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