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