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 { |
| 24 | /** |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 25 | * Create a queue correspondent to the switch. |
| 26 | * @param sw Switch to which new queue is attached. |
| 27 | * @return true if new queue is successfully created. |
| 28 | */ |
| 29 | boolean createQueue(IOFSwitch sw); |
| 30 | |
| 31 | /** |
| 32 | * Delete a queue correspondent to the switch. |
| 33 | * Messages remains in queue will be all sent before queue is deleted. |
| 34 | * @param sw Switch of which queue is deleted. |
| 35 | * @return true if queue is successfully deleted. |
| 36 | */ |
| 37 | boolean deleteQueue(IOFSwitch sw); |
| 38 | |
| 39 | /** |
| 40 | * Delete a queue correspondent to the switch. |
| 41 | * By setting force flag on, queue will be deleted immediately. |
| 42 | * @param sw Switch of which queue is deleted. |
Naoki Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 43 | * @param forceStop If this flag is set to true, queue will be deleted |
| 44 | * immediately regardless of any messages in the queue. |
| 45 | * If false, all messages will be sent to switch and queue will |
| 46 | * be deleted after that. |
| 47 | * @return true if queue is successfully deleted or flagged to be deleted. |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 48 | */ |
Naoki Shiota | b485d41 | 2013-11-26 12:04:19 -0800 | [diff] [blame] | 49 | boolean deleteQueue(IOFSwitch sw, boolean forceStop); |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 50 | |
| 51 | /** |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 52 | * Add a message to the queue of the switch. |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 53 | * |
| 54 | * Note: Notification is NOT delivered for the pushed message. |
| 55 | * |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 56 | * @param sw Switch to which message is pushed. |
| 57 | * @param msg Message object to be added. |
| 58 | * @return true if message is successfully added to a queue. |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 59 | */ |
Brian O'Connor | 8c166a7 | 2013-11-14 18:41:48 -0800 | [diff] [blame] | 60 | boolean add(IOFSwitch sw, OFMessage msg); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 61 | |
| 62 | /** |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 63 | * Push a collection of Flow Entries to the corresponding switches. |
| 64 | * |
| 65 | * Note: Notification is delivered for the Flow Entries that |
| 66 | * are pushed successfully. |
| 67 | * |
| 68 | * @param entries the collection of <IOFSwitch, FlowEntry> pairs |
| 69 | * to push. |
| 70 | */ |
| 71 | void pushFlowEntries(Collection<Pair<IOFSwitch, FlowEntry>> entries); |
| 72 | |
| 73 | /** |
| 74 | * Create a message from FlowEntry and add it to the queue of the |
| 75 | * switch. |
| 76 | * |
| 77 | * Note: Notification is delivered for the Flow Entries that |
| 78 | * are pushed successfully. |
| 79 | * |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 80 | * @param sw Switch to which message is pushed. |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 81 | * @param flowEntry FlowEntry object used for creating message. |
| 82 | * @return true if message is successfully added to a queue. |
| 83 | */ |
Pavlin Radoslavov | ab3f886 | 2013-12-04 18:35:53 -0800 | [diff] [blame] | 84 | void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry); |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 85 | |
| 86 | /** |
Naoki Shiota | e319973 | 2013-11-25 16:14:43 -0800 | [diff] [blame] | 87 | * Set sending rate to a switch. |
| 88 | * @param sw Switch. |
| 89 | * @param rate Rate in bytes/ms. |
| 90 | */ |
| 91 | public void setRate(IOFSwitch sw, long rate); |
| 92 | |
| 93 | /** |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 94 | * Add BARRIER message to queue and wait for reply. |
| 95 | * @param sw Switch to which barrier message is pushed. |
| 96 | * @return BARRIER_REPLY message sent from switch. |
| 97 | */ |
| 98 | OFBarrierReply barrier(IOFSwitch sw); |
| 99 | |
| 100 | /** |
| 101 | * Add BARRIER message to queue asynchronously. |
| 102 | * @param sw Switch to which barrier message is pushed. |
| 103 | * @return Future object of BARRIER_REPLY message which will be sent from switch. |
| 104 | */ |
| 105 | OFMessageFuture<OFBarrierReply> barrierAsync(IOFSwitch sw); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Suspend pushing message to a switch. |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 109 | * @param sw Switch to be suspended pushing message. |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 110 | * @return true if success |
| 111 | */ |
Brian O'Connor | 8c166a7 | 2013-11-14 18:41:48 -0800 | [diff] [blame] | 112 | boolean suspend(IOFSwitch sw); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Resume pushing message to a switch. |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 116 | * @param sw Switch to be resumed pushing message. |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 117 | * @return true if success |
| 118 | */ |
Brian O'Connor | 8c166a7 | 2013-11-14 18:41:48 -0800 | [diff] [blame] | 119 | boolean resume(IOFSwitch sw); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Get whether pushing of message is suspended or not. |
Naoki Shiota | c1601d3 | 2013-11-20 10:47:34 -0800 | [diff] [blame] | 123 | * @param sw Switch to be checked. |
| 124 | * @return true if suspended. |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 125 | */ |
Brian O'Connor | 8c166a7 | 2013-11-14 18:41:48 -0800 | [diff] [blame] | 126 | boolean isSuspended(IOFSwitch sw); |
Naoki Shiota | 8ee48d5 | 2013-11-11 15:51:17 -0800 | [diff] [blame] | 127 | } |