Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.networkgraph; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | import java.util.HashMap; |
| 6 | import java.util.List; |
| 7 | import java.util.Map; |
| 8 | |
| 9 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 10 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 11 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 12 | import net.floodlightcontroller.core.module.IFloodlightService; |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 13 | import net.floodlightcontroller.restserver.IRestApiService; |
Pavlin Radoslavov | 721a2e0 | 2014-02-14 23:40:14 -0800 | [diff] [blame] | 14 | import net.onrc.onos.datagrid.IDatagridService; |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 15 | import net.onrc.onos.ofcontroller.networkgraph.web.NetworkGraphWebRoutable; |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 16 | import net.onrc.onos.registry.controller.IControllerRegistryService; |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 17 | |
| 18 | public class NetworkGraphModule implements IFloodlightModule, INetworkGraphService { |
| 19 | |
| 20 | // This is initialized as a module for now |
| 21 | // private RCNetworkGraphPublisher eventListener; |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 22 | |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 23 | private NetworkGraphImpl networkGraph; |
Jonathan Hart | 22eb988 | 2014-02-11 15:52:59 -0800 | [diff] [blame] | 24 | //private NetworkGraphDatastore southboundNetworkGraph; |
Pavlin Radoslavov | 721a2e0 | 2014-02-14 23:40:14 -0800 | [diff] [blame] | 25 | private IDatagridService datagridService; |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 26 | private IControllerRegistryService registryService; |
| 27 | |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 28 | |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 29 | private IRestApiService restApi; |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 30 | |
| 31 | @Override |
| 32 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 33 | List<Class<? extends IFloodlightService>> services = |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 34 | new ArrayList<Class<? extends IFloodlightService>>(); |
| 35 | services.add(INetworkGraphService.class); |
| 36 | return services; |
| 37 | } |
| 38 | |
| 39 | @Override |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 40 | public Map<Class<? extends IFloodlightService>, IFloodlightService> |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 41 | getServiceImpls() { |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 42 | Map<Class<? extends IFloodlightService>, IFloodlightService> impls = |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 43 | new HashMap<Class<? extends IFloodlightService>, IFloodlightService>(); |
| 44 | impls.put(INetworkGraphService.class, this); |
| 45 | return impls; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public Collection<Class<? extends IFloodlightService>> getModuleDependencies() { |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 50 | List<Class<? extends IFloodlightService>> dependencies = |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 51 | new ArrayList<Class<? extends IFloodlightService>>(); |
Pavlin Radoslavov | 721a2e0 | 2014-02-14 23:40:14 -0800 | [diff] [blame] | 52 | dependencies.add(IDatagridService.class); |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 53 | dependencies.add(IRestApiService.class); |
| 54 | return dependencies; |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 55 | } |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 56 | |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 57 | @Override |
| 58 | public void init(FloodlightModuleContext context) |
| 59 | throws FloodlightModuleException { |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 60 | restApi = context.getServiceImpl(IRestApiService.class); |
Pavlin Radoslavov | 721a2e0 | 2014-02-14 23:40:14 -0800 | [diff] [blame] | 61 | datagridService = context.getServiceImpl(IDatagridService.class); |
Yuta HIGUCHI | 170229f | 2014-02-17 15:47:54 -0800 | [diff] [blame^] | 62 | registryService = context.getServiceImpl(IControllerRegistryService.class); |
| 63 | |
| 64 | networkGraph = new NetworkGraphImpl(registryService); |
Jonathan Hart | 22eb988 | 2014-02-11 15:52:59 -0800 | [diff] [blame] | 65 | //southboundNetworkGraph = new NetworkGraphDatastore(networkGraph); |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public void startUp(FloodlightModuleContext context) { |
Jonathan Hart | 4701671 | 2014-02-07 12:41:35 -0800 | [diff] [blame] | 70 | restApi.addRestletRoutable(new NetworkGraphWebRoutable()); |
Pavlin Radoslavov | 721a2e0 | 2014-02-14 23:40:14 -0800 | [diff] [blame] | 71 | networkGraph.startup(datagridService); |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public NetworkGraph getNetworkGraph() { |
| 76 | return networkGraph; |
| 77 | } |
| 78 | |
| 79 | @Override |
Jonathan Hart | 22eb988 | 2014-02-11 15:52:59 -0800 | [diff] [blame] | 80 | public NetworkGraphDiscoveryInterface getNetworkGraphDiscoveryInterface() { |
| 81 | return networkGraph; |
Jonathan Hart | 4b5bbb5 | 2014-02-06 10:09:31 -0800 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | } |