alshabib

check if there are any stats remaining when removing

Change-Id: I6af100ff73d5f577f38901b8f0ec881e51253cc8

apply fix to distributed store

Change-Id: I829394e919aa79f10e01ac42904f5708b296cf51
...@@ -46,6 +46,7 @@ import org.onlab.util.KryoNamespace; ...@@ -46,6 +46,7 @@ import org.onlab.util.KryoNamespace;
46 import org.slf4j.Logger; 46 import org.slf4j.Logger;
47 47
48 import java.io.IOException; 48 import java.io.IOException;
49 +import java.util.Collections;
49 import java.util.HashSet; 50 import java.util.HashSet;
50 import java.util.Map; 51 import java.util.Map;
51 import java.util.Set; 52 import java.util.Set;
...@@ -153,8 +154,8 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -153,8 +154,8 @@ public class DistributedStatisticStore implements StatisticStore {
153 return; 154 return;
154 } 155 }
155 InternalStatisticRepresentation rep = representations.get(cp); 156 InternalStatisticRepresentation rep = representations.get(cp);
156 - if (rep != null) { 157 + if (rep != null && rep.remove(rule)) {
157 - rep.remove(rule); 158 + updatePublishedStats(cp, Collections.emptySet());
158 } 159 }
159 Set<FlowEntry> values = current.get(cp); 160 Set<FlowEntry> values = current.get(cp);
160 if (values != null) { 161 if (values != null) {
...@@ -304,9 +305,9 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -304,9 +305,9 @@ public class DistributedStatisticStore implements StatisticStore {
304 counter.incrementAndGet(); 305 counter.incrementAndGet();
305 } 306 }
306 307
307 - public synchronized void remove(FlowRule rule) { 308 + public synchronized boolean remove(FlowRule rule) {
308 rules.remove(rule); 309 rules.remove(rule);
309 - counter.decrementAndGet(); 310 + return counter.decrementAndGet() == 0;
310 } 311 }
311 312
312 public synchronized boolean submit(FlowEntry rule) { 313 public synchronized boolean submit(FlowEntry rule) {
......
...@@ -29,6 +29,7 @@ import org.onlab.onos.net.flow.instructions.Instructions; ...@@ -29,6 +29,7 @@ import org.onlab.onos.net.flow.instructions.Instructions;
29 import org.onlab.onos.net.statistic.StatisticStore; 29 import org.onlab.onos.net.statistic.StatisticStore;
30 import org.slf4j.Logger; 30 import org.slf4j.Logger;
31 31
32 +import java.util.Collections;
32 import java.util.HashSet; 33 import java.util.HashSet;
33 import java.util.Map; 34 import java.util.Map;
34 import java.util.Set; 35 import java.util.Set;
...@@ -84,8 +85,8 @@ public class SimpleStatisticStore implements StatisticStore { ...@@ -84,8 +85,8 @@ public class SimpleStatisticStore implements StatisticStore {
84 return; 85 return;
85 } 86 }
86 InternalStatisticRepresentation rep = representations.get(cp); 87 InternalStatisticRepresentation rep = representations.get(cp);
87 - if (rep != null) { 88 + if (rep != null && rep.remove(rule)) {
88 - rep.remove(rule); 89 + updatePublishedStats(cp, Collections.emptySet());
89 } 90 }
90 Set<FlowEntry> values = current.get(cp); 91 Set<FlowEntry> values = current.get(cp);
91 if (values != null) { 92 if (values != null) {
...@@ -183,9 +184,9 @@ public class SimpleStatisticStore implements StatisticStore { ...@@ -183,9 +184,9 @@ public class SimpleStatisticStore implements StatisticStore {
183 counter.incrementAndGet(); 184 counter.incrementAndGet();
184 } 185 }
185 186
186 - public synchronized void remove(FlowRule rule) { 187 + public synchronized boolean remove(FlowRule rule) {
187 rules.remove(rule); 188 rules.remove(rule);
188 - counter.decrementAndGet(); 189 + return counter.decrementAndGet() == 0;
189 } 190 }
190 191
191 public synchronized boolean submit(FlowEntry rule) { 192 public synchronized boolean submit(FlowEntry rule) {
......