blob: 1026855daf1a1725651386f6c85be6f7bd839a3d [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.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 net.floodlightcontroller.core.internal.OFMessageFuture;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08006import net.floodlightcontroller.core.module.IFloodlightService;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -07007import net.onrc.onos.core.intent.FlowEntry;
Jonathan Hart5302b6c2014-08-13 15:57:59 -07008import net.onrc.onos.core.util.Dpid;
Naoki Shiota8ee48d52013-11-11 15:51:17 -08009
Pavlin Radoslavovb05aac92014-08-26 18:26:10 -070010import org.apache.commons.lang3.tuple.Pair;
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070011import org.projectfloodlight.openflow.protocol.OFBarrierReply;
12import org.projectfloodlight.openflow.protocol.OFMessage;
Jonathan Harta99ec672014-04-03 11:30:34 -070013
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 */
Naoki Shiota8ee48d52013-11-11 15:51:17 -080021public interface IFlowPusherService extends IFloodlightService {
Ray Milkey8e5170e2014-04-02 12:09:55 -070022 public static enum MsgPriority {
Jonathan Hart5302b6c2014-08-13 15:57:59 -070023 HIGH, // High priority: e.g. flow synchronization
Ray Milkey8e5170e2014-04-02 12:09:55 -070024 NORMAL, // Normal priority
Jonathan Hart5302b6c2014-08-13 15:57:59 -070025 // LOW, // Low priority, not needed for now
Ray Milkey8e5170e2014-04-02 12:09:55 -070026 }
27
Naoki Shiota8df97bc2014-03-13 18:42:23 -070028 public static enum QueueState {
Ray Milkey8e5170e2014-04-02 12:09:55 -070029 READY, // Queues with all priority are at work
30 SUSPENDED, // Only prior queue is at work
31 UNKNOWN
32 }
Naoki Shiota8df97bc2014-03-13 18:42:23 -070033
Ray Milkey8e5170e2014-04-02 12:09:55 -070034 /**
35 * Create a queue correspondent to the switch.
36 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070037 * @param dpid DPID of the switch to which new queue is attached.
Ray Milkey8e5170e2014-04-02 12:09:55 -070038 * @return true if new queue is successfully created.
39 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070040 boolean createQueue(Dpid dpid);
Naoki Shiotae3199732013-11-25 16:14:43 -080041
Ray Milkey8e5170e2014-04-02 12:09:55 -070042 /**
43 * Delete a queue correspondent to the switch.
44 * Messages remains in queue will be all sent before queue is deleted.
45 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070046 * @param dpid DPID of the switch from which the queue is deleted.
Ray Milkey8e5170e2014-04-02 12:09:55 -070047 * @return true if queue is successfully deleted.
48 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070049 boolean deleteQueue(Dpid dpid);
Naoki Shiotac1601d32013-11-20 10:47:34 -080050
Ray Milkey8e5170e2014-04-02 12:09:55 -070051 /**
52 * Delete a queue correspondent to the switch.
53 * By setting force flag on, queue will be deleted immediately.
54 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070055 * @param dpid DPID of the switch from which the queue is deleted.
Ray Milkey8e5170e2014-04-02 12:09:55 -070056 * @param forceStop If this flag is set to true, queue will be deleted
57 * immediately regardless of any messages in the queue.
58 * If false, all messages will be sent to switch and queue will
59 * be deleted after that.
60 * @return true if queue is successfully deleted or flagged to be deleted.
61 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070062 boolean deleteQueue(Dpid dpid, boolean forceStop);
Pavlin Radoslavovab3f8862013-12-04 18:35:53 -080063
Ray Milkey8e5170e2014-04-02 12:09:55 -070064 /**
65 * Add a message to the queue of the switch with normal priority.
66 * <p/>
67 * Note: Notification is NOT delivered for the pushed message.
68 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070069 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -070070 * @param msg Message object to be added.
71 * @return true if message is successfully added to a queue.
72 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070073 boolean add(Dpid dpid, OFMessage msg);
Naoki Shiotac1601d32013-11-20 10:47:34 -080074
Ray Milkey8e5170e2014-04-02 12:09:55 -070075 /**
76 * Add a message to the queue of the switch with specific priority.
77 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070078 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -070079 * @param msg Message object to be added.
80 * @param priority Sending priority of the message.
81 * @return true if message is successfully added to a queue.
82 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070083 boolean add(Dpid dpid, OFMessage msg, MsgPriority priority);
Ray Milkey8e5170e2014-04-02 12:09:55 -070084
85 /**
86 * Push a collection of Flow Entries to the corresponding switches
87 * with normal priority.
88 * <p/>
89 * Note: Notification is delivered for the Flow Entries that
90 * are pushed successfully.
91 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -070092 * @param entries the collection of <Dpid, FlowEntry> pairs
Ray Milkey8e5170e2014-04-02 12:09:55 -070093 * to push.
94 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -070095 void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries);
Ray Milkey8e5170e2014-04-02 12:09:55 -070096
97 /**
98 * Push a collection of Flow Entries to the corresponding switches
99 * with specific priority.
100 * <p/>
101 * Note: Notification is delivered for the Flow Entries that
102 * are pushed successfully.
103 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700104 * @param entries the collection of <Dpid, FlowEntry> pairs
Ray Milkey8e5170e2014-04-02 12:09:55 -0700105 * to push.
106 * @param priority Sending priority of flow entries.
107 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700108 void pushFlowEntries(Collection<Pair<Dpid, FlowEntry>> entries,
Ray Milkey8e5170e2014-04-02 12:09:55 -0700109 MsgPriority priority);
110
111 /**
112 * Create a message from FlowEntry and add it to the queue of the
113 * switch with normal priority.
114 * <p/>
115 * Note: Notification is delivered for the Flow Entries that
116 * are pushed successfully.
117 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700118 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700119 * @param flowEntry FlowEntry object used for creating message.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700120 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700121 void pushFlowEntry(Dpid dpid, FlowEntry flowEntry);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700122
123 /**
124 * Create a message from FlowEntry and add it to the queue of the
125 * switch with specific priority.
126 * <p/>
127 * Note: Notification is delivered for the Flow Entries that
128 * are pushed successfully.
129 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700130 * @param dpid DPID of the switch to which the message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700131 * @param flowEntry FlowEntry object used for creating message.
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700132 * @param priority Sending priority of flow entries.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700133 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700134 void pushFlowEntry(Dpid dpid, FlowEntry flowEntry,
Ray Milkey8e5170e2014-04-02 12:09:55 -0700135 MsgPriority priority);
136
137 /**
138 * Set sending rate to a switch.
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700139 * <p/>
140 * TODO The rate limiter function currently does not work as we are unable
141 * to determine the size of the messages when using Loxi.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700142 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700143 * @param dpid DPID of the switch to alter the sending rate of.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700144 * @param rate Rate in bytes/ms.
145 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700146 public void setRate(Dpid dpid, long rate);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700147
148 /**
149 * Add BARRIER message to queue and wait for reply.
150 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700151 * @param dpid DPID of the switch to which a barrier message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700152 * @return BARRIER_REPLY message sent from switch.
153 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700154 OFBarrierReply barrier(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700155
156 /**
157 * Add BARRIER message to queue asynchronously.
158 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700159 * @param dpid DPID of the switch to which a barrier message is pushed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700160 * @return Future object of BARRIER_REPLY message which will be sent from switch.
161 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700162 OFMessageFuture<OFBarrierReply> barrierAsync(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700163
164 /**
165 * Suspend pushing message to a switch.
166 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700167 * @param dpid DPID of the switch whose queue is to be suspended.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700168 * @return true if success
169 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700170 boolean suspend(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700171
172 /**
173 * Resume pushing message to a switch.
174 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700175 * @param dpid DPID of the switch whose queue is to be resumed.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700176 * @return true if success
177 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700178 boolean resume(Dpid dpid);
Ray Milkey8e5170e2014-04-02 12:09:55 -0700179
180 /**
181 * Get state of queue attached to a switch.
182 *
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700183 * @param dpid DPID of the switch to be checked.
Ray Milkey8e5170e2014-04-02 12:09:55 -0700184 * @return State of queue.
185 */
Jonathan Hart5302b6c2014-08-13 15:57:59 -0700186 QueueState getState(Dpid dpid);
Naoki Shiota8ee48d52013-11-11 15:51:17 -0800187}