blob: 14cffd8a1b41b48e9cfdad7fcf4faff3062c08f7 [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;
Pavlin Radoslavov28069402013-10-18 18:43:11 -07005import java.util.HashMap;
Pankaj Berdeda809572013-02-22 15:31:20 -08006import java.util.Map;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -07007import java.util.concurrent.ScheduledExecutorService;
8import java.util.concurrent.TimeUnit;
Pankaj Berdeda809572013-02-22 15:31:20 -08009
Pankaj Berde465ac7c2013-05-23 13:47:49 -070010import org.openflow.protocol.OFPhysicalPort;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070011import org.openflow.util.HexString;
Pankaj Berdeda809572013-02-22 15:31:20 -080012import org.slf4j.Logger;
13import org.slf4j.LoggerFactory;
14
15import net.floodlightcontroller.core.IFloodlightProviderService;
16import net.floodlightcontroller.core.IOFSwitch;
17import net.floodlightcontroller.core.IOFSwitchListener;
Pankaj Berdeda809572013-02-22 15:31:20 -080018import net.floodlightcontroller.core.module.FloodlightModuleContext;
19import net.floodlightcontroller.core.module.FloodlightModuleException;
20import net.floodlightcontroller.core.module.IFloodlightModule;
21import net.floodlightcontroller.core.module.IFloodlightService;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070022import net.floodlightcontroller.core.util.SingletonTask;
Pankaj Berdeda809572013-02-22 15:31:20 -080023import net.floodlightcontroller.devicemanager.IDevice;
24import net.floodlightcontroller.devicemanager.IDeviceListener;
25import net.floodlightcontroller.devicemanager.IDeviceService;
Pankaj Berde00e90882013-06-10 21:25:05 -070026import net.floodlightcontroller.routing.Link;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070027import net.floodlightcontroller.threadpool.IThreadPoolService;
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070028
29import net.onrc.onos.datagrid.IDatagridService;
Pankaj Berde38646d62013-06-21 11:34:04 -070030import net.onrc.onos.graph.GraphDBConnection;
31import net.onrc.onos.graph.GraphDBOperation;
32import net.onrc.onos.graph.IDBConnection;
33import net.onrc.onos.graph.LocalTopologyEventListener;
HIGUCHI Yuta2d011582013-06-15 01:47:11 -070034import net.onrc.onos.ofcontroller.core.IDeviceStorage;
35import net.onrc.onos.ofcontroller.core.ILinkStorage;
HIGUCHI Yuta36cf0762013-06-14 14:25:38 -070036import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
HIGUCHI Yuta20514902013-06-12 11:24:16 -070037import net.onrc.onos.ofcontroller.core.ISwitchStorage;
38import net.onrc.onos.ofcontroller.core.INetMapStorage.DM_OPERATION;
HIGUCHI Yuta20514902013-06-12 11:24:16 -070039import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
40import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
HIGUCHI Yuta2d011582013-06-15 01:47:11 -070041import net.onrc.onos.ofcontroller.core.internal.DeviceStorageImpl;
42import net.onrc.onos.ofcontroller.core.internal.LinkStorageImpl;
HIGUCHI Yutaed49ef72013-06-12 11:34:10 -070043import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
HIGUCHI Yutaa56fbde2013-06-17 14:26:05 -070044import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryListener;
45import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
Naoki Shiotab2d17e82013-10-18 18:08:16 -070046import net.onrc.onos.ofcontroller.linkdiscovery.LinkInfo;
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070047import net.onrc.onos.ofcontroller.topology.TopologyElement;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070048import net.onrc.onos.registry.controller.IControllerRegistryService;
49import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
50import net.onrc.onos.registry.controller.RegistryException;
Pankaj Berdeda809572013-02-22 15:31:20 -080051
Pavlin Radoslavov28069402013-10-18 18:43:11 -070052public class NetworkGraphPublisher implements IDeviceListener,
53 IOFSwitchListener,
54 IOFSwitchPortListener,
55 ILinkDiscoveryListener,
56 IFloodlightModule,
57 INetworkGraphService {
Pankaj Berdeda809572013-02-22 15:31:20 -080058
59 protected IDeviceStorage devStore;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070060 protected ISwitchStorage swStore;
Pankaj Berde00e90882013-06-10 21:25:05 -070061 protected ILinkStorage linkStore;
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070062 protected final static Logger log = LoggerFactory.getLogger(NetworkGraphPublisher.class);
Pankaj Berdeda809572013-02-22 15:31:20 -080063 protected IDeviceService deviceService;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070064 protected IControllerRegistryService registryService;
Toshio Koide70ba38b2013-06-13 14:05:05 -070065 protected GraphDBOperation op;
Pankaj Berdeda809572013-02-22 15:31:20 -080066
67 protected static final String DBConfigFile = "dbconf";
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -070068 protected static final String CleanupEnabled = "EnableCleanup";
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070069 protected IThreadPoolService threadPool;
Pankaj Berde465ac7c2013-05-23 13:47:49 -070070 protected IFloodlightProviderService floodlightProvider;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070071
Pankaj Berde62016142013-04-09 15:35:50 -070072 protected final int CLEANUP_TASK_INTERVAL = 60; // 1 min
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070073 protected SingletonTask cleanupTask;
Pankaj Berde00e90882013-06-10 21:25:05 -070074 protected ILinkDiscoveryService linkDiscovery;
Pavlin Radoslavov8442e492013-10-25 21:54:13 -070075
76 protected IDatagridService datagridService;
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070077
78 /**
79 * Cleanup and synch switch state from registry
80 */
81 protected class SwitchCleanup implements ControlChangeCallback, Runnable {
82 @Override
83 public void run() {
84 try {
85 log.debug("Running cleanup thread");
86 switchCleanup();
87 }
88 catch (Exception e) {
89 log.error("Error in cleanup thread", e);
90 } finally {
Toshio Koide70ba38b2013-06-13 14:05:05 -070091 op.close();
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070092 cleanupTask.reschedule(CLEANUP_TASK_INTERVAL,
Pankaj Berde99fcee12013-03-18 09:41:53 -070093 TimeUnit.SECONDS);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070094 }
95 }
96
97 @Override
98 public void controlChanged(long dpid, boolean hasControl) {
Pankaj Berdef08d5ff2013-03-14 17:03:07 -070099 if (hasControl) {
Pankaj Berde99fcee12013-03-18 09:41:53 -0700100 log.debug("got control to set inactive sw {}", HexString.toHexString(dpid));
Naoki Shiota987a5722013-10-23 11:59:36 -0700101 try {
102 if (swStore.updateSwitch(HexString.toHexString(dpid), SwitchState.INACTIVE, DM_OPERATION.UPDATE)) {
103 registryService.releaseControl(dpid);
104
105 // TODO publish UPDATE_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700106 //
107 // NOTE: Here we explicitly send
108 // notification to remove the
109 // switch, because it is inactive
110 //
111 TopologyElement topologyElement =
112 new TopologyElement(dpid);
113 datagridService.notificationSendTopologyElementRemoved(topologyElement);
114
Naoki Shiota987a5722013-10-23 11:59:36 -0700115 }
116 } catch (Exception e) {
117 log.error("Error in SwitchCleanup:controlChanged ", e);
118 }
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700119 }
120 }
121 }
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700122
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700123 protected void switchCleanup() {
Toshio Koide70ba38b2013-06-13 14:05:05 -0700124 op.close();
125 Iterable<ISwitchObject> switches = op.getActiveSwitches();
Jonathan Hartf02a0932013-03-18 18:30:48 -0700126
127 log.debug("Checking for inactive switches");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700128 // For each switch check if a controller exists in controller registry
129 for (ISwitchObject sw: switches) {
Jonathan Hartf02a0932013-03-18 18:30:48 -0700130 //log.debug("checking if switch is inactive: {}", sw.getDPID());
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700131 try {
132 long dpid = HexString.toLong(sw.getDPID());
133 String controller = registryService.getControllerForSwitch(dpid);
134 if (controller == null) {
Pankaj Berde99fcee12013-03-18 09:41:53 -0700135 log.debug("request Control to set inactive sw {}", HexString.toHexString(dpid));
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700136 registryService.requestControl(dpid, new SwitchCleanup());
Umesh Krishnaswamy255b9882013-04-02 19:55:43 -0700137 //} else {
138 // log.debug("sw {} is controlled by controller: {}",HexString.toHexString(dpid),controller);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700139 }
140 } catch (NumberFormatException e) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700141 log.debug("Caught NumberFormatException trying to requestControl in cleanup thread");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700142 e.printStackTrace();
143 } catch (RegistryException e) {
Jonathan Hart4baf3be2013-03-21 18:26:13 -0700144 log.debug("Caught RegistryException trying to requestControl in cleanup thread");
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700145 e.printStackTrace();
Naoki Shiota987a5722013-10-23 11:59:36 -0700146 }
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700147 }
Toshio Koide70ba38b2013-06-13 14:05:05 -0700148 op.close();
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700149 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800150
151 @Override
152 public void linkDiscoveryUpdate(LDUpdate update) {
Pankaj Berde00e90882013-06-10 21:25:05 -0700153 Link lt = new Link(update.getSrc(),update.getSrcPort(),update.getDst(),update.getDstPort());
Jonathan Harte7c2d2f2013-07-27 18:08:34 +1200154 //log.debug("{}:LinkDicoveryUpdate(): Updating Link {}",this.getClass(), lt);
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700155
Jonathan Harte7c2d2f2013-07-27 18:08:34 +1200156 switch (update.getOperation()) {
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700157 case LINK_REMOVED:
Jonathan Harte7c2d2f2013-07-27 18:08:34 +1200158 log.debug("LinkDiscoveryUpdate(): Removing link {}", lt);
Naoki Shiota987a5722013-10-23 11:59:36 -0700159
160 if (linkStore.deleteLink(lt)) {
161 // TODO publish DELETE_LINK event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700162 TopologyElement topologyElement =
163 new TopologyElement(update.getSrc(),
164 update.getSrcPort(),
165 update.getDst(),
166 update.getDstPort());
167 datagridService.notificationSendTopologyElementRemoved(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700168 }
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700169 break;
Pankaj Berde00e90882013-06-10 21:25:05 -0700170 case LINK_UPDATED:
Jonathan Harte7c2d2f2013-07-27 18:08:34 +1200171 log.debug("LinkDiscoveryUpdate(): Updating link {}", lt);
Naoki Shiota987a5722013-10-23 11:59:36 -0700172
Naoki Shiotab2d17e82013-10-18 18:08:16 -0700173 LinkInfo linfo = linkStore.getLinkInfo(lt);
174 // TODO update "linfo" using portState derived using "update"
Naoki Shiota987a5722013-10-23 11:59:36 -0700175 if (linkStore.update(lt, linfo, DM_OPERATION.UPDATE)) {
176 // TODO publish UPDATE_LINK event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700177 //
178 // TODO NOTE: Here we assume that updated
179 // link is UP.
180 //
181 TopologyElement topologyElement =
182 new TopologyElement(update.getSrc(),
183 update.getSrcPort(),
184 update.getDst(),
185 update.getDstPort());
186 datagridService.notificationSendTopologyElementUpdated(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700187 }
Pankaj Berde00e90882013-06-10 21:25:05 -0700188 break;
189 case LINK_ADDED:
Jonathan Harte7c2d2f2013-07-27 18:08:34 +1200190 log.debug("LinkDiscoveryUpdate(): Adding link {}", lt);
Naoki Shiota987a5722013-10-23 11:59:36 -0700191
192 if (linkStore.addLink(lt)) {
193 // TODO publish ADD_LINK event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700194 TopologyElement topologyElement =
195 new TopologyElement(update.getSrc(),
196 update.getSrcPort(),
197 update.getDst(),
198 update.getDstPort());
199 datagridService.notificationSendTopologyElementAdded(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700200 }
Pankaj Berde00e90882013-06-10 21:25:05 -0700201 break;
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700202 default:
203 break;
204 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800205
206 }
207
208 @Override
209 public void addedSwitch(IOFSwitch sw) {
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700210 if (registryService.hasControl(sw.getId())) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700211 if (swStore.addSwitch(sw)) {
212 // TODO publish ADD_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700213 TopologyElement topologyElement =
214 new TopologyElement(sw.getId());
215 // TODO: Add only ports that are UP?
216 for (OFPhysicalPort port : sw.getPorts()) {
217 topologyElement.addSwitchPort(port.getPortNumber());
218 }
219 datagridService.notificationSendTopologyElementAdded(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700220 }
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700221 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800222 }
223
224 @Override
225 public void removedSwitch(IOFSwitch sw) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700226 if (registryService.hasControl(sw.getId())) {
227 if (swStore.deleteSwitch(sw.getStringId())) {
228 // TODO publish DELETE_SWITCH event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700229 TopologyElement topologyElement =
230 new TopologyElement(sw.getId());
231 datagridService.notificationSendTopologyElementRemoved(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700232 }
233 }
Pankaj Berdeda809572013-02-22 15:31:20 -0800234 }
235
236 @Override
237 public void switchPortChanged(Long switchId) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700238 // NOTE: Event not needed here. This callback always coincide with add/remove callback.
Pankaj Berdeda809572013-02-22 15:31:20 -0800239 }
240
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700241
242 @Override
243 public void switchPortAdded(Long switchId, OFPhysicalPort port) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700244 if (swStore.addPort(HexString.toHexString(switchId), port)) {
245 // TODO publish ADD_PORT event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700246 TopologyElement topologyElement =
247 new TopologyElement(switchId, port.getPortNumber());
248 datagridService.notificationSendTopologyElementAdded(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700249 }
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700250 }
251
252 @Override
253 public void switchPortRemoved(Long switchId, OFPhysicalPort port) {
Naoki Shiota987a5722013-10-23 11:59:36 -0700254 if (swStore.deletePort(HexString.toHexString(switchId), port.getPortNumber())) {
255 // TODO publish DELETE_PORT event here
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700256 TopologyElement topologyElement =
257 new TopologyElement(switchId, port.getPortNumber());
258 datagridService.notificationSendTopologyElementRemoved(topologyElement);
Naoki Shiota987a5722013-10-23 11:59:36 -0700259 }
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700260 }
261
Pankaj Berdeda809572013-02-22 15:31:20 -0800262 @Override
263 public String getName() {
HIGUCHI Yuta155cfc52013-06-14 15:54:16 -0700264 return "NetworkGraphPublisher";
Pankaj Berdeda809572013-02-22 15:31:20 -0800265 }
266
267 @Override
268 public void deviceAdded(IDevice device) {
Pankaj Berdeda809572013-02-22 15:31:20 -0800269 log.debug("{}:deviceAdded(): Adding device {}",this.getClass(),device.getMACAddressString());
270 devStore.addDevice(device);
271 }
272
273 @Override
274 public void deviceRemoved(IDevice device) {
275 // TODO Auto-generated method stub
Pankaj Berdeda809572013-02-22 15:31:20 -0800276 }
277
278 @Override
279 public void deviceMoved(IDevice device) {
Pankaj Berdeda809572013-02-22 15:31:20 -0800280 devStore.changeDeviceAttachments(device);
Pankaj Berdeda809572013-02-22 15:31:20 -0800281 }
282
283 @Override
284 public void deviceIPV4AddrChanged(IDevice device) {
Pankaj Berdeda809572013-02-22 15:31:20 -0800285 devStore.changeDeviceIPv4Address(device);
Pankaj Berdeda809572013-02-22 15:31:20 -0800286 }
287
288 @Override
289 public void deviceVlanChanged(IDevice device) {
290 // TODO Auto-generated method stub
291 }
292
293
294 @Override
295 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
Pavlin Radoslavov28069402013-10-18 18:43:11 -0700296 Collection<Class<? extends IFloodlightService>> l =
297 new ArrayList<Class<? extends IFloodlightService>>();
298 l.add(INetworkGraphService.class);
299 return l;
Pankaj Berdeda809572013-02-22 15:31:20 -0800300 }
301
302 @Override
303 public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
Pavlin Radoslavov28069402013-10-18 18:43:11 -0700304 Map<Class<? extends IFloodlightService>,
305 IFloodlightService> m =
306 new HashMap<Class<? extends IFloodlightService>,
307 IFloodlightService>();
308 m.put(INetworkGraphService.class, this);
309 return m;
Pankaj Berdeda809572013-02-22 15:31:20 -0800310 }
311
312 @Override
313 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
314 Collection<Class<? extends IFloodlightService>> l =
315 new ArrayList<Class<? extends IFloodlightService>>();
316 l.add(IFloodlightProviderService.class);
317 l.add(IDeviceService.class);
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700318 l.add(IDatagridService.class);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700319 l.add(IThreadPoolService.class);
Pankaj Berdeda809572013-02-22 15:31:20 -0800320 return l;
321 }
322
323 @Override
324 public void init(FloodlightModuleContext context)
325 throws FloodlightModuleException {
Pankaj Berdeda809572013-02-22 15:31:20 -0800326 Map<String, String> configMap = context.getConfigParams(this);
327 String conf = configMap.get(DBConfigFile);
Toshio Koidebfe9b922013-06-18 10:56:05 -0700328 op = new GraphDBOperation(conf);
Pankaj Berdeda809572013-02-22 15:31:20 -0800329
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700330 floodlightProvider =
331 context.getServiceImpl(IFloodlightProviderService.class);
Pankaj Berdeda809572013-02-22 15:31:20 -0800332 deviceService = context.getServiceImpl(IDeviceService.class);
Pankaj Berde00e90882013-06-10 21:25:05 -0700333 linkDiscovery = context.getServiceImpl(ILinkDiscoveryService.class);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700334 threadPool = context.getServiceImpl(IThreadPoolService.class);
335 registryService = context.getServiceImpl(IControllerRegistryService.class);
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700336 datagridService = context.getServiceImpl(IDatagridService.class);
Pankaj Berdeda809572013-02-22 15:31:20 -0800337
Pankaj Berdeda809572013-02-22 15:31:20 -0800338 devStore = new DeviceStorageImpl();
339 devStore.init(conf);
340
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700341 swStore = new SwitchStorageImpl();
342 swStore.init(conf);
Pankaj Berde00e90882013-06-10 21:25:05 -0700343
344 linkStore = new LinkStorageImpl();
345 linkStore.init(conf);
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700346
HIGUCHI Yuta155cfc52013-06-14 15:54:16 -0700347 log.debug("Initializing NetworkGraphPublisher module with {}", conf);
Pankaj Berdeda809572013-02-22 15:31:20 -0800348
349 }
350
351 @Override
352 public void startUp(FloodlightModuleContext context) {
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700353 Map<String, String> configMap = context.getConfigParams(this);
354 String cleanupNeeded = configMap.get(CleanupEnabled);
355
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700356 deviceService.addListener(this);
Pankaj Berde465ac7c2013-05-23 13:47:49 -0700357 floodlightProvider.addOFSwitchListener(this);
Pankaj Berde00e90882013-06-10 21:25:05 -0700358 linkDiscovery.addListener(this);
Pankaj Berde9d6b5072013-04-03 11:51:23 -0700359
360 log.debug("Adding EventListener");
Toshio Koide70ba38b2013-06-13 14:05:05 -0700361 IDBConnection conn = op.getDBConnection();
362 conn.addEventListener(new LocalTopologyEventListener((GraphDBConnection) conn));
Pankaj Berdef08d5ff2013-03-14 17:03:07 -0700363 // Setup the Cleanup task.
Pankaj Berde99fcee12013-03-18 09:41:53 -0700364 if (cleanupNeeded == null || !cleanupNeeded.equals("False")) {
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700365 ScheduledExecutorService ses = threadPool.getScheduledExecutor();
366 cleanupTask = new SingletonTask(ses, new SwitchCleanup());
Pankaj Berde99fcee12013-03-18 09:41:53 -0700367 cleanupTask.reschedule(CLEANUP_TASK_INTERVAL, TimeUnit.SECONDS);
Pankaj Berde1e3e5ba2013-03-15 13:17:53 -0700368 }
Pavlin Radoslavov8442e492013-10-25 21:54:13 -0700369
370 //
371 // NOTE: No need to register with the Datagrid Service,
372 // because we don't need to receive any notifications from it.
373 //
Pankaj Berdeda809572013-02-22 15:31:20 -0800374 }
375
376}