alshabib

remote stats service functional

Change-Id: I4ebc4c565b7ee7533b5bd1a0379f54470223ba0e
...@@ -3,8 +3,7 @@ package org.onlab.onos.store.statistic.impl; ...@@ -3,8 +3,7 @@ package org.onlab.onos.store.statistic.impl;
3 import static org.onlab.onos.store.statistic.impl.StatisticStoreMessageSubjects.*; 3 import static org.onlab.onos.store.statistic.impl.StatisticStoreMessageSubjects.*;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
5 5
6 -import com.google.common.collect.ImmutableSet; 6 +import com.google.common.collect.Sets;
7 -
8 import org.apache.felix.scr.annotations.Activate; 7 import org.apache.felix.scr.annotations.Activate;
9 import org.apache.felix.scr.annotations.Component; 8 import org.apache.felix.scr.annotations.Component;
10 import org.apache.felix.scr.annotations.Deactivate; 9 import org.apache.felix.scr.annotations.Deactivate;
...@@ -130,7 +129,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -130,7 +129,7 @@ public class DistributedStatisticStore implements StatisticStore {
130 } 129 }
131 130
132 @Override 131 @Override
133 - public void removeFromStatistics(FlowRule rule) { 132 + public synchronized void removeFromStatistics(FlowRule rule) {
134 ConnectPoint cp = buildConnectPoint(rule); 133 ConnectPoint cp = buildConnectPoint(rule);
135 if (cp == null) { 134 if (cp == null) {
136 return; 135 return;
...@@ -139,6 +138,15 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -139,6 +138,15 @@ public class DistributedStatisticStore implements StatisticStore {
139 if (rep != null) { 138 if (rep != null) {
140 rep.remove(rule); 139 rep.remove(rule);
141 } 140 }
141 + Set<FlowEntry> values = current.get(cp);
142 + if (values != null) {
143 + values.remove(rule);
144 + }
145 + values = previous.get(cp);
146 + if (values != null) {
147 + values.remove(rule);
148 + }
149 +
142 } 150 }
143 151
144 @Override 152 @Override
...@@ -181,7 +189,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -181,7 +189,7 @@ public class DistributedStatisticStore implements StatisticStore {
181 return SERIALIZER.decode(response.get(STATISTIC_STORE_TIMEOUT_MILLIS, 189 return SERIALIZER.decode(response.get(STATISTIC_STORE_TIMEOUT_MILLIS,
182 TimeUnit.MILLISECONDS)); 190 TimeUnit.MILLISECONDS));
183 } catch (IOException | TimeoutException e) { 191 } catch (IOException | TimeoutException e) {
184 - // FIXME: throw a FlowStoreException 192 + // FIXME: throw a StatsStoreException
185 throw new RuntimeException(e); 193 throw new RuntimeException(e);
186 } 194 }
187 } 195 }
...@@ -200,7 +208,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -200,7 +208,7 @@ public class DistributedStatisticStore implements StatisticStore {
200 } else { 208 } else {
201 ClusterMessage message = new ClusterMessage( 209 ClusterMessage message = new ClusterMessage(
202 clusterService.getLocalNode().id(), 210 clusterService.getLocalNode().id(),
203 - GET_CURRENT, 211 + GET_PREVIOUS,
204 SERIALIZER.encode(connectPoint)); 212 SERIALIZER.encode(connectPoint));
205 213
206 try { 214 try {
...@@ -209,7 +217,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -209,7 +217,7 @@ public class DistributedStatisticStore implements StatisticStore {
209 return SERIALIZER.decode(response.get(STATISTIC_STORE_TIMEOUT_MILLIS, 217 return SERIALIZER.decode(response.get(STATISTIC_STORE_TIMEOUT_MILLIS,
210 TimeUnit.MILLISECONDS)); 218 TimeUnit.MILLISECONDS));
211 } catch (IOException | TimeoutException e) { 219 } catch (IOException | TimeoutException e) {
212 - // FIXME: throw a FlowStoreException 220 + // FIXME: throw a StatsStoreException
213 throw new RuntimeException(e); 221 throw new RuntimeException(e);
214 } 222 }
215 } 223 }
...@@ -283,7 +291,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -283,7 +291,7 @@ public class DistributedStatisticStore implements StatisticStore {
283 291
284 public synchronized Set<FlowEntry> get() { 292 public synchronized Set<FlowEntry> get() {
285 counter.set(rules.size()); 293 counter.set(rules.size());
286 - return ImmutableSet.copyOf(rules); 294 + return Sets.newHashSet(rules);
287 } 295 }
288 296
289 297
......
...@@ -31,6 +31,7 @@ import org.onlab.onos.net.flow.DefaultFlowEntry; ...@@ -31,6 +31,7 @@ import org.onlab.onos.net.flow.DefaultFlowEntry;
31 import org.onlab.onos.net.flow.DefaultFlowRule; 31 import org.onlab.onos.net.flow.DefaultFlowRule;
32 import org.onlab.onos.net.flow.DefaultTrafficSelector; 32 import org.onlab.onos.net.flow.DefaultTrafficSelector;
33 import org.onlab.onos.net.flow.DefaultTrafficTreatment; 33 import org.onlab.onos.net.flow.DefaultTrafficTreatment;
34 +import org.onlab.onos.net.flow.FlowEntry;
34 import org.onlab.onos.net.flow.FlowId; 35 import org.onlab.onos.net.flow.FlowId;
35 import org.onlab.onos.net.flow.criteria.Criteria; 36 import org.onlab.onos.net.flow.criteria.Criteria;
36 import org.onlab.onos.net.flow.criteria.Criterion; 37 import org.onlab.onos.net.flow.criteria.Criterion;
...@@ -98,6 +99,7 @@ public final class KryoNamespaces { ...@@ -98,6 +99,7 @@ public final class KryoNamespaces {
98 DefaultHostDescription.class, 99 DefaultHostDescription.class,
99 DefaultFlowRule.class, 100 DefaultFlowRule.class,
100 DefaultFlowEntry.class, 101 DefaultFlowEntry.class,
102 + FlowEntry.FlowEntryState.class,
101 FlowId.class, 103 FlowId.class,
102 DefaultTrafficSelector.class, 104 DefaultTrafficSelector.class,
103 Criteria.PortCriterion.class, 105 Criteria.PortCriterion.class,
......