Reimplement the backend for the Flow getsummary REST call.
After the change, the speedup is approximately 100x.
E.g., previously it was taking 15 seconds to getsummary for 100 flows;
now it takes approximately 150milliseconds.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index d794ced..3fe47a0 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -2,12 +2,12 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.SortedMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
@@ -303,21 +303,27 @@
@Override
public ArrayList<FlowPath> getAllFlowsSummary(FlowId flowId,
int maxFlows) {
- ArrayList<FlowPath> flowPaths =
- FlowDatabaseOperation.getAllFlows(dbHandlerApi);
+ ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
+ SortedMap<Long, FlowPath> sortedFlowPaths =
+ flowEventHandler.getAllFlowPathsCopy();
+ //
// Truncate each Flow Path and Flow Entry
- for (FlowPath flowPath : flowPaths) {
+ //
+ for (FlowPath flowPath : sortedFlowPaths.values()) {
+ //
+ // TODO: Add only the Flow Paths that have been successfully
+ // installed.
+ //
flowPath.setFlowEntryMatch(null);
flowPath.setFlowEntryActions(null);
for (FlowEntry flowEntry : flowPath.flowEntries()) {
flowEntry.setFlowEntryMatch(null);
flowEntry.setFlowEntryActions(null);
}
+ flowPaths.add(flowPath);
}
- Collections.sort(flowPaths);
-
return flowPaths;
}