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