Reimplement the Shortest Path computation so it doesn't use
the (very) slow Gremlin Script mechanism.
diff --git a/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java b/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
index 94e4769..1f21221 100644
--- a/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
+++ b/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
@@ -24,6 +24,9 @@
 import com.thinkaurelius.titan.core.TitanGraph;
 import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
 import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.gremlin.java.GremlinPipeline;
+import com.tinkerpop.pipes.PipeFunction;
+import com.tinkerpop.pipes.branch.LoopPipe.LoopBundle;
 
 import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
@@ -91,6 +94,21 @@
 
     SwitchStorageImpl swStore = store.get();
 
+    static class ShortestPathLoopFunction implements PipeFunction<LoopBundle<Vertex>, Boolean> {
+	String dpid;
+	public ShortestPathLoopFunction(String dpid) {
+	    super();
+	    this.dpid = dpid;
+	}
+	public Boolean compute(LoopBundle<Vertex> bundle) {
+	    Boolean output = false;
+	    if (! bundle.getObject().getProperty("dpid").equals(dpid)) {
+		output = true;
+	    }
+	    return output;
+	}
+    }
+
     @Override
     public DataPath getShortestPath(SwitchPort src, SwitchPort dest) {
 	DataPath result_data_path = new DataPath();
@@ -112,8 +130,6 @@
 	//   results = []; v_src.as("x").out("on").out("link").in("on").dedup().loop("x"){it.object.dpid != v_dest.dpid}.path().fill(results)
 	//
 
-	String gremlin = "v_src.as(\"x\").out(\"on\").out(\"link\").in(\"on\").dedup().loop(\"x\"){it.object.dpid != v_dest.dpid}.path().fill(results)";
-
 	// Get the source vertex
 	Iterator<Vertex> iter = titanGraph.getVertices("dpid", dpid_src).iterator();
 	if (! iter.hasNext()) {
@@ -147,24 +163,12 @@
 	    return result_data_path;
 	}
 
-	//
-	// Implement the Gremlin script and run it
-	//
-	ScriptEngine engine = new GremlinGroovyScriptEngine();
-
-	ArrayList<ArrayList<Vertex>> results = new ArrayList<ArrayList<Vertex>>();
-	engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", titanGraph);
-	engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v_src", v_src);
-	engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v_dest", v_dest);
-	engine.getBindings(ScriptContext.ENGINE_SCOPE).put("results", results);
-
-	try {
-	    engine.eval(gremlin);
-	} catch (ScriptException e) {
-	    System.err.println("Caught ScriptException running Gremlin script: " + e.getMessage());
-	    // titanGraph.stopTransaction(Conclusion.SUCCESS);
-	    return null;
-	}
+	ShortestPathLoopFunction whileFunction = new ShortestPathLoopFunction(dpid_dest);
+	GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>();
+	Collection<List> results = new ArrayList<List>();
+	GremlinPipeline<Vertex, List> path;
+	path = pipe.start(v_src).as("x").out("on").out("link").in("on").dedup().loop("x", whileFunction).path();
+	path.fill(results);
 
 	//
 	// Loop through the result and collect the list
@@ -174,14 +178,15 @@
 	short portId = 0;
 	Port inPort = new Port(src.port().value());
 	Port outPort = new Port();
-	for (ArrayList<Vertex> lv : results) {
+	for (List l : results) {
 	    int idx = 0;
-	    for (Vertex v: lv) {
+	    for (Object o: l) {
+		Vertex v = (Vertex)(o);
 		String type = v.getProperty("type").toString();
-		System.out.println("type: " + type);
+		// System.out.println("type: " + type);
 		if (type.equals("port")) {
 		    String number = v.getProperty("number").toString();
-		    System.out.println("number: " + number);
+		    // System.out.println("number: " + number);
 
 		    Object obj = v.getProperty("number");
 		    // String class_str = obj.getClass().toString();
@@ -197,7 +202,7 @@
 		    String dpid = v.getProperty("dpid").toString();
 		    nodeId = HexString.toLong(dpid);
 
-		    System.out.println("dpid: " + dpid);
+		    // System.out.println("dpid: " + dpid);
 		}
 		idx++;
 		if (idx == 1) {