* Add missing Javadoc comments related to the Flow Manager.
* Minor cleanup inside the Flow Manager.
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 2b3b0f2..f47e631 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -64,7 +64,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+/**
+ * @short Flow Manager class for handling the network flows.
+ */
public class FlowManager implements IFloodlightModule, IFlowService, INetMapStorage {
protected GraphDBOperation op;
@@ -105,6 +107,10 @@
private ScheduledExecutorService mapReaderScheduler;
private ScheduledExecutorService shortestPathReconcileScheduler;
+ /**
+ * Periodic task for reading the Flow Entries and pushing changes
+ * into the switches.
+ */
final Runnable mapReader = new Runnable() {
public void run() {
try {
@@ -249,6 +255,10 @@
}
};
+ /**
+ * Periodic task for reading the Flow Paths and recomputing the
+ * shortest paths.
+ */
final Runnable shortestPathReconcile = new Runnable() {
public void run() {
try {
@@ -414,27 +424,38 @@
}
};
- //final ScheduledFuture<?> mapReaderHandle =
- //mapReaderScheduler.scheduleAtFixedRate(mapReader, 3, 3, TimeUnit.SECONDS);
- //final ScheduledFuture<?> shortestPathReconcileHandle =
- //shortestPathReconcileScheduler.scheduleAtFixedRate(shortestPathReconcile, 3, 3, TimeUnit.SECONDS);
-
+ /**
+ * Initialize the Flow Manager.
+ *
+ * @param conf the Graph Database configuration string.
+ */
@Override
public void init(String conf) {
op = new GraphDBOperation(conf);
topoRouteService = new TopoRouteService(conf);
}
+ /**
+ * Shutdown the Flow Manager operation.
+ */
public void finalize() {
close();
}
+ /**
+ * Shutdown the Flow Manager operation.
+ */
@Override
public void close() {
op.close();
}
+ /**
+ * Get the collection of offered module services.
+ *
+ * @return the collection of offered module services.
+ */
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Collection<Class<? extends IFloodlightService>> l =
@@ -443,6 +464,11 @@
return l;
}
+ /**
+ * Get the collection of implemented services.
+ *
+ * @return the collection of implemented services.
+ */
@Override
public Map<Class<? extends IFloodlightService>, IFloodlightService>
getServiceImpls() {
@@ -454,6 +480,11 @@
return m;
}
+ /**
+ * Get the collection of modules this module depends on.
+ *
+ * @return the collection of modules this module depends on.
+ */
@Override
public Collection<Class<? extends IFloodlightService>>
getModuleDependencies() {
@@ -464,6 +495,11 @@
return l;
}
+ /**
+ * Initialize the module.
+ *
+ * @param context the module context to use for the initialization.
+ */
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
@@ -478,10 +514,15 @@
String conf = "/tmp/cassandra.titan";
this.init(conf);
- mapReaderScheduler = Executors.newScheduledThreadPool(1);
- shortestPathReconcileScheduler = Executors.newScheduledThreadPool(1);
+ mapReaderScheduler = Executors.newScheduledThreadPool(1);
+ shortestPathReconcileScheduler = Executors.newScheduledThreadPool(1);
}
+ /**
+ * Get the next Flow Entry ID to use.
+ *
+ * @return the next Flow Entry ID to use.
+ */
private synchronized long getNextFlowEntryId() {
//
// Generate the next Flow Entry ID.
@@ -500,17 +541,22 @@
return result;
}
+ /**
+ * Startup module operation.
+ *
+ * @param context the module context to use for the startup.
+ */
@Override
public void startUp(FloodlightModuleContext context) {
- restApi.addRestletRoutable(new FlowWebRoutable());
+ restApi.addRestletRoutable(new FlowWebRoutable());
- // Initialize the Flow Entry ID generator
- nextFlowEntryIdPrefix = randomGenerator.nextInt();
+ // Initialize the Flow Entry ID generator
+ nextFlowEntryIdPrefix = randomGenerator.nextInt();
- mapReaderScheduler.scheduleAtFixedRate(
- mapReader, 3, 3, TimeUnit.SECONDS);
- shortestPathReconcileScheduler.scheduleAtFixedRate(
- shortestPathReconcile, 3, 3, TimeUnit.SECONDS);
+ mapReaderScheduler.scheduleAtFixedRate(
+ mapReader, 3, 3, TimeUnit.SECONDS);
+ shortestPathReconcileScheduler.scheduleAtFixedRate(
+ shortestPathReconcile, 3, 3, TimeUnit.SECONDS);
}
/**
@@ -747,8 +793,7 @@
// - flowEntry.actionOutputPort()
// - flowEntry.actions()
//
- ISwitchObject sw =
- op.searchSwitch(flowEntry.dpid().toString());
+ ISwitchObject sw = op.searchSwitch(flowEntry.dpid().toString());
flowEntryObj.setSwitchDpid(flowEntry.dpid().toString());
flowEntryObj.setSwitch(sw);
if (flowEntry.flowEntryMatch().matchInPort()) {
@@ -1164,21 +1209,22 @@
}
/**
- * Get summary of all installed flows by all installers in a given range
+ * Get summary of all installed flows by all installers in a given range.
*
- * @param flowId the data path endpoints of the flows to get.
- * @param maxFlows: the maximum number of flows to be returned
+ * @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.
*/
@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.
- // We should use the appropriate Titan/Gremlin query to filter-out
- // the flows as appropriate.
- //
+ //
+ // 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 = new ArrayList<FlowPath>();
ArrayList<IFlowPath> flowPathsWithoutFlowEntries = getAllFlowsWithoutFlowEntries();
@@ -1278,8 +1324,13 @@
return flowPaths;
}
-
- public ArrayList<IFlowPath> getAllFlowsWithoutFlowEntries(){
+
+ /**
+ * Get all Flows information, without the associated Flow Entries.
+ *
+ * @return all Flows information, without the associated Flow Entries.
+ */
+ public ArrayList<IFlowPath> getAllFlowsWithoutFlowEntries() {
Iterable<IFlowPath> flowPathsObj = null;
ArrayList<IFlowPath> flowPathsObjArray = new ArrayList<IFlowPath>();
ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
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
index 2800305..0f13fe8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
@@ -14,10 +14,23 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Add a Flow with the Flow
+ * Entries:
+ *
+ * POST /wm/flow/add/json
+ */
public class AddFlowResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(AddFlowResource.class);
+ /**
+ * Implement the API.
+ *
+ * @param flowJson a string with the JSON representation of the Flow to
+ * add.
+ * @return the Flow ID of the added flow.
+ */
@Post("json")
public FlowId store(String flowJson) {
FlowId result = new FlowId();
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
index 2a75c6a..9340fda 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddShortestPathFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddShortestPathFlowResource.java
@@ -14,10 +14,23 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Add a Flow by delegating
+ * the Shortest Path computation to ONOS:
+ *
+ * POST /wm/flow/add-shortest-path/json
+ */
public class AddShortestPathFlowResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(AddShortestPathFlowResource.class);
+ /**
+ * Implement the API.
+ *
+ * @param flowJson a string with the JSON representation of the Flow to
+ * add.
+ * @return the Flow ID of the added flow.
+ */
@Post("json")
public FlowId store(String flowJson) {
FlowId result = new FlowId();
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
index 1daa2ab..c9e1816 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/ClearFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/ClearFlowResource.java
@@ -8,9 +8,22 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Clear internal Flow state.
+ *
+ * The "{flow-id}" request attribute value can be either a specific Flow ID,
+ * or the keyword "all" to clear all Flows:
+ *
+ * GET /wm/flow/clear/{flow-id}/json
+ */
public class ClearFlowResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(ClearFlowResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return true on success, otehrwise false.
+ */
@Get("json")
public Boolean retrieve() {
Boolean result = false;
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
index 393ff44..9c0673e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
@@ -8,9 +8,22 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Delete Flow state.
+ *
+ * The "{flow-id}" request attribute value can be either a specific Flow ID,
+ * or the keyword "all" to delete all Flows:
+ *
+ * GET /wm/flow/delete/{flow-id}/json
+ */
public class DeleteFlowResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(DeleteFlowResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return true on success, otehrwise false.
+ */
@Get("json")
public Boolean retrieve() {
Boolean result = false;
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
index e1c6da9..2c91716 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/FlowWebRoutable.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/FlowWebRoutable.java
@@ -6,6 +6,9 @@
import org.restlet.Restlet;
import org.restlet.routing.Router;
+/**
+ * @short REST API implementation for the Flow Manager.
+ */
public class FlowWebRoutable implements RestletRoutable {
/**
* Create the Restlet router and bind to the proper resources.
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
index 6142096..3d06efe 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByEndpointsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByEndpointsResource.java
@@ -14,9 +14,29 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Get all Flow state for given
+ * source and destination switches and ports.
+ *
+ * The "{src-dpid}" request attribute value is the source DPID of the flows to
+ * get.
+ * The "{src-port}" request attribute value is the source port of the flows to
+ * get.
+ * The "{dst-dpid}" request attribute value is the destination DPID of the
+ * flows to get.
+ * The "{dst-port}" request attribute value is the destination port of the
+ * flows to get.
+ *
+ * GET /wm/flow/getall-by-endpoints/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json"
+ */
public class GetAllFlowsByEndpointsResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(GetAllFlowsByEndpointsResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return the collection of Flow states if any found, otherwise null.
+ */
@Get("json")
public ArrayList<FlowPath> retrieve() {
ArrayList<FlowPath> result = null;
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
index 498108f..03999b0 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByInstallerIdResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsByInstallerIdResource.java
@@ -15,9 +15,31 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Get all Flow state for a given
+ * Installer ID and given source and destination switches and ports.
+ *
+ * The "{installer-id}" request attribute value is the Installer ID of the
+ * flows to get.
+ * The "{src-dpid}" request attribute value is the source DPID of the flows to
+ * get.
+ * The "{src-port}" request attribute value is the source port of the flows to
+ * get.
+ * The "{dst-dpid}" request attribute value is the destination DPID of the
+ * flows to get.
+ * The "{dst-port}" request attribute value is the destination port of the
+ * flows to get.
+ *
+ * GET /wm/flow/getall-by-installer-id/{installer-id}/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json"
+ */
public class GetAllFlowsByInstallerIdResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(GetAllFlowsByInstallerIdResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return the collection of Flow states if any found, otherwise null.
+ */
@Get("json")
public ArrayList<FlowPath> retrieve() {
ArrayList<FlowPath> result = null;
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
index 61eaf27..bac5618 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetAllFlowsResource.java
@@ -10,9 +10,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Get all Flow state.
+ *
+ * GET /wm/flow/getall/json"
+ */
public class GetAllFlowsResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(GetAllFlowsResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return the collection of Flow states if any found, otherwise null.
+ */
@Get("json")
public ArrayList<FlowPath> retrieve() {
ArrayList<FlowPath> result = null;
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
index 48e7369..d2ccd39 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
@@ -9,9 +9,21 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Get a single Flow state.
+ *
+ * The "{flow-id}" request attribute value is the Flow ID of the flow to get:
+ *
+ * GET /wm/flow/get/{flow-id}/json
+ */
public class GetFlowByIdResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(GetFlowByIdResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return the Flow state if the flow is found, otherwise null.
+ */
@Get("json")
public FlowPath retrieve() {
FlowPath result = null;
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
index 4b3c00f..5e82765 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
@@ -11,9 +11,25 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @short Flow Manager REST API implementation: Get summary of all installed
+ * flows by all installers in a given range.
+ *
+ * The "{flow-id}" request attribute value is the Flow ID of the flow in the
+ * flow range to get.
+ * The "{max-flows}" request attribute value is the maximum number of flows
+ * to be returned.
+ *
+ * GET /wm/flow/getsummary/{flow-id}/{max-flows}/json"
+ */
public class GetSummaryFlowsResource extends ServerResource {
protected static Logger log = LoggerFactory.getLogger(GetSummaryFlowsResource.class);
+ /**
+ * Implement the API.
+ *
+ * @return the collection of Flow states if any found, otherwise null.
+ */
@Get("json")
public ArrayList<IFlowPath> retrieve() {
ArrayList<IFlowPath> result = null;