Count number of FlowRules in parallel
Change-Id: Iec5ffdac0b46e2103619aad6675ee0f873cbf5e5
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 0f7e980..7ca613e 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
@@ -27,7 +27,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
- import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@@ -91,7 +90,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
- import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.Futures;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
@@ -333,9 +332,9 @@
// make it device specific.
@Override
public int getFlowRuleCount() {
- AtomicInteger sum = new AtomicInteger(0);
- deviceService.getDevices().forEach(device -> sum.addAndGet(Iterables.size(getFlowEntries(device.id()))));
- return sum.get();
+ return Streams.stream(deviceService.getDevices()).parallel()
+ .mapToInt(device -> Iterables.size(getFlowEntries(device.id())))
+ .sum();
}
@Override