blob: 66584951897f4217febf02c9123b281a90bfda02 [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.
Naoki Shiotab485d412013-11-26 12:04:19 -080020 *
Ray Milkey8e5170e2014-04-02 12:09:55 -070021 * @author Naoki Shiota
Naoki Shiotab485d412013-11-26 12:04:19 -080022 */
Naoki Shiota8ee48d52013-11-11 15:51:17 -080023public interface IFlowPusherService extends IFloodlightService {
Ray Milkey8e5170e2014-04-02 12:09:55 -070024 public static enum MsgPriority {
25 HIGH, // High priority: e.g. flow synchronization
26 NORMAL, // Normal priority
Naoki Shiota8df97bc2014-03-13 18:42:23 -070027// LOW, // Low priority, not needed for now
Ray Milkey8e5170e2014-04-02 12:09:55 -070028 }
29
Naoki Shiota8df97bc2014-03-13 18:42:23 -070030 public static enum QueueState {
Ray Milkey8e5170e2014-04-02 12:09:55 -070031 READY, // Queues with all priority are at work
32 SUSPENDED, // Only prior queue is at work
33 UNKNOWN
34 }
Naoki Shiota8df97bc2014-03-13 18:42:23 -070035
Ray Milkey8e5170e2014-04-02 12:09:55 -070036 /**
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 Shiotae3199732013-11-25 16:14:43 -080043
Ray Milkey8e5170e2014-04-02 12:09:55 -070044 /**
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 Shiotac1601d32013-11-20 10:47:34 -080052
Ray Milkey8e5170e2014-04-02 12:09:55 -070053 /**
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 Radoslavovab3f8862013-12-04 18:35:53 -080065
Ray Milkey8e5170e2014-04-02 12:09:55 -070066 /**
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 Shiotac1601d32013-11-20 10:47:34 -080076
Ray Milkey8e5170e2014-04-02 12:09:55 -070077 /**
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 Shiota8ee48d52013-11-11 15:51:17 -0800187}