Skip to content
Snippets Groups Projects
Commit 96b67018 authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

Topology recompute task now runs every half a second.

parent 33472a60
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,8 @@ public class TopologyManager implements
*/
protected boolean dtLinksUpdated;
protected final int TOPOLOGY_COMPUTE_INTERVAL_MS = 500;
/**
* Thread for recomputing topology. The thread is always running,
* however the function applyUpdates() has a blocking call.
......@@ -133,10 +135,15 @@ public class TopologyManager implements
@Override
public void run() {
try {
updateTopology();
if (ldUpdates.peek() != null)
updateTopology();
}
catch (Exception e) {
log.error("Error in topology instance task thread", e);
} finally {
if (floodlightProvider.getRole() != Role.SLAVE)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
}
}
}
......@@ -158,20 +165,10 @@ public class TopologyManager implements
@Override
public void linkDiscoveryUpdate(LDUpdate update) {
boolean scheduleFlag = false;
// if there's no udpates in the queue, then
// we need to schedule an update.
if (ldUpdates.peek() == null)
scheduleFlag = true;
if (log.isTraceEnabled()) {
log.trace("Queuing update: {}", update);
}
ldUpdates.add(update);
if (scheduleFlag) {
newInstanceTask.reschedule(1, TimeUnit.MICROSECONDS);
}
}
// ****************
......@@ -582,12 +579,14 @@ public class TopologyManager implements
if (oldRole == Role.SLAVE) {
log.debug("Re-computing topology due " +
"to HA change from SLAVE->MASTER");
newInstanceTask.reschedule(1, TimeUnit.MILLISECONDS);
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
}
break;
case SLAVE:
log.debug("Clearing topology due to " +
"HA change to SLAVE");
ldUpdates.clear();
clearCurrentTopology();
break;
default:
......@@ -666,6 +665,11 @@ public class TopologyManager implements
public void startUp(FloodlightModuleContext context) {
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (floodlightProvider.getRole() != Role.SLAVE)
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
TimeUnit.MILLISECONDS);
linkDiscovery.addListener(this);
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProvider.addHAListener(this);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment