Cherry-pick from https://gerrit.onos.onlab.us/#/c/339/

Cherry-pick from https://gerrit.onos.onlab.us/#/c/67

Implemented bypassing function to FlowPusher so that FlowSynchronizer can
push flows while queue is suspended (ONOS-967).

In this commit I modified FlowPusher to have two (or more, in future)
queues to prioritize messages.
High priority queue is for flow synchronization. This queue won't be
blocked even in SUSPENDED status.
Low priority queue is for normal OpenFlow message installation. This
queue works only in READY status, but blocked in SUSPENDED status.
Messages in high priority queue are always installed before messages in
low priority queue. In other words, messages in low priority queue are
installed only if high priority queue is empty.

Moved timing of FlowEntryAdded notification.

Change-Id: Ic7ee4ce002c1f6b50af4f160fbf98eb82658ee8b

Implemented bypassing function to FlowPusher.

Change-Id: Ia3ae86242ceed34257c58e9aaffcdd8f72534bf3

Fixed a bug FlowPusher#hasMessageToSend doesn't work with SUSPENDED status.

Conflicts:
        src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java

NOTE: The above conflict was resolved by hand.

Change-Id: I79446dced030ecd91a6e81333cb93c1c4b637914
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 6bf20d9..29a579e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
@@ -21,6 +21,18 @@
  *
  */
 public interface IFlowPusherService extends IFloodlightService {
+	public static enum MsgPriority {
+		HIGH,		// High priority: e.g. flow synchronization
+		NORMAL,		// Normal priority
+//		LOW,		// Low priority, not needed for now
+	}
+	
+    public static enum QueueState {
+		READY,		// Queues with all priority are at work
+		SUSPENDED,	// Only prior queue is at work
+		UNKNOWN
+	}
+
 	/**
 	 * Create a queue correspondent to the switch.
 	 * @param sw Switch to which new queue is attached.
@@ -49,7 +61,7 @@
 	boolean deleteQueue(IOFSwitch sw, boolean forceStop);
 	
 	/**
-	 * Add a message to the queue of the switch.
+	 * Add a message to the queue of the switch with normal priority.
 	 *
 	 * Note: Notification is NOT delivered for the pushed message.
 	 *
@@ -60,7 +72,18 @@
 	boolean add(IOFSwitch sw, OFMessage msg);
 
 	/**
-	 * Push a collection of Flow Entries to the corresponding switches.
+	 * Add a message to the queue of the switch with specific priority.
+	 *
+	 * @param sw Switch to which message is pushed.
+	 * @param msg Message object to be added.
+	 * @param priority Sending priority of the message.
+	 * @return true if message is successfully added to a queue.
+	 */
+	boolean add(IOFSwitch sw, OFMessage msg, MsgPriority priority);
+	
+	/**
+	 * Push a collection of Flow Entries to the corresponding switches
+	 * with normal priority.
 	 *
 	 * Note: Notification is delivered for the Flow Entries that
 	 * are pushed successfully.
@@ -71,8 +94,22 @@
 	void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries);
 
 	/**
+	 * Push a collection of Flow Entries to the corresponding switches
+	 * with specific priority.
+	 *
+	 * Note: Notification is delivered for the Flow Entries that
+	 * are pushed successfully.
+	 *
+	 * @param entries the collection of <IOFSwitch, FlowEntry> pairs
+	 * to push.
+	 * @param priority Sending priority of flow entries.
+	 */
+	void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries,
+			MsgPriority priority);
+	
+	/**
 	 * Create a message from FlowEntry and add it to the queue of the
-	 * switch.
+	 * switch with normal priority.
 	 *
 	 * Note: Notification is delivered for the Flow Entries that
 	 * are pushed successfully.
@@ -84,6 +121,20 @@
 	void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry);
 
 	/**
+	 * Create a message from FlowEntry and add it to the queue of the
+	 * switch with specific priority.
+	 *
+	 * 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.
+	 */
+	void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry,
+			MsgPriority priority);
+	
+	/**
 	 * Set sending rate to a switch.
 	 * @param sw Switch.
 	 * @param rate Rate in bytes/ms.
@@ -119,9 +170,9 @@
 	boolean resume(IOFSwitch sw);
 	
 	/**
-	 * Get whether pushing of message is suspended or not.
+	 * Get state of queue attached to a switch.
 	 * @param sw Switch to be checked.
-	 * @return true if suspended.
+	 * @return State of queue.
 	 */
-	boolean isSuspended(IOFSwitch sw);
+	QueueState getState(IOFSwitch sw);
 }