Get flow summary now returns flows in order of FlowId, and we attempt to filter out null flows caused by empty vertices in Titan
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index 2b9bf68..ab60e68 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -57,9 +59,11 @@
import org.openflow.protocol.OFType;
import org.openflow.protocol.action.OFAction;
import org.openflow.protocol.action.OFActionOutput;
+import org.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class FlowManager implements IFloodlightModule, IFlowService, INetMapStorage {
public GraphDBConnection conn;
@@ -903,10 +907,7 @@
*/
@Override
public ArrayList<IFlowPath> getAllFlowsSummary(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.
@@ -917,6 +918,20 @@
ArrayList<IFlowPath> flowPathsWithoutFlowEntries = getAllFlowsWithoutFlowEntries();
+ Collections.sort(flowPathsWithoutFlowEntries,
+ new Comparator<IFlowPath>(){
+ @Override
+ public int compare(IFlowPath first, IFlowPath second) {
+ // TODO Auto-generated method stub
+ long result = new FlowId(first.getFlowId()).value()
+ - new FlowId(second.getFlowId()).value();
+ if (result > 0) return 1;
+ else if (result < 0) return -1;
+ else return 0;
+ }
+ }
+ );
+
return flowPathsWithoutFlowEntries;
/*
diff --git a/src/main/java/net/onrc/onos/util/GraphDBUtils.java b/src/main/java/net/onrc/onos/util/GraphDBUtils.java
index 7283d09..1646fc7 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBUtils.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBUtils.java
@@ -140,10 +140,18 @@
}
@Override
- public Iterable<IFlowPath> getAllFlowPaths(GraphDBConnection conn) {
+ public Iterable<IFlowPath> getAllFlowPaths(GraphDBConnection conn) {
FramedGraph<TitanGraph> fg = conn.getFramedGraph();
+ Iterable<IFlowPath> flowPaths = fg.getVertices("type", "flow", IFlowPath.class);
- return fg.getVertices("type", "flow", IFlowPath.class);
+ List<IFlowPath> nonNullFlows = new ArrayList<IFlowPath>();
+
+ for (IFlowPath fp: flowPaths) {
+ if (fp.getFlowId() != null) {
+ nonNullFlows.add(fp);
+ }
+ }
+ return nonNullFlows;
}
@Override