Minor refactoring of the getAllFlowsSummary() implementation:
Avoid chained calls and move all the processing logic in a single place.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index 75bd8b2..1babafa 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -3,7 +3,6 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
@@ -496,52 +495,6 @@
}
/**
- * Get summary of all installed flows by all installers in a given range.
- *
- * @param dbHandler the Graph Database handler to use.
- * @param flowId the Flow ID of the first flow in the flow range to get.
- * @param maxFlows the maximum number of flows to be returned.
- * @return the Flow Paths if found, otherwise null.
- */
- static ArrayList<FlowPath> getAllFlowsSummary(GraphDBOperation dbHandler,
- FlowId flowId,
- int maxFlows) {
- //
- // TODO: The implementation below is not optimal:
- // We fetch all flows, and then return only the subset that match
- // the query conditions.
- // We should use the appropriate Titan/Gremlin query to filter-out
- // the flows as appropriate.
- //
- ArrayList<FlowPath> flowPaths = getAllFlowsWithDataPathSummary(dbHandler);
- Collections.sort(flowPaths);
- return flowPaths;
- }
-
- /**
- * Get all Flows information, with Data Path summary for the Flow Entries.
- *
- * @param dbHandler the Graph Database handler to use.
- * @return all Flows information, with Data Path summary for the Flow
- * Entries.
- */
- static ArrayList<FlowPath> getAllFlowsWithDataPathSummary(GraphDBOperation dbHandler) {
- ArrayList<FlowPath> flowPaths = getAllFlows(dbHandler);
-
- // Truncate each Flow Path and Flow Entry
- for (FlowPath flowPath : flowPaths) {
- flowPath.setFlowEntryMatch(null);
- flowPath.setFlowEntryActions(null);
- for (FlowEntry flowEntry : flowPath.flowEntries()) {
- flowEntry.setFlowEntryMatch(null);
- flowEntry.setFlowEntryActions(null);
- }
- }
-
- return flowPaths;
- }
-
- /**
* Extract Flow Path State from a Titan Database Object @ref IFlowPath.
*
* @param flowObj the object to extract the Flow Path State from.
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 89fe63e..d794ced 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -302,8 +303,22 @@
@Override
public ArrayList<FlowPath> getAllFlowsSummary(FlowId flowId,
int maxFlows) {
- return FlowDatabaseOperation.getAllFlowsSummary(dbHandlerApi, flowId,
- maxFlows);
+ ArrayList<FlowPath> flowPaths =
+ FlowDatabaseOperation.getAllFlows(dbHandlerApi);
+
+ // Truncate each Flow Path and Flow Entry
+ for (FlowPath flowPath : flowPaths) {
+ flowPath.setFlowEntryMatch(null);
+ flowPath.setFlowEntryActions(null);
+ for (FlowEntry flowEntry : flowPath.flowEntries()) {
+ flowEntry.setFlowEntryMatch(null);
+ flowEntry.setFlowEntryActions(null);
+ }
+ }
+
+ Collections.sort(flowPaths);
+
+ return flowPaths;
}
/**