fixed #229: handling rapid switch flapping race conditions gracefully
diff --git a/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java b/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
index c6fe108..9cb1c4f 100644
--- a/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
+++ b/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
@@ -48,7 +48,7 @@
protected static final String CleanupEnabled = "EnableCleanup";
protected IThreadPoolService threadPool;
- protected final int CLEANUP_TASK_INTERVAL = 999; // 999 ms
+ protected final int CLEANUP_TASK_INTERVAL = 10; // 10 sec
protected SingletonTask cleanupTask;
/**
@@ -65,7 +65,7 @@
log.error("Error in cleanup thread", e);
} finally {
cleanupTask.reschedule(CLEANUP_TASK_INTERVAL,
- TimeUnit.MILLISECONDS);
+ TimeUnit.SECONDS);
}
}
@@ -74,7 +74,7 @@
// TODO Auto-generated method stub
if (hasControl) {
- log.debug("got control to set inactive sw {}", dpid);
+ log.debug("got control to set inactive sw {}", HexString.toHexString(dpid));
swStore.update(HexString.toHexString(dpid),SwitchState.INACTIVE, DM_OPERATION.UPDATE);
registryService.releaseControl(dpid);
}
@@ -94,10 +94,10 @@
long dpid = HexString.toLong(sw.getDPID());
String controller = registryService.getControllerForSwitch(dpid);
if (controller == null) {
- log.debug("request Control to set inactive sw {}", dpid);
+ log.debug("request Control to set inactive sw {}", HexString.toHexString(dpid));
registryService.requestControl(dpid, new SwitchCleanup());
} else {
- log.debug("sw {} is controlled by controller: {}",dpid,controller);
+ log.debug("sw {} is controlled by controller: {}",HexString.toHexString(dpid),controller);
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
@@ -223,10 +223,10 @@
deviceService.addListener(this);
// Setup the Cleanup task.
- if (cleanupNeeded != null &&cleanupNeeded.equals("True")) {
+ if (cleanupNeeded == null || !cleanupNeeded.equals("False")) {
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
cleanupTask = new SingletonTask(ses, new SwitchCleanup());
- cleanupTask.reschedule(CLEANUP_TASK_INTERVAL, TimeUnit.MILLISECONDS);
+ cleanupTask.reschedule(CLEANUP_TASK_INTERVAL, TimeUnit.SECONDS);
}
}