* Added new method FlowDatabaseOperation.getFlowSourceDpid() that
can be used to get the Source Switch DPID
* Added a boolean flag to FlowEventHandler and FlowManager to enable/disable
the new Flow setup mechanism:
enableOnrc2014MeasurementsFlows
* Create locally the FlowEventHandler.dbHandler instead of
reusing the dbHandler from the FlowManager.
Reusing the dbHandler from the FlowManager might not be thread-safe (??)
* Renamed flag FlowEventHandler.accessDBFlag
to enableOnrc2014MeasurementsTopology
(for consistency with the Flow setup-related flag)
* Changed the logic when reading the complete topology from the database:
if there is a topology-related event, we unconditionally assume
the topology has been modified. Long-term this might be sub-optimal,
but gives us the bare-bones behavior we want to measure.
* Reverse the change to Topology.readFromDatabase() to exclude the
compareTopology() call (see above bullet).
* Fix a bug when cheching whether there is any event to process.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index e075bad..2cbadd6 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -464,6 +464,45 @@
}
/**
+ * Get the source switch DPID of a previously added flow.
+ *
+ * @param dbHandler the Graph Database handler to use.
+ * @param flowId the Flow ID of the flow to get.
+ * @return the source switch DPID if found, otherwise null.
+ */
+ static Dpid getFlowSourceDpid(GraphDBOperation dbHandler, FlowId flowId) {
+ IFlowPath flowObj = null;
+ try {
+ flowObj = dbHandler.searchFlowPath(flowId);
+ } catch (Exception e) {
+ // TODO: handle exceptions
+ dbHandler.rollback();
+ log.error(":getFlowSourceDpid FlowId:{} failed", flowId);
+ return null;
+ }
+ if (flowObj == null) {
+ dbHandler.commit();
+ return null; // Flow not found
+ }
+
+ //
+ // Extract the Flow Source DPID
+ //
+ String srcSwitchStr = flowObj.getSrcSwitch();
+ if (srcSwitchStr == null) {
+ // TODO: A work-around, becauuse of some bogus database objects
+ dbHandler.commit();
+ return null;
+ }
+
+ Dpid dpid = new Dpid(srcSwitchStr);
+
+ dbHandler.commit();
+
+ return dpid;
+ }
+
+ /**
* Get all installed flows by all installers.
*
* @param dbHandler the Graph Database handler to use.