Renamed package flowcache -> flowmanager
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
new file mode 100644
index 0000000..2800305
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
@@ -0,0 +1,61 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.io.IOException;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+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/flowmanager/web/AddShortestPathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddShortestPathFlowResource.java
new file mode 100644
index 0000000..9d2e0c9
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddShortestPathFlowResource.java
@@ -0,0 +1,64 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.io.IOException;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+
+import org.codehaus.jackson.JsonGenerationException;
+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/flowmanager/web/ClearFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/ClearFlowResource.java
new file mode 100644
index 0000000..1daa2ab
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/ClearFlowResource.java
@@ -0,0 +1,41 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+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/flowmanager/web/DatapathSummarySerializer.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DatapathSummarySerializer.java
new file mode 100644
index 0000000..9133077
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DatapathSummarySerializer.java
@@ -0,0 +1,82 @@
+package net.onrc.onos.ofcontroller.flowmanager.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/flowmanager/web/DeleteFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
new file mode 100644
index 0000000..393ff44
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
@@ -0,0 +1,41 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+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/flowmanager/web/FlowWebRoutable.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/FlowWebRoutable.java
new file mode 100644
index 0000000..954c84d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/FlowWebRoutable.java
@@ -0,0 +1,40 @@
+package net.onrc.onos.ofcontroller.flowmanager.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/flowmanager/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByEndpointsResource.java
new file mode 100644
index 0000000..6142096
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByEndpointsResource.java
@@ -0,0 +1,55 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.util.ArrayList;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
+
+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/flowmanager/web/GetAllFlowsByInstallerIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByInstallerIdResource.java
new file mode 100644
index 0000000..498108f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByInstallerIdResource.java
@@ -0,0 +1,60 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.util.ArrayList;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.CallerId;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
+
+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/flowmanager/web/GetAllFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsResource.java
new file mode 100644
index 0000000..61eaf27
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsResource.java
@@ -0,0 +1,36 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.util.ArrayList;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+
+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/flowmanager/web/GetFlowByIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
new file mode 100644
index 0000000..48e7369
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
@@ -0,0 +1,38 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+
+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/flowmanager/web/GetSummaryFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
new file mode 100644
index 0000000..4b3c00f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
@@ -0,0 +1,44 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.util.ArrayList;
+
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+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/flowmanager/web/MeasurementClearAllPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementClearAllPathsFlowResource.java
new file mode 100644
index 0000000..07d9fb2
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementClearAllPathsFlowResource.java
@@ -0,0 +1,33 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+
+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/flowmanager/web/MeasurementGetInstallPathsTimeNsecFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
new file mode 100644
index 0000000..467afca
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+
+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/flowmanager/web/MeasurementGetPerFlowInstallTimeFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementGetPerFlowInstallTimeFlowResource.java
new file mode 100644
index 0000000..92d84ab
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementGetPerFlowInstallTimeFlowResource.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+
+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/flowmanager/web/MeasurementInstallPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementInstallPathsFlowResource.java
new file mode 100644
index 0000000..074dfb4
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementInstallPathsFlowResource.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+
+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/flowmanager/web/MeasurementStorePathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementStorePathFlowResource.java
new file mode 100644
index 0000000..0f23663
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/MeasurementStorePathFlowResource.java
@@ -0,0 +1,64 @@
+package net.onrc.onos.ofcontroller.flowmanager.web;
+
+import java.io.IOException;
+
+import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+
+import org.codehaus.jackson.JsonGenerationException;
+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;
+ }
+}