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;
import org.slf4j.Logger;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
......@@ -153,8 +154,8 @@ public class DistributedStatisticStore implements StatisticStore {
return;
}
InternalStatisticRepresentation rep = representations.get(cp);
if (rep != null) {
rep.remove(rule);
if (rep != null && rep.remove(rule)) {
updatePublishedStats(cp, Collections.emptySet());
}
Set<FlowEntry> values = current.get(cp);
if (values != null) {
......@@ -304,9 +305,9 @@ public class DistributedStatisticStore implements StatisticStore {
counter.incrementAndGet();
}
public synchronized void remove(FlowRule rule) {
public synchronized boolean remove(FlowRule rule) {
rules.remove(rule);
counter.decrementAndGet();
return counter.decrementAndGet() == 0;
}
public synchronized boolean submit(FlowEntry rule) {
......
......@@ -29,6 +29,7 @@ import org.onlab.onos.net.flow.instructions.Instructions;
import org.onlab.onos.net.statistic.StatisticStore;
import org.slf4j.Logger;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
......@@ -84,8 +85,8 @@ public class SimpleStatisticStore implements StatisticStore {
return;
}
InternalStatisticRepresentation rep = representations.get(cp);
if (rep != null) {
rep.remove(rule);
if (rep != null && rep.remove(rule)) {
updatePublishedStats(cp, Collections.emptySet());
}
Set<FlowEntry> values = current.get(cp);
if (values != null) {
......@@ -183,9 +184,9 @@ public class SimpleStatisticStore implements StatisticStore {
counter.incrementAndGet();
}
public synchronized void remove(FlowRule rule) {
public synchronized boolean remove(FlowRule rule) {
rules.remove(rule);
counter.decrementAndGet();
return counter.decrementAndGet() == 0;
}
public synchronized boolean submit(FlowEntry rule) {
......