Pavlin Radoslavov | 1eee2c8 | 2013-10-15 02:30:32 -0700 | [diff] [blame] | 1 | package net.onrc.onos.datagrid; |
| 2 | |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 3 | import java.util.Collection; |
| 4 | |
Pavlin Radoslavov | 1eee2c8 | 2013-10-15 02:30:32 -0700 | [diff] [blame] | 5 | import net.floodlightcontroller.core.module.IFloodlightService; |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 6 | import net.onrc.onos.intent.Intent; |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 7 | import net.onrc.onos.ofcontroller.flowmanager.IFlowEventHandlerService; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 8 | import net.onrc.onos.ofcontroller.proxyarp.ArpReplyNotification; |
| 9 | import net.onrc.onos.ofcontroller.proxyarp.IArpReplyEventHandler; |
| 10 | import net.onrc.onos.ofcontroller.proxyarp.IPacketOutEventHandler; |
| 11 | import net.onrc.onos.ofcontroller.proxyarp.PacketOutNotification; |
Pavlin Radoslavov | aaace7f | 2013-10-25 19:42:00 -0700 | [diff] [blame] | 12 | import net.onrc.onos.ofcontroller.topology.TopologyElement; |
Pavlin Radoslavov | 909da3c | 2014-01-09 04:04:33 -0800 | [diff] [blame] | 13 | import net.onrc.onos.ofcontroller.util.Dpid; |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 14 | import net.onrc.onos.ofcontroller.util.FlowEntry; |
| 15 | import net.onrc.onos.ofcontroller.util.FlowEntryId; |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 16 | import net.onrc.onos.ofcontroller.util.FlowId; |
| 17 | import net.onrc.onos.ofcontroller.util.FlowPath; |
Pavlin Radoslavov | a9c0c3b | 2014-01-09 10:54:45 -0800 | [diff] [blame] | 18 | import net.onrc.onos.ofcontroller.util.Pair; |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 19 | |
Pavlin Radoslavov | 1eee2c8 | 2013-10-15 02:30:32 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Interface for providing Datagrid Service to other modules. |
| 22 | */ |
| 23 | public interface IDatagridService extends IFloodlightService { |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame^] | 24 | /** |
| 25 | * Create an event channel. |
| 26 | * |
| 27 | * If the channel already exists, just return it. |
| 28 | * NOTE: The channel is started automatically. |
| 29 | * |
| 30 | * @param channelName the event channel name. |
| 31 | * @param typeK the type of the Key in the Key-Value store. |
| 32 | * @param typeV the type of the Value in the Key-Value store. |
| 33 | * @return the event channel for the channel name. |
| 34 | */ |
| 35 | <K, V> IEventChannel<K, V> createChannel(String channelName, |
| 36 | Class<K> typeK, Class<V> typeV); |
| 37 | |
| 38 | /** |
| 39 | * Add event channel listener. |
| 40 | * |
| 41 | * NOTE: The channel is started automatically right after the listener |
| 42 | * is added. |
| 43 | * |
| 44 | * @param channelName the event channel name. |
| 45 | * @param listener the listener to add. |
| 46 | * @param typeK the type of the Key in the Key-Value store. |
| 47 | * @param typeV the type of the Value in the Key-Value store. |
| 48 | * @return the event channel for the channel name. |
| 49 | */ |
| 50 | <K, V> IEventChannel<K, V> addListener(String channelName, |
| 51 | IEventChannelListener<K, V> listener, |
| 52 | Class<K> typeK, Class<V> typeV); |
| 53 | |
| 54 | /** |
| 55 | * Remove event channel listener. |
| 56 | * |
| 57 | * @param channelName the event channel name. |
| 58 | * @param listener the listener to remove. |
| 59 | */ |
| 60 | <K, V> void removeListener(String channelName, |
| 61 | IEventChannelListener<K, V> listener); |
| 62 | |
Toshio Koide | 3738ee5 | 2014-02-12 14:57:39 -0800 | [diff] [blame] | 63 | /* |
| 64 | * register all the intents as one batch |
| 65 | */ |
| 66 | void registerIntent(Collection<Intent> intents); |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 67 | /** |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 68 | * Register Flow Event Handler Service for receiving Flow-related |
Pavlin Radoslavov | 6b79f2b | 2013-10-26 21:31:10 -0700 | [diff] [blame] | 69 | * notifications. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 70 | * |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 71 | * NOTE: Only a single Flow Event Handler Service can be registered. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 72 | * |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 73 | * @param flowEventHandlerService the Flow Event Handler Service to register. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 74 | */ |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 75 | void registerFlowEventHandlerService(IFlowEventHandlerService flowEventHandlerService); |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 78 | * De-register Flow Event Handler Service for receiving Flow-related |
Pavlin Radoslavov | 6b79f2b | 2013-10-26 21:31:10 -0700 | [diff] [blame] | 79 | * notifications. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 80 | * |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 81 | * NOTE: Only a single Flow Event Handler Service can be registered. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 82 | * |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 83 | * @param flowEventHandlerService the Flow Event Handler Service to |
Pavlin Radoslavov | 6b79f2b | 2013-10-26 21:31:10 -0700 | [diff] [blame] | 84 | * de-register. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 85 | */ |
Pavlin Radoslavov | 9a85902 | 2013-10-30 10:08:24 -0700 | [diff] [blame] | 86 | void deregisterFlowEventHandlerService(IFlowEventHandlerService flowEventHandlerService); |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 89 | * Register event handler for packet-out events. |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 90 | * |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 91 | * @param packetOutEventHandler The packet-out event handler to register. |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 92 | */ |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 93 | public void registerPacketOutEventHandler(IPacketOutEventHandler packetOutEventHandler); |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 94 | |
| 95 | /** |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 96 | * Deregister event handler service for packet-out events. |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 97 | * |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 98 | * @param packetOutEventHandler The packet-out event handler to deregister. |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 99 | */ |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 100 | public void deregisterPacketOutEventHandler(IPacketOutEventHandler packetOutEventHandler); |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 101 | |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 102 | /** |
| 103 | * Register event handler for ARP reply events. |
| 104 | * |
| 105 | * @param packetOutEventHandler The ARP reply event handler to register. |
| 106 | */ |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 107 | public void registerArpReplyEventHandler(IArpReplyEventHandler arpReplyEventHandler); |
| 108 | |
Jonathan Hart | c632562 | 2014-01-14 16:37:50 -0800 | [diff] [blame] | 109 | /** |
| 110 | * Deregister event handler service for ARP reply events. |
| 111 | * |
| 112 | * @param packetOutEventHandler The ARP reply event handler to deregister. |
| 113 | */ |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 114 | public void deregisterArpReplyEventHandler(IArpReplyEventHandler arpReplyEventHandler); |
Pavlin Radoslavov | 379c904 | 2013-11-26 15:40:49 -0800 | [diff] [blame] | 115 | |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 116 | /** |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 117 | * Get all Flows that are currently in the datagrid. |
| 118 | * |
| 119 | * @return all Flows that are currently in the datagrid. |
| 120 | */ |
| 121 | Collection<FlowPath> getAllFlows(); |
| 122 | |
| 123 | /** |
Pavlin Radoslavov | 379c904 | 2013-11-26 15:40:49 -0800 | [diff] [blame] | 124 | * Get a Flow for a given Flow ID. |
| 125 | * |
| 126 | * @param flowId the Flow ID of the Flow to get. |
| 127 | * @return the Flow if found, otherwise null. |
| 128 | */ |
| 129 | FlowPath getFlow(FlowId flowId); |
| 130 | |
| 131 | /** |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 132 | * Send a notification that a Flow is added. |
| 133 | * |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 134 | * @param flowPath the Flow that is added. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 135 | */ |
| 136 | void notificationSendFlowAdded(FlowPath flowPath); |
| 137 | |
| 138 | /** |
| 139 | * Send a notification that a Flow is removed. |
| 140 | * |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 141 | * @param flowId the Flow ID of the Flow that is removed. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 142 | */ |
| 143 | void notificationSendFlowRemoved(FlowId flowId); |
| 144 | |
| 145 | /** |
| 146 | * Send a notification that a Flow is updated. |
| 147 | * |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 148 | * @param flowPath the Flow that is updated. |
Pavlin Radoslavov | 1308dc6 | 2013-10-25 15:54:31 -0700 | [diff] [blame] | 149 | */ |
| 150 | void notificationSendFlowUpdated(FlowPath flowPath); |
| 151 | |
| 152 | /** |
| 153 | * Send a notification that all Flows are removed. |
| 154 | */ |
| 155 | void notificationSendAllFlowsRemoved(); |
Pavlin Radoslavov | aaace7f | 2013-10-25 19:42:00 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 158 | * Get all Flow Entries that are currently in the datagrid. |
| 159 | * |
| 160 | * @return all Flow Entries that are currently in the datagrid. |
| 161 | */ |
| 162 | Collection<FlowEntry> getAllFlowEntries(); |
| 163 | |
| 164 | /** |
Pavlin Radoslavov | 379c904 | 2013-11-26 15:40:49 -0800 | [diff] [blame] | 165 | * Get a Flow Entry for a given Flow Entry ID. |
| 166 | * |
| 167 | * @param flowEntryId the Flow Entry ID of the Flow Entry to get. |
| 168 | * @return the Flow Entry if found, otherwise null. |
| 169 | */ |
| 170 | FlowEntry getFlowEntry(FlowEntryId flowEntryId); |
| 171 | |
| 172 | /** |
Pavlin Radoslavov | b750684 | 2013-10-29 17:46:54 -0700 | [diff] [blame] | 173 | * Send a notification that a FlowEntry is added. |
| 174 | * |
| 175 | * @param flowEntry the FlowEntry that is added. |
| 176 | */ |
| 177 | void notificationSendFlowEntryAdded(FlowEntry flowEntry); |
| 178 | |
| 179 | /** |
| 180 | * Send a notification that a FlowEntry is removed. |
| 181 | * |
| 182 | * @param flowEntryId the FlowEntry ID of the FlowEntry that is removed. |
| 183 | */ |
| 184 | void notificationSendFlowEntryRemoved(FlowEntryId flowEntryId); |
| 185 | |
| 186 | /** |
| 187 | * Send a notification that a FlowEntry is updated. |
| 188 | * |
| 189 | * @param flowEntry the FlowEntry that is updated. |
| 190 | */ |
| 191 | void notificationSendFlowEntryUpdated(FlowEntry flowEntry); |
| 192 | |
| 193 | /** |
| 194 | * Send a notification that all Flow Entries are removed. |
| 195 | */ |
| 196 | void notificationSendAllFlowEntriesRemoved(); |
| 197 | |
| 198 | /** |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 199 | * Get all Flow IDs that are currently in the datagrid. |
| 200 | * |
Pavlin Radoslavov | a9c0c3b | 2014-01-09 10:54:45 -0800 | [diff] [blame] | 201 | * @return all Flow IDs that ae currently in the datagrid. |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 202 | */ |
Pavlin Radoslavov | 2194d11 | 2014-01-10 13:36:00 -0800 | [diff] [blame] | 203 | Collection<Pair<FlowId, Dpid>> getAllFlowIds(); |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * Send a notification that a FlowId is added. |
| 207 | * |
| 208 | * @param flowId the FlowId that is added. |
Pavlin Radoslavov | 2194d11 | 2014-01-10 13:36:00 -0800 | [diff] [blame] | 209 | * @param dpid the Source Switch Dpid. |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 210 | */ |
Pavlin Radoslavov | 2194d11 | 2014-01-10 13:36:00 -0800 | [diff] [blame] | 211 | void notificationSendFlowIdAdded(FlowId flowId, Dpid dpid); |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * Send a notification that a FlowId is removed. |
| 215 | * |
| 216 | * @param flowId the FlowId that is removed. |
| 217 | */ |
| 218 | void notificationSendFlowIdRemoved(FlowId flowId); |
| 219 | |
| 220 | /** |
| 221 | * Send a notification that a FlowId is updated. |
| 222 | * |
| 223 | * @param flowId the FlowId that is updated. |
Pavlin Radoslavov | 2194d11 | 2014-01-10 13:36:00 -0800 | [diff] [blame] | 224 | * @param dpid the Source Switch Dpid. |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 225 | */ |
Pavlin Radoslavov | 2194d11 | 2014-01-10 13:36:00 -0800 | [diff] [blame] | 226 | void notificationSendFlowIdUpdated(FlowId flowId, Dpid dpid); |
Pavlin Radoslavov | 2004fa0 | 2014-01-07 14:46:42 -0800 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * Send a notification that all Flow IDs are removed. |
| 230 | */ |
| 231 | void notificationSendAllFlowIdsRemoved(); |
| 232 | |
| 233 | /** |
Pavlin Radoslavov | a9c0c3b | 2014-01-09 10:54:45 -0800 | [diff] [blame] | 234 | * Get all Flow Entry IDs that are currently in the datagrid. |
| 235 | * |
| 236 | * @return all Flow Entry IDs that ae currently in the datagrid. |
| 237 | */ |
| 238 | Collection<Pair<FlowEntryId, Dpid>> getAllFlowEntryIds(); |
| 239 | |
| 240 | /** |
Pavlin Radoslavov | 909da3c | 2014-01-09 04:04:33 -0800 | [diff] [blame] | 241 | * Send a notification that a FlowEntryId is added. |
| 242 | * |
| 243 | * @param flowEntryId the FlowEntryId that is added. |
| 244 | * @param dpid the Switch Dpid. |
| 245 | */ |
| 246 | void notificationSendFlowEntryIdAdded(FlowEntryId flowEntryId, Dpid dpid); |
| 247 | |
| 248 | /** |
| 249 | * Send a notification that a FlowEntryId is removed. |
| 250 | * |
| 251 | * @param flowEntryId the FlowEntryId that is removed. |
| 252 | */ |
| 253 | void notificationSendFlowEntryIdRemoved(FlowEntryId flowEntryId); |
| 254 | |
| 255 | /** |
| 256 | * Send a notification that a FlowEntryId is updated. |
| 257 | * |
| 258 | * @param flowEntryId the FlowEntryId that is updated. |
| 259 | * @param dpid the Switch Dpid. |
| 260 | */ |
| 261 | void notificationSendFlowEntryIdUpdated(FlowEntryId flowEntryId, |
| 262 | Dpid dpid); |
| 263 | |
| 264 | /** |
| 265 | * Send a notification that all Flow Entry IDs are removed. |
| 266 | */ |
| 267 | void notificationSendAllFlowEntryIdsRemoved(); |
| 268 | |
| 269 | /** |
Pavlin Radoslavov | aaace7f | 2013-10-25 19:42:00 -0700 | [diff] [blame] | 270 | * Get all Topology Elements that are currently in the datagrid. |
| 271 | * |
| 272 | * @return all Topology Elements that are currently in the datagrid. |
| 273 | */ |
| 274 | Collection<TopologyElement> getAllTopologyElements(); |
| 275 | |
| 276 | /** |
| 277 | * Send a notification that a Topology Element is added. |
| 278 | * |
| 279 | * @param topologyElement the Topology Element that is added. |
| 280 | */ |
| 281 | void notificationSendTopologyElementAdded(TopologyElement topologyElement); |
| 282 | |
| 283 | /** |
| 284 | * Send a notification that a Topology Element is removed. |
| 285 | * |
| 286 | * @param topologyElement the Topology Element that is removed. |
| 287 | */ |
| 288 | void notificationSendTopologyElementRemoved(TopologyElement topologyElement); |
| 289 | |
| 290 | /** |
| 291 | * Send a notification that a Topology Element is updated. |
| 292 | * |
| 293 | * @param topologyElement the Topology Element that is updated. |
| 294 | */ |
| 295 | void notificationSendTopologyElementUpdated(TopologyElement topologyElement); |
| 296 | |
| 297 | /** |
| 298 | * Send a notification that all Topology Elements are removed. |
| 299 | */ |
| 300 | void notificationSendAllTopologyElementsRemoved(); |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 301 | |
| 302 | /** |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 303 | * Send a packet-out notification to other ONOS instances. This informs |
| 304 | * other instances that they should send this packet out some of the ports |
| 305 | * they control. Not all notifications are applicable to all instances |
| 306 | * (i.e. some notifications specify a single port to send the packet out), |
| 307 | * so each instance must determine whether it needs to take action when it |
| 308 | * receives the notification. |
| 309 | * |
| 310 | * @param packetOutNotification The packet notification to send |
Jonathan Hart | 18ad55c | 2013-11-11 22:49:55 -0800 | [diff] [blame] | 311 | */ |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 312 | public void sendPacketOutNotification(PacketOutNotification packetOutNotification); |
| 313 | |
| 314 | /** |
| 315 | * Send notification to other ONOS instances that an ARP reply has been |
| 316 | * received. |
| 317 | * @param arpReply The notification of the ARP reply |
| 318 | */ |
| 319 | public void sendArpReplyNotification(ArpReplyNotification arpReply); |
Pavlin Radoslavov | 1eee2c8 | 2013-10-15 02:30:32 -0700 | [diff] [blame] | 320 | } |