Moved pure ONOS code in net.floodlightcontroller.flowcache.web to onos package namespace
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
index fcb57ea..1a01155 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.core;
-import net.floodlightcontroller.flowcache.web.DatapathSummarySerializer;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.flowcache.web.DatapathSummarySerializer;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
index 7caf8db..02fd920 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
@@ -24,7 +24,6 @@
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
-import net.floodlightcontroller.flowcache.web.FlowWebRoutable;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.util.CallerId;
import net.floodlightcontroller.util.DataPath;
@@ -49,6 +48,7 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
+import net.onrc.onos.ofcontroller.flowcache.web.FlowWebRoutable;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBConnection.Transaction;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java
new file mode 100644
index 0000000..2557c40
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java
@@ -0,0 +1,62 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.io.IOException;
+
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.restlet.resource.Post;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddFlowResource extends ServerResource {
+
+ protected static Logger log = LoggerFactory.getLogger(AddFlowResource.class);
+
+ @Post("json")
+ public FlowId store(String flowJson) {
+ FlowId result = new FlowId();
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ //
+ // Extract the arguments
+ // NOTE: The "flow" is specified in JSON format.
+ //
+ ObjectMapper mapper = new ObjectMapper();
+ String flowPathStr = flowJson;
+ FlowPath flowPath = null;
+ log.debug("Add Flow Path: " + flowPathStr);
+ try {
+ flowPath = mapper.readValue(flowPathStr, FlowPath.class);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Process the request
+ if (flowPath != null) {
+ if (flowService.addFlow(flowPath, result, null) != true) {
+ result = new FlowId(); // Error: Return empty Flow Id
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java
new file mode 100644
index 0000000..5a1c36f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java
@@ -0,0 +1,65 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.io.IOException;
+
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.restlet.resource.Post;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddShortestPathFlowResource extends ServerResource {
+
+ protected static Logger log = LoggerFactory.getLogger(AddShortestPathFlowResource.class);
+
+ @Post("json")
+ public FlowId store(String flowJson) {
+ FlowId result = new FlowId();
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ //
+ // Extract the arguments
+ // NOTE: The "flow" is specified in JSON format.
+ //
+ ObjectMapper mapper = new ObjectMapper();
+ String flowPathStr = flowJson;
+ FlowPath flowPath = null;
+ log.debug("Add Shortest Path Flow Path: " + flowPathStr);
+ try {
+ flowPath = mapper.readValue(flowPathStr, FlowPath.class);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Process the request
+ if (flowPath != null) {
+ FlowPath addedFlowPath =
+ flowService.addAndMaintainShortestPathFlow(flowPath);
+ if (addedFlowPath == null)
+ result = new FlowId(); // Error: Return empty Flow Id
+ else
+ result = addedFlowPath.flowId();
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java
new file mode 100644
index 0000000..fe19ce0
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java
@@ -0,0 +1,42 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ClearFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(ClearFlowResource.class);
+
+ @Get("json")
+ public Boolean retrieve() {
+ Boolean result = false;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String flowIdStr = (String) getRequestAttributes().get("flow-id");
+
+ // Process the request
+ if (flowIdStr.equals("all")) {
+ log.debug("Clear All Flows");
+ result = flowService.clearAllFlows();
+ } else {
+ FlowId flowId = new FlowId(flowIdStr);
+ log.debug("Clear Flow Id: " + flowIdStr);
+ result = flowService.clearFlow(flowId);
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DatapathSummarySerializer.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DatapathSummarySerializer.java
new file mode 100644
index 0000000..2022966
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DatapathSummarySerializer.java
@@ -0,0 +1,82 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DatapathSummarySerializer extends JsonSerializer<String>{
+ static Logger log = LoggerFactory.getLogger(DatapathSummarySerializer.class);
+
+ @Override
+ public void serialize(String datapathSummary, JsonGenerator jGen,
+ SerializerProvider serializer) throws IOException,
+ JsonProcessingException {
+
+ String[] flowEntries = datapathSummary.split(";");
+ if (flowEntries.length < 2){
+ log.debug("datapathSummary string to short to parse: {}",
+ datapathSummary);
+ jGen.writeStartObject();
+ jGen.writeEndObject();
+ return;
+ }
+
+ String[] srcFlowEntry = flowEntries[0].split("/");
+ String[] dstFlowEntry = flowEntries[flowEntries.length - 1].split("/");
+ if (srcFlowEntry.length != 3 || dstFlowEntry.length != 3){
+ log.debug("Malformed datapathSummary string: {}", datapathSummary);
+ jGen.writeStartObject();
+ jGen.writeEndObject();
+ return;
+ }
+
+ jGen.writeStartObject();
+
+ /*
+ jGen.writeObjectFieldStart("srcPort");
+ jGen.writeObjectFieldStart("dpid");
+ jGen.writeStringField("value", srcFlowEntry[1]);
+ jGen.writeEndObject();
+ jGen.writeObjectFieldStart("port");
+ jGen.writeStringField("value", srcFlowEntry[0]);
+ jGen.writeEndObject();
+ jGen.writeEndObject();
+
+ jGen.writeObjectFieldStart("dstPort");
+ jGen.writeObjectFieldStart("dpid");
+ jGen.writeStringField("value", srcFlowEntry[1]);
+ jGen.writeEndObject();
+ jGen.writeObjectFieldStart("port");
+ jGen.writeStringField("value", srcFlowEntry[2]);
+ jGen.writeEndObject();
+ jGen.writeEndObject();
+ */
+ jGen.writeArrayFieldStart("flowEntries");
+
+ for (String flowEntryString : flowEntries){
+ String[] flowEntry = flowEntryString.split("/");
+ if (flowEntry.length != 3){
+ log.debug("Malformed datapathSummary string: {}", datapathSummary);
+ jGen.writeStartObject();
+ jGen.writeEndObject();
+ continue;
+ }
+
+ jGen.writeStartObject();
+ jGen.writeObjectFieldStart("dpid");
+ jGen.writeStringField("value", flowEntry[1]);
+ jGen.writeEndObject();
+ jGen.writeEndObject();
+ }
+
+ jGen.writeEndArray();
+
+ jGen.writeEndObject();
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java
new file mode 100644
index 0000000..f393c0e
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java
@@ -0,0 +1,42 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeleteFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(DeleteFlowResource.class);
+
+ @Get("json")
+ public Boolean retrieve() {
+ Boolean result = false;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String flowIdStr = (String) getRequestAttributes().get("flow-id");
+
+ // Process the request
+ if (flowIdStr.equals("all")) {
+ log.debug("Delete All Flows");
+ result = flowService.deleteAllFlows();
+ } else {
+ FlowId flowId = new FlowId(flowIdStr);
+ log.debug("Delete Flow Id: " + flowIdStr);
+ result = flowService.deleteFlow(flowId);
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/FlowWebRoutable.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/FlowWebRoutable.java
new file mode 100644
index 0000000..a2a3e54
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/FlowWebRoutable.java
@@ -0,0 +1,40 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.restserver.RestletRoutable;
+
+import org.restlet.Context;
+import org.restlet.Restlet;
+import org.restlet.routing.Router;
+
+public class FlowWebRoutable implements RestletRoutable {
+ /**
+ * Create the Restlet router and bind to the proper resources.
+ */
+ @Override
+ public Restlet getRestlet(Context context) {
+ Router router = new Router(context);
+ router.attach("/add/json", AddFlowResource.class);
+ router.attach("/add-shortest-path/json", AddShortestPathFlowResource.class);
+ router.attach("/clear/{flow-id}/json", ClearFlowResource.class);
+ router.attach("/delete/{flow-id}/json", DeleteFlowResource.class);
+ router.attach("/get/{flow-id}/json", GetFlowByIdResource.class);
+ router.attach("/getall-by-installer-id/{installer-id}/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", GetAllFlowsByInstallerIdResource.class);
+ router.attach("/getall-by-endpoints/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", GetAllFlowsByEndpointsResource.class);
+ router.attach("/getall/json", GetAllFlowsResource.class);
+ router.attach("/getsummary/{flow-id}/{max-flows}/json", GetSummaryFlowsResource.class);
+ router.attach("/measurement-store-path/json", MeasurementStorePathFlowResource.class);
+ router.attach("/measurement-install-paths/{num-threads}/json", MeasurementInstallPathsFlowResource.class);
+ router.attach("/measurement-get-install-paths-time-nsec/json", MeasurementGetInstallPathsTimeNsecFlowResource.class);
+ router.attach("/measurement-get-per-flow-install-time/json", MeasurementGetPerFlowInstallTimeFlowResource.class);
+ router.attach("/measurement-clear-all-paths/json", MeasurementClearAllPathsFlowResource.class);
+ return router;
+ }
+
+ /**
+ * Set the base path for the Topology
+ */
+ @Override
+ public String basePath() {
+ return "/wm/flow";
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
new file mode 100644
index 0000000..2c3d81e
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
@@ -0,0 +1,55 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.util.ArrayList;
+
+import net.floodlightcontroller.util.DataPathEndpoints;
+import net.floodlightcontroller.util.Dpid;
+import net.floodlightcontroller.util.FlowPath;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetAllFlowsByEndpointsResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(GetAllFlowsByEndpointsResource.class);
+
+ @Get("json")
+ public ArrayList<FlowPath> retrieve() {
+ ArrayList<FlowPath> result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
+ String srcPortStr = (String) getRequestAttributes().get("src-port");
+ String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
+ String dstPortStr = (String) getRequestAttributes().get("dst-port");
+
+ log.debug("Get All Flows Endpoints: " + srcDpidStr + "--" +
+ srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
+
+ Dpid srcDpid = new Dpid(srcDpidStr);
+ Port srcPort = new Port(Short.parseShort(srcPortStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
+ Port dstPort = new Port(Short.parseShort(dstPortStr));
+ SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
+ SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
+ DataPathEndpoints dataPathEndpoints =
+ new DataPathEndpoints(srcSwitchPort, dstSwitchPort);
+
+ result = flowService.getAllFlows(dataPathEndpoints);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java
new file mode 100644
index 0000000..f55e105
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java
@@ -0,0 +1,60 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.util.ArrayList;
+
+import net.floodlightcontroller.util.CallerId;
+import net.floodlightcontroller.util.DataPathEndpoints;
+import net.floodlightcontroller.util.Dpid;
+import net.floodlightcontroller.util.FlowPath;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetAllFlowsByInstallerIdResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(GetAllFlowsByInstallerIdResource.class);
+
+ @Get("json")
+ public ArrayList<FlowPath> retrieve() {
+ ArrayList<FlowPath> result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String installerIdStr = (String) getRequestAttributes().get("installer-id");
+ String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
+ String srcPortStr = (String) getRequestAttributes().get("src-port");
+ String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
+ String dstPortStr = (String) getRequestAttributes().get("dst-port");
+
+ log.debug("Get All Flow By Installer: " + installerIdStr +
+ " Endpoints: " +
+ srcDpidStr + "--" + srcPortStr + "--" +
+ dstDpidStr + "--" + dstPortStr);
+
+ CallerId installerId = new CallerId(installerIdStr);
+ Dpid srcDpid = new Dpid(srcDpidStr);
+ Port srcPort = new Port(Short.parseShort(srcPortStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
+ Port dstPort = new Port(Short.parseShort(dstPortStr));
+ SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
+ SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
+ DataPathEndpoints dataPathEndpoints =
+ new DataPathEndpoints(srcSwitchPort, dstSwitchPort);
+
+ result = flowService.getAllFlows(installerId, dataPathEndpoints);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java
new file mode 100644
index 0000000..1f9176f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java
@@ -0,0 +1,36 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.util.ArrayList;
+
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetAllFlowsResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(GetAllFlowsResource.class);
+
+ @Get("json")
+ public ArrayList<FlowPath> retrieve() {
+ ArrayList<FlowPath> result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ log.debug("Get All Flows Endpoints");
+
+ result = flowService.getAllFlows();
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java
new file mode 100644
index 0000000..fbfc169
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java
@@ -0,0 +1,38 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetFlowByIdResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(GetFlowByIdResource.class);
+
+ @Get("json")
+ public FlowPath retrieve() {
+ FlowPath result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String flowIdStr = (String) getRequestAttributes().get("flow-id");
+ FlowId flowId = new FlowId(flowIdStr);
+
+ log.debug("Get Flow Id: " + flowIdStr);
+
+ result = flowService.getFlow(flowId);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java
new file mode 100644
index 0000000..ed0aea8
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java
@@ -0,0 +1,45 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.util.ArrayList;
+
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetSummaryFlowsResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(GetSummaryFlowsResource.class);
+
+ @Get("json")
+ public ArrayList<IFlowPath> retrieve() {
+ ArrayList<IFlowPath> result = null;
+
+ FlowId flowId;
+ int maxFlows = 0;
+
+ IFlowService flowService = (IFlowService)getContext().getAttributes().get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String flowIdStr = (String) getRequestAttributes().get("flow-id");
+ String maxFlowStr = (String) getRequestAttributes().get("max-flows");
+ log.debug("Get Summary Flows starting flow-id: " + flowIdStr + " max-flows: " + maxFlowStr);
+
+ flowId = new FlowId(flowIdStr);
+ maxFlows = Integer.parseInt(maxFlowStr);
+ if (maxFlows < 0) maxFlows = 0;
+
+ result = flowService.getAllFlowsSummary(flowId, maxFlows);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java
new file mode 100644
index 0000000..58dd3f4
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeasurementClearAllPathsFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(MeasurementClearAllPathsFlowResource.class);
+
+ @Get("json")
+ public Boolean retrieve() {
+ Boolean result = false;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ log.debug("Measurement Clear All Paths");
+
+ // Process the request
+ result = flowService.measurementClearAllPaths();
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
new file mode 100644
index 0000000..83ac152
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
@@ -0,0 +1,37 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeasurementGetInstallPathsTimeNsecFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(MeasurementGetInstallPathsTimeNsecFlowResource.class);
+
+ @Get("json")
+ public Long retrieve() {
+ Long result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+
+ // Process the request
+ result = flowService.measurementGetInstallPathsTimeNsec();
+
+ log.debug("Measurement Get Install Paths Time (nsec): " + result);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java
new file mode 100644
index 0000000..c01e624
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java
@@ -0,0 +1,37 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeasurementGetPerFlowInstallTimeFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(MeasurementGetPerFlowInstallTimeFlowResource.class);
+
+ @Get("json")
+ public String retrieve() {
+ String result = null;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+
+ // Process the request
+ result = flowService.measurementGetPerFlowInstallTime();
+
+ log.debug("Measurement Get Install Paths Time (nsec): " + result);
+
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java
new file mode 100644
index 0000000..e0ecb18
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java
@@ -0,0 +1,37 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import net.floodlightcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.openflow.util.HexString;
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeasurementInstallPathsFlowResource extends ServerResource {
+ protected static Logger log = LoggerFactory.getLogger(MeasurementInstallPathsFlowResource.class);
+
+ @Get("json")
+ public Boolean retrieve() {
+ Boolean result = false;
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ // Extract the arguments
+ String numThreadsStr = (String) getRequestAttributes().get("num-threads");
+ Integer numThreads = new Integer(numThreadsStr);
+ log.debug("Measurement Install Paths Number of Threads " + numThreadsStr);
+
+ // Process the request
+ result = flowService.measurementInstallPaths(numThreads);
+ return result;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java
new file mode 100644
index 0000000..42b1d7d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java
@@ -0,0 +1,65 @@
+package net.onrc.onos.ofcontroller.flowcache.web;
+
+import java.io.IOException;
+
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.restlet.resource.Post;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MeasurementStorePathFlowResource extends ServerResource {
+
+ protected static Logger log = LoggerFactory.getLogger(MeasurementStorePathFlowResource.class);
+
+ @Post("json")
+ public FlowId store(String flowJson) {
+ FlowId result = new FlowId();
+
+ IFlowService flowService =
+ (IFlowService)getContext().getAttributes().
+ get(IFlowService.class.getCanonicalName());
+
+ if (flowService == null) {
+ log.debug("ONOS Flow Service not found");
+ return result;
+ }
+
+ //
+ // Extract the arguments
+ // NOTE: The "flow" is specified in JSON format.
+ //
+ ObjectMapper mapper = new ObjectMapper();
+ String flowPathStr = flowJson;
+ FlowPath flowPath = null;
+ log.debug("Measurement Store Flow Path: " + flowPathStr);
+ try {
+ flowPath = mapper.readValue(flowPathStr, FlowPath.class);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Process the request
+ if (flowPath != null) {
+ FlowPath addedFlowPath =
+ flowService.measurementStorePathFlow(flowPath);
+ if (addedFlowPath == null)
+ result = new FlowId(); // Error: Return empty Flow Id
+ else
+ result = addedFlowPath.flowId();
+ }
+
+ return result;
+ }
+}