blob: 7c05467928e1eb13c556c34b818f4ae905ce2295 [file] [log] [blame]
HIGUCHI Yuta155cfc52013-06-14 15:54:16 -07001package net.onrc.onos.ofcontroller.floodlightlistener;
Pankaj Berdeda809572013-02-22 15:31:20 -08002
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Map;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -07006import java.util.concurrent.TimeUnit;
Pankaj Berdeda809572013-02-22 15:31:20 -08007
Pankaj Berdeda809572013-02-22 15:31:20 -08008import net.floodlightcontroller.core.IFloodlightProviderService;
9import net.floodlightcontroller.core.IOFSwitch;
10import net.floodlightcontroller.core.IOFSwitchListener;
Pankaj Berdeda809572013-02-22 15:31:20 -080011import net.floodlightcontroller.core.module.FloodlightModuleContext;
12import net.floodlightcontroller.core.module.FloodlightModuleException;
13import net.floodlightcontroller.core.module.IFloodlightModule;
14import net.floodlightcontroller.core.module.IFloodlightService;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070015import net.floodlightcontroller.core.util.SingletonTask;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070016import net.floodlightcontroller.threadpool.IThreadPoolService;
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070017import net.onrc.onos.datagrid.IDatagridService;
Jonathan Hartd857ad62013-12-14 18:08:17 -080018import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
HIGUCHI Yutaa56fbde2013-06-17 14:26:05 -070019import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryListener;
20import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
Jonathan Hart02a59e42014-03-26 18:50:23 -070021import net.onrc.onos.ofcontroller.linkdiscovery.Link;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070022import net.onrc.onos.registry.controller.IControllerRegistryService;
23import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
Pankaj Berdeda809572013-02-22 15:31:20 -080024
Jonathan Hartd857ad62013-12-14 18:08:17 -080025import org.openflow.protocol.OFPhysicalPort;
Jonathan Hartd857ad62013-12-14 18:08:17 -080026import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28
Jonathan Hart02a59e42014-03-26 18:50:23 -070029public class OldNetworkGraphPublisher implements
Pavlin Radoslavov28069402013-10-18 18:43:11 -070030 IOFSwitchListener,
31 IOFSwitchPortListener,
32 ILinkDiscoveryListener,
Jonathan Hart4b5bbb52014-02-06 10:09:31 -080033 IFloodlightModule {
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -080034
Pavlin Radoslavovc0aa4bf2014-03-26 18:32:49 -070035 protected final static Logger log = LoggerFactory.getLogger(OldNetworkGraphPublisher.class);
Jonathan Hartd857ad62013-12-14 18:08:17 -080036 //protected IDeviceService deviceService;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070037 protected IControllerRegistryService registryService;
Pavlin Radoslavov697f6982014-03-26 15:55:19 -070038 // protected DBOperation op;
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -080039
Pankaj Berdeda809572013-02-22 15:31:20 -080040 protected static final String DBConfigFile = "dbconf";
yoshi2fd4c7e2013-11-22 15:47:55 -080041 protected static final String GraphDBStore = "graph_db_store";
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -070042 protected static final String CleanupEnabled = "EnableCleanup";
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070043 protected IThreadPoolService threadPool;
Pankaj Berde465ac7c2013-05-23 13:47:49 -070044 protected IFloodlightProviderService floodlightProvider;
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -080045
Pankaj Berde62016142013-04-09 15:35:50 -070046 protected final int CLEANUP_TASK_INTERVAL = 60; // 1 min
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070047 protected SingletonTask cleanupTask;
Pankaj Berde00e90882013-06-10 21:25:05 -070048 protected ILinkDiscoveryService linkDiscovery;
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070049
50 protected IDatagridService datagridService;
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -080051
52 /**
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070053 * Cleanup and synch switch state from registry
54 */
55 protected class SwitchCleanup implements ControlChangeCallback, Runnable {
56 @Override
57 public void run() {
Yuta HIGUCHI61509a42013-12-17 10:41:04 -080058 String old = Thread.currentThread().getName();
Yuta HIGUCHI1412e8c2014-01-03 17:19:01 -080059 Thread.currentThread().setName("SwitchCleanup@" + old);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070060 try {
61 log.debug("Running cleanup thread");
Pavlin Radoslavov697f6982014-03-26 15:55:19 -070062 // op = GraphDBManager.getDBOperation();
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070063 switchCleanup();
64 }
65 catch (Exception e) {
66 log.error("Error in cleanup thread", e);
67 } finally {
Pavlin Radoslavov697f6982014-03-26 15:55:19 -070068 // op.close();
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070069 cleanupTask.reschedule(CLEANUP_TASK_INTERVAL,
Pankaj Berde99fcee12013-03-18 09:41:53 -070070 TimeUnit.SECONDS);
Yuta HIGUCHI61509a42013-12-17 10:41:04 -080071 Thread.currentThread().setName(old);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070072 }
73 }
74
75 @Override
76 public void controlChanged(long dpid, boolean hasControl) {
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -070077 /*
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070078 if (hasControl) {
Pankaj Berde99fcee12013-03-18 09:41:53 -070079 log.debug("got control to set inactive sw {}", HexString.toHexString(dpid));
Naoki Shiota987a5722013-10-23 11:59:36 -070080 try {
Pavlin Radoslavovfb157282013-11-05 08:40:13 -080081 // Get the affected ports
82 List<Short> ports = swStore.getPorts(HexString.toHexString(dpid));
83 // Get the affected links
84 List<Link> links = linkStore.getLinks(HexString.toHexString(dpid));
85 // Get the affected reverse links
86 List<Link> reverseLinks = linkStore.getReverseLinks(HexString.toHexString(dpid));
87 links.addAll(reverseLinks);
88
Jonathan Hartadc63892013-11-08 14:03:55 -080089 //if (swStore.updateSwitch(HexString.toHexString(dpid), SwitchState.INACTIVE, DM_OPERATION.UPDATE)) {
90 if (swStore.deactivateSwitch(HexString.toHexString(dpid))) {
Naoki Shiota987a5722013-10-23 11:59:36 -070091 registryService.releaseControl(dpid);
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -080092
Naoki Shiota987a5722013-10-23 11:59:36 -070093 // TODO publish UPDATE_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070094 //
95 // NOTE: Here we explicitly send
96 // notification to remove the
97 // switch, because it is inactive
98 //
99 TopologyElement topologyElement =
100 new TopologyElement(dpid);
101 datagridService.notificationSendTopologyElementRemoved(topologyElement);
102
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800103 // Publish: remove the affected ports
104 for (Short port : ports) {
105 TopologyElement topologyElementPort =
106 new TopologyElement(dpid, port);
107 datagridService.notificationSendTopologyElementRemoved(topologyElementPort);
108 }
109 // Publish: remove the affected links
110 for (Link link : links) {
111 TopologyElement topologyElementLink =
112 new TopologyElement(link.getSrc(),
113 link.getSrcPort(),
114 link.getDst(),
115 link.getDstPort());
116 datagridService.notificationSendTopologyElementRemoved(topologyElementLink);
117 }
Naoki Shiota987a5722013-10-23 11:59:36 -0700118 }
119 } catch (Exception e) {
120 log.error("Error in SwitchCleanup:controlChanged ", e);
121 }
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800122 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700123 */
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700124 }
125 }
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700126
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700127 protected void switchCleanup() {
Pavlin Radoslavov4cf8ee52014-03-26 18:19:58 -0700128 /*
yoshi8b972bc2013-12-05 17:10:04 -0800129 //op.close();
Pavlin Radoslavov4cf8ee52014-03-26 18:19:58 -0700130 Iterable<ISwitchObject> switches = op.getActiveSwitches();
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800131
Jonathan Hartf02a0932013-03-18 18:30:48 -0700132 log.debug("Checking for inactive switches");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700133 // For each switch check if a controller exists in controller registry
134 for (ISwitchObject sw: switches) {
Jonathan Hartf02a0932013-03-18 18:30:48 -0700135 //log.debug("checking if switch is inactive: {}", sw.getDPID());
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700136 try {
137 long dpid = HexString.toLong(sw.getDPID());
138 String controller = registryService.getControllerForSwitch(dpid);
139 if (controller == null) {
Pankaj Berde99fcee12013-03-18 09:41:53 -0700140 log.debug("request Control to set inactive sw {}", HexString.toHexString(dpid));
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700141 registryService.requestControl(dpid, new SwitchCleanup());
Umesh Krishnaswamy255b9882013-04-02 19:55:43 -0700142 //} else {
143 // log.debug("sw {} is controlled by controller: {}",HexString.toHexString(dpid),controller);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700144 }
145 } catch (NumberFormatException e) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700146 log.debug("Caught NumberFormatException trying to requestControl in cleanup thread");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700147 e.printStackTrace();
148 } catch (RegistryException e) {
Jonathan Hart4baf3be2013-03-21 18:26:13 -0700149 log.debug("Caught RegistryException trying to requestControl in cleanup thread");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700150 e.printStackTrace();
Naoki Shiota987a5722013-10-23 11:59:36 -0700151 }
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700152 }
Pavlin Radoslavov697f6982014-03-26 15:55:19 -0700153 // op.close();
Pavlin Radoslavov4cf8ee52014-03-26 18:19:58 -0700154 */
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700155 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800156
pingping-lin00926032013-12-18 12:13:08 +0800157 @Override
158 public void linkDiscoveryUpdate(LDUpdate update) {
159 Link lt = new Link(update.getSrc(),update.getSrcPort(),update.getDst(),update.getDstPort());
160 //log.debug("{}:LinkDicoveryUpdate(): Updating Link {}",this.getClass(), lt);
Pankaj Berdeda809572013-02-22 15:31:20 -0800161
pingping-lin00926032013-12-18 12:13:08 +0800162 switch (update.getOperation()) {
163 case LINK_REMOVED:
164 log.debug("LinkDiscoveryUpdate(): Removing link {}", lt);
165
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700166 /*
pingping-lin00926032013-12-18 12:13:08 +0800167 if (linkStore.deleteLink(lt)) {
168 // TODO publish DELETE_LINK event here
169 TopologyElement topologyElement =
170 new TopologyElement(update.getSrc(),
171 update.getSrcPort(),
172 update.getDst(),
173 update.getDstPort());
174 datagridService.notificationSendTopologyElementRemoved(topologyElement);
175 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700176 */
pingping-lin00926032013-12-18 12:13:08 +0800177 break;
178 case LINK_UPDATED:
179 log.debug("LinkDiscoveryUpdate(): Updating link {}", lt);
180
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700181 /*
pingping-lin00926032013-12-18 12:13:08 +0800182 LinkInfo linfo = linkStore.getLinkInfo(lt);
183 // TODO update "linfo" using portState derived using "update"
184 if (linkStore.update(lt, linfo, DM_OPERATION.UPDATE)) {
185 // TODO publish UPDATE_LINK event here
186 //
187 // TODO NOTE: Here we assume that updated
188 // link is UP.
189 //
190 TopologyElement topologyElement =
191 new TopologyElement(update.getSrc(),
192 update.getSrcPort(),
193 update.getDst(),
194 update.getDstPort());
195 datagridService.notificationSendTopologyElementUpdated(topologyElement);
196 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700197 */
pingping-lin00926032013-12-18 12:13:08 +0800198 break;
199 case LINK_ADDED:
200 log.debug("LinkDiscoveryUpdate(): Adding link {}", lt);
201
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700202 /*
pingping-lin00926032013-12-18 12:13:08 +0800203 if (linkStore.addLink(lt)) {
204 // TODO publish ADD_LINK event here
205 TopologyElement topologyElement =
206 new TopologyElement(update.getSrc(),
207 update.getSrcPort(),
208 update.getDst(),
209 update.getDstPort());
210 datagridService.notificationSendTopologyElementAdded(topologyElement);
211 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700212 */
pingping-lin00926032013-12-18 12:13:08 +0800213
214 break;
215 default:
216 break;
217 }
218
219 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800220
221 @Override
222 public void addedSwitch(IOFSwitch sw) {
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700223 /*
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700224 if (registryService.hasControl(sw.getId())) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700225 if (swStore.addSwitch(sw)) {
226 // TODO publish ADD_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700227 TopologyElement topologyElement =
228 new TopologyElement(sw.getId());
Pavlin Radoslavov649c97d2013-11-04 16:00:23 -0800229 datagridService.notificationSendTopologyElementAdded(topologyElement);
Pankaj Berdeda809572013-02-22 15:31:20 -0800230
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800231 // Publish: add the ports
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700232 // TODO: Add only ports that are UP?
233 for (OFPhysicalPort port : sw.getPorts()) {
Jonathan Hart8a5d0972013-12-04 10:02:44 -0800234 TopologyElement topologyElementPort =
235 new TopologyElement(sw.getId(), port.getPortNumber());
236 datagridService.notificationSendTopologyElementAdded(topologyElementPort);
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800237
Jonathan Hart8a5d0972013-12-04 10:02:44 -0800238 // Allow links to be discovered on this port now that it's
239 // in the database
240 linkDiscovery.RemoveFromSuppressLLDPs(sw.getId(), port.getPortNumber());
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700241 }
Pavlin Radoslavov649c97d2013-11-04 16:00:23 -0800242
Pavlin Radoslavov0fe70022013-11-02 16:13:12 -0700243 // Add all links that might be connected already
244 List<Link> links = linkStore.getLinks(HexString.toHexString(sw.getId()));
245 // Add all reverse links as well
246 List<Link> reverseLinks = linkStore.getReverseLinks(HexString.toHexString(sw.getId()));
247 links.addAll(reverseLinks);
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800248
249 // Publish: add the links
Pavlin Radoslavov0fe70022013-11-02 16:13:12 -0700250 for (Link link : links) {
251 TopologyElement topologyElementLink =
252 new TopologyElement(link.getSrc(),
253 link.getSrcPort(),
254 link.getDst(),
255 link.getDstPort());
256 datagridService.notificationSendTopologyElementAdded(topologyElementLink);
257 }
Naoki Shiota987a5722013-10-23 11:59:36 -0700258 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800259 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700260 */
Pankaj Berdeda809572013-02-22 15:31:20 -0800261 }
262
263 @Override
264 public void removedSwitch(IOFSwitch sw) {
Jonathan Hartadc63892013-11-08 14:03:55 -0800265 /*
Naoki Shiota987a5722013-10-23 11:59:36 -0700266 if (registryService.hasControl(sw.getId())) {
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800267 // Get the affected ports
268 List<Short> ports = swStore.getPorts(HexString.toHexString(sw.getId()));
269 // Get the affected links
270 List<Link> links = linkStore.getLinks(HexString.toHexString(sw.getId()));
271 // Get the affected reverse links
272 List<Link> reverseLinks = linkStore.getReverseLinks(HexString.toHexString(sw.getId()));
273 links.addAll(reverseLinks);
Pankaj Berdeda809572013-02-22 15:31:20 -0800274
Naoki Shiota987a5722013-10-23 11:59:36 -0700275 if (swStore.deleteSwitch(sw.getStringId())) {
276 // TODO publish DELETE_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700277 TopologyElement topologyElement =
278 new TopologyElement(sw.getId());
279 datagridService.notificationSendTopologyElementRemoved(topologyElement);
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800280
281 // Publish: remove the affected ports
282 for (Short port : ports) {
283 TopologyElement topologyElementPort =
284 new TopologyElement(sw.getId(), port);
285 datagridService.notificationSendTopologyElementRemoved(topologyElementPort);
286 }
287 // Publish: remove the affected links
288 for (Link link : links) {
289 TopologyElement topologyElementLink =
290 new TopologyElement(link.getSrc(),
291 link.getSrcPort(),
292 link.getDst(),
293 link.getDstPort());
294 datagridService.notificationSendTopologyElementRemoved(topologyElementLink);
295 }
Naoki Shiota987a5722013-10-23 11:59:36 -0700296 }
297 }
Jonathan Hartadc63892013-11-08 14:03:55 -0800298 */
Pankaj Berdeda809572013-02-22 15:31:20 -0800299 }
300
301 @Override
302 public void switchPortChanged(Long switchId) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700303 // NOTE: Event not needed here. This callback always coincide with add/remove callback.
Pankaj Berdeda809572013-02-22 15:31:20 -0800304 }
305
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700306
307 @Override
308 public void switchPortAdded(Long switchId, OFPhysicalPort port) {
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700309 /*
Naoki Shiota987a5722013-10-23 11:59:36 -0700310 if (swStore.addPort(HexString.toHexString(switchId), port)) {
Jonathan Hart8a5d0972013-12-04 10:02:44 -0800311 // Allow links to be discovered on this port now that it's
312 // in the database
313 linkDiscovery.RemoveFromSuppressLLDPs(switchId, port.getPortNumber());
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800314
Naoki Shiota987a5722013-10-23 11:59:36 -0700315 // TODO publish ADD_PORT event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700316 TopologyElement topologyElement =
317 new TopologyElement(switchId, port.getPortNumber());
318 datagridService.notificationSendTopologyElementAdded(topologyElement);
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800319
320 // Add all links that might be connected already
321 List<Link> links = linkStore.getLinks(switchId, port.getPortNumber());
322 // Add all reverse links as well
323 List<Link> reverseLinks = linkStore.getReverseLinks(switchId, port.getPortNumber());
324 links.addAll(reverseLinks);
325
326 // Publish: add the links
327 for (Link link : links) {
328 TopologyElement topologyElementLink =
329 new TopologyElement(link.getSrc(),
330 link.getSrcPort(),
331 link.getDst(),
332 link.getDstPort());
333 datagridService.notificationSendTopologyElementAdded(topologyElementLink);
334 }
Naoki Shiota987a5722013-10-23 11:59:36 -0700335 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700336 */
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700337 }
338
339 @Override
340 public void switchPortRemoved(Long switchId, OFPhysicalPort port) {
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800341 // Remove all links that might be connected already
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700342
343 /*
Pavlin Radoslavove2497672014-01-12 18:03:35 -0800344 PerformanceMonitor.start("SwitchPortRemoved.DbAccess");
345
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800346 List<Link> links = linkStore.getLinks(switchId, port.getPortNumber());
347 // Remove all reverse links as well
348 List<Link> reverseLinks = linkStore.getReverseLinks(switchId, port.getPortNumber());
349 links.addAll(reverseLinks);
350
Naoki Shiota987a5722013-10-23 11:59:36 -0700351 if (swStore.deletePort(HexString.toHexString(switchId), port.getPortNumber())) {
Pavlin Radoslavove2497672014-01-12 18:03:35 -0800352 PerformanceMonitor.stop("SwitchPortRemoved.DbAccess");
353 PerformanceMonitor.start("SwitchPortRemoved.NotificationSend");
Naoki Shiota987a5722013-10-23 11:59:36 -0700354 // TODO publish DELETE_PORT event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700355 TopologyElement topologyElement =
356 new TopologyElement(switchId, port.getPortNumber());
357 datagridService.notificationSendTopologyElementRemoved(topologyElement);
Pavlin Radoslavovfb157282013-11-05 08:40:13 -0800358
359 // Publish: remove the links
360 for (Link link : links) {
361 TopologyElement topologyElementLink =
362 new TopologyElement(link.getSrc(),
363 link.getSrcPort(),
364 link.getDst(),
365 link.getDstPort());
366 datagridService.notificationSendTopologyElementRemoved(topologyElementLink);
367 }
Pavlin Radoslavove2497672014-01-12 18:03:35 -0800368 PerformanceMonitor.stop("SwitchPortRemoved.NotificationSend");
Pavlin Radoslavov8bd6d112014-01-12 20:12:37 -0800369 PerformanceMonitor.report("SwitchPortRemoved.DbAccess");
370 PerformanceMonitor.report("TopologyEntryRemoved.NotificationReceived");
Naoki Shiota987a5722013-10-23 11:59:36 -0700371 }
Pavlin Radoslavov5fe71882014-03-21 16:27:21 -0700372 */
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700373 }
374
Pankaj Berdeda809572013-02-22 15:31:20 -0800375 @Override
376 public String getName() {
Pavlin Radoslavovc0aa4bf2014-03-26 18:32:49 -0700377 return "OldNetworkGraphPublisher";
Pankaj Berdeda809572013-02-22 15:31:20 -0800378 }
379
380 @Override
Pankaj Berdeda809572013-02-22 15:31:20 -0800381 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Jonathan Hart4b5bbb52014-02-06 10:09:31 -0800382 return null;
Pankaj Berdeda809572013-02-22 15:31:20 -0800383 }
384
385 @Override
386 public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
Jonathan Hart4b5bbb52014-02-06 10:09:31 -0800387 return null;
Pankaj Berdeda809572013-02-22 15:31:20 -0800388 }
389
390 @Override
391 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
392 Collection<Class<? extends IFloodlightService>> l =
393 new ArrayList<Class<? extends IFloodlightService>>();
Pavlin Radoslavovc35229e2014-02-06 16:19:37 -0800394 l.add(IFloodlightProviderService.class);
395 //l.add(IDeviceService.class);
396 l.add(IDatagridService.class);
397 l.add(IThreadPoolService.class);
398 l.add(ILinkDiscoveryService.class);
399 return l;
Pankaj Berdeda809572013-02-22 15:31:20 -0800400 }
401
402 @Override
403 public void init(FloodlightModuleContext context)
404 throws FloodlightModuleException {
Pankaj Berdeda809572013-02-22 15:31:20 -0800405 Map<String, String> configMap = context.getConfigParams(this);
406 String conf = configMap.get(DBConfigFile);
yoshi2fd4c7e2013-11-22 15:47:55 -0800407 String dbStore = configMap.get(GraphDBStore);
Pavlin Radoslavov697f6982014-03-26 15:55:19 -0700408 // op = GraphDBManager.getDBOperation();
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800409
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700410 floodlightProvider =
411 context.getServiceImpl(IFloodlightProviderService.class);
Jonathan Hartd857ad62013-12-14 18:08:17 -0800412 //deviceService = context.getServiceImpl(IDeviceService.class);
Pankaj Berde00e90882013-06-10 21:25:05 -0700413 linkDiscovery = context.getServiceImpl(ILinkDiscoveryService.class);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700414 threadPool = context.getServiceImpl(IThreadPoolService.class);
415 registryService = context.getServiceImpl(IControllerRegistryService.class);
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700416 datagridService = context.getServiceImpl(IDatagridService.class);
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800417
Pavlin Radoslavovc0aa4bf2014-03-26 18:32:49 -0700418 log.debug("Initializing OldNetworkGraphPublisher module with {}", conf);
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800419
Pankaj Berdeda809572013-02-22 15:31:20 -0800420 }
421
422 @Override
423 public void startUp(FloodlightModuleContext context) {
Pavlin Radoslavov697f6982014-03-26 15:55:19 -0700424 /*
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700425 Map<String, String> configMap = context.getConfigParams(this);
426 String cleanupNeeded = configMap.get(CleanupEnabled);
427
Jonathan Hartd857ad62013-12-14 18:08:17 -0800428 //deviceService.addListener(this);
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700429 floodlightProvider.addOFSwitchListener(this);
Pankaj Berde00e90882013-06-10 21:25:05 -0700430 linkDiscovery.addListener(this);
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800431
Pankaj Berde9d6b5072013-04-03 11:51:23 -0700432 log.debug("Adding EventListener");
Toshio Koide70ba38b2013-06-13 14:05:05 -0700433 IDBConnection conn = op.getDBConnection();
yoshi2fd4c7e2013-11-22 15:47:55 -0800434 conn.addEventListener(new LocalTopologyEventListener((DBConnection) conn));
Yuta HIGUCHI3ab1fd02013-12-17 11:01:02 -0800435 // Setup the Cleanup task.
Pankaj Berde99fcee12013-03-18 09:41:53 -0700436 if (cleanupNeeded == null || !cleanupNeeded.equals("False")) {
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700437 ScheduledExecutorService ses = threadPool.getScheduledExecutor();
438 cleanupTask = new SingletonTask(ses, new SwitchCleanup());
Pankaj Berde99fcee12013-03-18 09:41:53 -0700439 cleanupTask.reschedule(CLEANUP_TASK_INTERVAL, TimeUnit.SECONDS);
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700440 }
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700441
442 //
443 // NOTE: No need to register with the Datagrid Service,
444 // because we don't need to receive any notifications from it.
445 //
Pavlin Radoslavov697f6982014-03-26 15:55:19 -0700446 */
Pankaj Berdeda809572013-02-22 15:31:20 -0800447 }
448
449}