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/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
index 792511c..853591a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
@@ -3,9 +3,11 @@
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,6 +38,7 @@
import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
import net.onrc.onos.ofcontroller.util.FlowEntryUserState;
import net.onrc.onos.ofcontroller.util.IPv4Net;
+import net.onrc.onos.ofcontroller.util.Pair;
import net.onrc.onos.ofcontroller.util.Port;
/**
@@ -446,9 +449,46 @@
return true;
}
-
+
@Override
- public boolean add(IOFSwitch sw, FlowEntry flowEntry) {
+ public void pushFlowEntries(
+ Collection<Pair<IOFSwitch, FlowEntry>> entries) {
+
+ List<Pair<IOFSwitch, FlowEntry>> pushedEntries =
+ new LinkedList<Pair<IOFSwitch, FlowEntry>>();
+
+ for (Pair<IOFSwitch, FlowEntry> entry : entries) {
+ if (add(entry.left, entry.right)) {
+ pushedEntries.add(entry);
+ }
+ }
+
+ //
+ // TODO: We should use the OpenFlow Barrier mechanism
+ // to check for errors, and update the SwitchState
+ // for a flow entry after the Barrier message is
+ // is received.
+ // Only after inform the Flow Manager that the entry is pushed.
+ //
+ flowManager.flowEntriesPushedToSwitch(pushedEntries);
+ }
+
+ @Override
+ public void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry) {
+ Collection<Pair<IOFSwitch, FlowEntry>> entries =
+ new LinkedList<Pair<IOFSwitch, FlowEntry>>();
+
+ entries.add(new Pair<IOFSwitch, FlowEntry>(sw, flowEntry));
+ pushFlowEntries(entries);
+ }
+
+ /**
+ * Create a message from FlowEntry and add it to the queue of the switch.
+ * @param sw Switch to which message is pushed.
+ * @param flowEntry FlowEntry object used for creating message.
+ * @return true if message is successfully added to a queue.
+ */
+ private boolean add(IOFSwitch sw, FlowEntry flowEntry) {
//
// Create the OpenFlow Flow Modification Entry to push
//
@@ -712,19 +752,7 @@
+ matchSrcMac + " dstMac: " + matchDstMac + " inPort: "
+ matchInPort + " outPort: " + actionOutputPort);
- if (add(sw, fm) != true)
- return false;
-
- //
- // TODO: We should use the OpenFlow Barrier mechanism
- // to check for errors, and update the SwitchState
- // for a flow entry after the Barrier message is
- // is received.
- // Only after inform the Flow Manager that the entry is pushed.
- //
- flowManager.flowEntryPushedToSwitch(sw, flowEntry);
-
- return true;
+ return add(sw, fm);
}
@Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
index c357e7c..7d5527b 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -246,7 +246,7 @@
return;
}
- pusher.add(sw, flowEntry);
+ pusher.pushFlowEntry(sw, flowEntry);
}
/**
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
index 2f550a7..6bf20d9 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
@@ -1,5 +1,7 @@
package net.onrc.onos.ofcontroller.flowprogrammer;
+import java.util.Collection;
+
import org.openflow.protocol.OFBarrierReply;
import org.openflow.protocol.OFMessage;
@@ -7,6 +9,7 @@
import net.floodlightcontroller.core.internal.OFMessageFuture;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.Pair;
/**
* FlowPusherService is a service to send message to switches in proper rate.
@@ -47,6 +50,9 @@
/**
* Add a message to the queue of the switch.
+ *
+ * Note: Notification is NOT delivered for the pushed message.
+ *
* @param sw Switch to which message is pushed.
* @param msg Message object to be added.
* @return true if message is successfully added to a queue.
@@ -54,12 +60,28 @@
boolean add(IOFSwitch sw, OFMessage msg);
/**
- * Create a message from FlowEntry and add it to the queue of the switch.
+ * Push a collection of Flow Entries to the corresponding switches.
+ *
+ * Note: Notification is delivered for the Flow Entries that
+ * are pushed successfully.
+ *
+ * @param entries the collection of <IOFSwitch, FlowEntry> pairs
+ * to push.
+ */
+ void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries);
+
+ /**
+ * Create a message from FlowEntry and add it to the queue of the
+ * switch.
+ *
+ * Note: Notification is delivered for the Flow Entries that
+ * are pushed successfully.
+ *
* @param sw Switch to which message is pushed.
* @param flowEntry FlowEntry object used for creating message.
* @return true if message is successfully added to a queue.
*/
- boolean add(IOFSwitch sw, FlowEntry flowEntry);
+ void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry);
/**
* Set sending rate to a switch.