Refactoring of the API between the Flow Manager and the FlowPusher.
Now the Flow Manager can push a collection of Flow Entries to the FlowPusher.
Similarly, the Flow Pusher itself can inform the Flow Manager that a collection
of Flow Entries have been pushed successfully.
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 dcd683d..0bced44 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -4,6 +4,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
@@ -402,30 +403,41 @@
}
/**
- * Inform the Flow Manager that a Flow Entry has been pushed to a switch.
+ * Inform the Flow Manager that a collection of Flow Entries have been
+ * pushed to a switch.
*
- * @param sw the switch the Flow Entry has been pushed to.
- * @param flowEntry the Flow Entry that has been pushed.
+ * @param entries the collection of <IOFSwitch, FlowEntry> pairs
+ * that have been pushed.
*/
- public void flowEntryPushedToSwitch(IOFSwitch sw, FlowEntry flowEntry) {
- //
- // Mark the Flow Entry that it has been pushed to the switch
- //
- flowEntry.setFlowEntrySwitchState(FlowEntrySwitchState.FE_SWITCH_UPDATED);
+ public void flowEntriesPushedToSwitch(
+ Collection<Pair<IOFSwitch, FlowEntry>> entries) {
//
- // Write the Flow Entry to the Datagrid
+ // Process all entries
//
- switch (flowEntry.flowEntryUserState()) {
- case FE_USER_ADD:
- datagridService.notificationSendFlowEntryAdded(flowEntry);
- break;
- case FE_USER_MODIFY:
- datagridService.notificationSendFlowEntryUpdated(flowEntry);
- break;
- case FE_USER_DELETE:
- datagridService.notificationSendFlowEntryRemoved(flowEntry.flowEntryId());
- break;
+ for (Pair<IOFSwitch, FlowEntry> entry : entries) {
+ IOFSwitch sw = entry.left;
+ FlowEntry flowEntry = entry.right;
+
+ //
+ // Mark the Flow Entry that it has been pushed to the switch
+ //
+ flowEntry.setFlowEntrySwitchState(FlowEntrySwitchState.FE_SWITCH_UPDATED);
+
+ //
+ // Write the Flow Entry to the Datagrid
+ //
+ switch (flowEntry.flowEntryUserState()) {
+ case FE_USER_ADD:
+ datagridService.notificationSendFlowEntryAdded(flowEntry);
+ break;
+ case FE_USER_MODIFY:
+ datagridService.notificationSendFlowEntryUpdated(flowEntry);
+ break;
+ case FE_USER_DELETE:
+ datagridService.notificationSendFlowEntryRemoved(flowEntry.flowEntryId());
+ break;
+ }
}
}
@@ -460,27 +472,24 @@
if (modifiedFlowEntries.isEmpty())
return;
+ List<Pair<IOFSwitch, FlowEntry>> entries =
+ new LinkedList<Pair<IOFSwitch, FlowEntry>>();
+
Map<Long, IOFSwitch> mySwitches = getMySwitches();
+ //
+ // Create a collection of my Flow Entries to push
+ //
for (FlowEntry flowEntry : modifiedFlowEntries) {
IOFSwitch mySwitch = mySwitches.get(flowEntry.dpid().value());
if (mySwitch == null)
continue;
log.debug("Pushing Flow Entry To Switch: {}", flowEntry.toString());
-
- //
- // Push the Flow Entry into the switch
- //
- if (! pusher.add(mySwitch, flowEntry)) {
- String logMsg = "Cannot install Flow Entry " +
- flowEntry.flowEntryId() +
- " from Flow Path " + flowEntry.flowId() +
- " on switch " + flowEntry.dpid();
- log.error(logMsg);
- continue;
- }
+ entries.add(new Pair<IOFSwitch, FlowEntry>(mySwitch, flowEntry));
}
+
+ pusher.pushFlowEntries(entries);
}
/**
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
index 6d6043e..3a8a947 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowService.java
@@ -1,6 +1,7 @@
package net.onrc.onos.ofcontroller.flowmanager;
import java.util.ArrayList;
+import java.util.Collection;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.module.IFloodlightService;
@@ -11,6 +12,7 @@
import net.onrc.onos.ofcontroller.util.FlowEntryId;
import net.onrc.onos.ofcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Pair;
/**
* Interface for providing Flow Service to other modules.
@@ -125,10 +127,12 @@
public void flowEntryOnSwitchExpired(IOFSwitch sw, FlowEntryId flowEntryId);
/**
- * Inform the Flow Manager that a Flow Entry has been pushed to a switch.
+ * Inform the Flow Manager that a collection of Flow Entries have been
+ * pushed to a switch.
*
- * @param sw the switch the Flow Entry has been pushed to.
- * @param flowEntry the Flow Entry that has been pushed.
+ * @param entries the collection of <IOFSwitch, FlowEntry> pairs
+ * that have been pushed.
*/
- void flowEntryPushedToSwitch(IOFSwitch sw, FlowEntry flowEntry);
+ public void flowEntriesPushedToSwitch(
+ Collection<Pair<IOFSwitch, FlowEntry>> entries);
}