blob: 6bf20d91cb891a2f354737a27dc0b22437609227 [file] [log] [blame]
Naoki Shiotaaea88582013-11-12 17:58:34 -08001package net.onrc.onos.ofcontroller.flowprogrammer;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08002
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -08003import java.util.Collection;
4
Naoki Shiotac1601d32013-11-20 10:47:34 -08005import org.openflow.protocol.OFBarrierReply;
6import org.openflow.protocol.OFMessage;
7
Naoki Shiota8ee48d52013-11-11 15:51:17 -08008import net.floodlightcontroller.core.IOFSwitch;
Naoki Shiotac1601d32013-11-20 10:47:34 -08009import net.floodlightcontroller.core.internal.OFMessageFuture;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080010import net.floodlightcontroller.core.module.IFloodlightService;
Brian O'Connor8c166a72013-11-14 18:41:48 -080011import net.onrc.onos.ofcontroller.util.FlowEntry;
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080012import net.onrc.onos.ofcontroller.util.Pair;
Naoki Shiota8ee48d52013-11-11 15:51:17 -080013
Naoki Shiotab485d412013-11-26 12:04:19 -080014/**
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 Shiota8ee48d52013-11-11 15:51:17 -080023public interface IFlowPusherService extends IFloodlightService {
24 /**
Naoki Shiotae3199732013-11-25 16:14:43 -080025 * 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 Shiotab485d412013-11-26 12:04:19 -080043 * @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 Shiotae3199732013-11-25 16:14:43 -080048 */
Naoki Shiotab485d412013-11-26 12:04:19 -080049 boolean deleteQueue(IOFSwitch sw, boolean forceStop);
Naoki Shiotae3199732013-11-25 16:14:43 -080050
51 /**
Naoki Shiotac1601d32013-11-20 10:47:34 -080052 * Add a message to the queue of the switch.
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080053 *
54 * Note: Notification is NOT delivered for the pushed message.
55 *
Naoki Shiotac1601d32013-11-20 10:47:34 -080056 * @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 Shiota8ee48d52013-11-11 15:51:17 -080059 */
Brian O'Connor8c166a72013-11-14 18:41:48 -080060 boolean add(IOFSwitch sw, OFMessage msg);
Naoki Shiotac1601d32013-11-20 10:47:34 -080061
62 /**
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080063 * 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 Shiotac1601d32013-11-20 10:47:34 -080080 * @param sw Switch to which message is pushed.
Naoki Shiotac1601d32013-11-20 10:47:34 -080081 * @param flowEntry FlowEntry object used for creating message.
82 * @return true if message is successfully added to a queue.
83 */
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080084 void pushFlowEntry(IOFSwitch sw, FlowEntry flowEntry);
Naoki Shiotac1601d32013-11-20 10:47:34 -080085
86 /**
Naoki Shiotae3199732013-11-25 16:14:43 -080087 * 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 Shiotac1601d32013-11-20 10:47:34 -080094 * 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 Shiota8ee48d52013-11-11 15:51:17 -0800106
107 /**
108 * Suspend pushing message to a switch.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800109 * @param sw Switch to be suspended pushing message.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800110 * @return true if success
111 */
Brian O'Connor8c166a72013-11-14 18:41:48 -0800112 boolean suspend(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800113
114 /**
115 * Resume pushing message to a switch.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800116 * @param sw Switch to be resumed pushing message.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800117 * @return true if success
118 */
Brian O'Connor8c166a72013-11-14 18:41:48 -0800119 boolean resume(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800120
121 /**
122 * Get whether pushing of message is suspended or not.
Naoki Shiotac1601d32013-11-20 10:47:34 -0800123 * @param sw Switch to be checked.
124 * @return true if suspended.
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800125 */
Brian O'Connor8c166a72013-11-14 18:41:48 -0800126 boolean isSuspended(IOFSwitch sw);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800127}