[ONOS-6607] Get active flow entries count in FlowRuleService
Change-Id: I68b4d916f92427c06a82d3622fcc05738f64541c
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
index af388bab..0f7e980 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
@@ -31,6 +31,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
+ import com.google.common.collect.Streams;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -926,6 +927,13 @@
return ImmutableList.copyOf(tableStats);
}
+ @Override
+ public long getActiveFlowRuleCount(DeviceId deviceId) {
+ return Streams.stream(getTableStatistics(deviceId))
+ .mapToLong(TableStatisticsEntry::activeFlowEntries)
+ .sum();
+ }
+
private class InternalTableStatsListener
implements EventuallyConsistentMapListener<DeviceId, List<TableStatisticsEntry>> {
@Override