}
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
// To be started by the first switch connection
discoveryTask = new SingletonTask(ses, new Runnable() {
@Override
public void run() {
try {
discoverLinks();
} catch (StorageException e) {
log.error("Storage exception in LLDP send timer; "
+ "terminating process", e);
floodlightProvider.terminate();
} catch (Exception e) {
log.error("Exception in LLDP send timer.", e);
} finally {
if (!shuttingDown) {
// null role implies HA mode is not enabled.
if (role == null || role == Role.MASTER) {
log.trace("Rescheduling discovery task as role = {}",
role);
discoveryTask.reschedule(DISCOVERY_TASK_INTERVAL,
TimeUnit.SECONDS);
} else {
log.trace("Stopped LLDP rescheduling due to role = {}.",
role);
}
}
}
}
});
// null role implies HA mode is not enabled.
if (role == null || role == Role.MASTER) {
log.trace("Setup: Rescheduling discovery task. role = {}", role);
discoveryTask.reschedule(DISCOVERY_TASK_INTERVAL,
TimeUnit.SECONDS);
} else {
log.trace("Setup: Not scheduling LLDP as role = {}.", role);
}
// Setup the BDDP task. It is invoked whenever switch port tuples
// are added to the quarantine list.
bddpTask = new SingletonTask(ses, new QuarantineWorker());
bddpTask.reschedule(BDDP_TASK_INTERVAL, TimeUnit.MILLISECONDS);
updatesThread = new Thread(new Runnable() {
@Override
public void run() {