Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowprogrammer; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 3 | import java.util.Collection; |
| 4 | |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 5 | import net.floodlightcontroller.core.IOFSwitch; |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 6 | import net.floodlightcontroller.core.internal.OFMessageFuture; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 7 | import net.floodlightcontroller.core.module.IFloodlightService; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 8 | import net.onrc.onos.core.util.FlowEntry; |
| 9 | import net.onrc.onos.core.util.Pair; |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 10 | |
Jonathan Hart | a99ec67 | 2014-04-03 11:30:34 -0700 | [diff] [blame] | 11 | import org.openflow.protocol.OFBarrierReply; |
| 12 | import org.openflow.protocol.OFMessage; |
| 13 | |
Naoki Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 14 | /** |
| 15 | * FlowPusherService is a service to send message to switches in proper rate. |
| 16 | * Conceptually a queue is attached to each switch, and FlowPusherService |
| 17 | * read a message from queue and send it to switch in order. |
| 18 | * To guarantee message has been installed, FlowPusherService can add barrier |
| 19 | * message to queue and can notify when barrier message is sent to switch. |
Naoki Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 20 | */ |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 21 | public interface IFlowPusherService extends IFloodlightService { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 22 | public static enum MsgPriority { |
| 23 | HIGH, // High priority: e.g. flow synchronization |
| 24 | NORMAL, // Normal priority |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 25 | // LOW, // Low priority, not needed for now |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 26 | } |
| 27 | |
Naoki Shiota | 8df97bc | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 28 | public static enum QueueState { |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 29 | READY, // Queues with all priority are at work |
| 30 | SUSPENDED, // Only prior queue is at work |
| 31 | UNKNOWN |
| 32 | } |
Naoki Shiota | 8df97bc | 2014-03-13 18:42:23 -0700 | [diff] [blame] | 33 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 34 | /** |
| 35 | * Create a queue correspondent to the switch. |
| 36 | * |
| 37 | * @param sw Switch to which new queue is attached. |
| 38 | * @return true if new queue is successfully created. |
| 39 | */ |
| 40 | boolean createQueue(IOFSwitch sw); |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 41 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 42 | /** |
| 43 | * Delete a queue correspondent to the switch. |
| 44 | * Messages remains in queue will be all sent before queue is deleted. |
| 45 | * |
| 46 | * @param sw Switch of which queue is deleted. |
| 47 | * @return true if queue is successfully deleted. |
| 48 | */ |
| 49 | boolean deleteQueue(IOFSwitch sw); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 50 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 51 | /** |
| 52 | * Delete a queue correspondent to the switch. |
| 53 | * By setting force flag on, queue will be deleted immediately. |
| 54 | * |
| 55 | * @param sw Switch of which queue is deleted. |
| 56 | * @param forceStop If this flag is set to true, queue will be deleted |
| 57 | * immediately regardless of any messages in the queue. |
| 58 | * If false, all messages will be sent to switch and queue will |
| 59 | * be deleted after that. |
| 60 | * @return true if queue is successfully deleted or flagged to be deleted. |
| 61 | */ |
| 62 | boolean deleteQueue(IOFSwitch sw, boolean forceStop); |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 63 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Add a message to the queue of the switch with normal priority. |
| 66 | * <p/> |
| 67 | * Note: Notification is NOT delivered for the pushed message. |
| 68 | * |
| 69 | * @param sw Switch to which message is pushed. |
| 70 | * @param msg Message object to be added. |
| 71 | * @return true if message is successfully added to a queue. |
| 72 | */ |
| 73 | boolean add(IOFSwitch sw, OFMessage msg); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 74 | |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 75 | /** |
| 76 | * Add a message to the queue of the switch with specific priority. |
| 77 | * |
| 78 | * @param sw Switch to which message is pushed. |
| 79 | * @param msg Message object to be added. |
| 80 | * @param priority Sending priority of the message. |
| 81 | * @return true if message is successfully added to a queue. |
| 82 | */ |
| 83 | boolean add(IOFSwitch sw, OFMessage msg, MsgPriority priority); |
| 84 | |
| 85 | /** |
| 86 | * Push a collection of Flow Entries to the corresponding switches |
| 87 | * with normal priority. |
| 88 | * <p/> |
| 89 | * Note: Notification is delivered for the Flow Entries that |
| 90 | * are pushed successfully. |
| 91 | * |
| 92 | * @param entries the collection of <IOFSwitch, FlowEntry> pairs |
| 93 | * to push. |
| 94 | */ |
| 95 | void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries); |
| 96 | |
| 97 | /** |
| 98 | * Push a collection of Flow Entries to the corresponding switches |
| 99 | * with specific priority. |
| 100 | * <p/> |
| 101 | * Note: Notification is delivered for the Flow Entries that |
| 102 | * are pushed successfully. |
| 103 | * |
| 104 | * @param entries the collection of <IOFSwitch, FlowEntry> pairs |
| 105 | * to push. |
| 106 | * @param priority Sending priority of flow entries. |
| 107 | */ |
| 108 | void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries, |
| 109 | MsgPriority priority); |
| 110 | |
| 111 | /** |
| 112 | * Create a message from FlowEntry and add it to the queue of the |
| 113 | * switch with normal priority. |
| 114 | * <p/> |
| 115 | * Note: Notification is delivered for the Flow Entries that |
| 116 | * are pushed successfully. |
| 117 | * |
| 118 | * @param sw Switch to which message is pushed. |
| 119 | * @param flowEntry FlowEntry object used for creating message. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 120 | */ |
| 121 | void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry); |
| 122 | |
| 123 | /** |
| 124 | * Create a message from FlowEntry and add it to the queue of the |
| 125 | * switch with specific priority. |
| 126 | * <p/> |
| 127 | * Note: Notification is delivered for the Flow Entries that |
| 128 | * are pushed successfully. |
| 129 | * |
| 130 | * @param sw Switch to which message is pushed. |
| 131 | * @param flowEntry FlowEntry object used for creating message. |
Ray Milkey | 8e5170e | 2014-04-02 12:09:55 -0700 | [diff] [blame] | 132 | */ |
| 133 | void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry, |
| 134 | MsgPriority priority); |
| 135 | |
| 136 | /** |
| 137 | * Set sending rate to a switch. |
| 138 | * |
| 139 | * @param sw Switch. |
| 140 | * @param rate Rate in bytes/ms. |
| 141 | */ |
| 142 | public void setRate(IOFSwitch sw, long rate); |
| 143 | |
| 144 | /** |
| 145 | * Add BARRIER message to queue and wait for reply. |
| 146 | * |
| 147 | * @param sw Switch to which barrier message is pushed. |
| 148 | * @return BARRIER_REPLY message sent from switch. |
| 149 | */ |
| 150 | OFBarrierReply barrier(IOFSwitch sw); |
| 151 | |
| 152 | /** |
| 153 | * Add BARRIER message to queue asynchronously. |
| 154 | * |
| 155 | * @param sw Switch to which barrier message is pushed. |
| 156 | * @return Future object of BARRIER_REPLY message which will be sent from switch. |
| 157 | */ |
| 158 | OFMessageFuture<OFBarrierReply> barrierAsync(IOFSwitch sw); |
| 159 | |
| 160 | /** |
| 161 | * Suspend pushing message to a switch. |
| 162 | * |
| 163 | * @param sw Switch to be suspended pushing message. |
| 164 | * @return true if success |
| 165 | */ |
| 166 | boolean suspend(IOFSwitch sw); |
| 167 | |
| 168 | /** |
| 169 | * Resume pushing message to a switch. |
| 170 | * |
| 171 | * @param sw Switch to be resumed pushing message. |
| 172 | * @return true if success |
| 173 | */ |
| 174 | boolean resume(IOFSwitch sw); |
| 175 | |
| 176 | /** |
| 177 | * Get state of queue attached to a switch. |
| 178 | * |
| 179 | * @param sw Switch to be checked. |
| 180 | * @return State of queue. |
| 181 | */ |
| 182 | QueueState getState(IOFSwitch sw); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 183 | } |