Reduce output from DeadlockMonitor 61/34561/2
authorTom Pantelis <tpanteli@brocade.com>
Fri, 12 Feb 2016 14:56:46 +0000 (09:56 -0500)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 15 Feb 2016 09:32:29 +0000 (09:32 +0000)
If a module doesn't finish after 5 sec, the DeadlockMonitor starts
logging warning messages. However it does this every second. CDS will
wait up to 90 sec for all shards to elect a leader so the
DeadlockMonitor produces a lot of output during this period. To reduce
the noise I changed the sleep to use WARN_AFTER_MILLIS so the message is
logged every 5 sec.

Change-Id: I63842075dee1fc6a4fc4e4200cc089e33a110e78
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java

index e3fbcd0edb97d0b55b91e01b7804539ff04ea30d..9882b4662cce2b75519b509135fd17c961e12e9d 100644 (file)
@@ -77,7 +77,11 @@ public class DeadlockMonitor implements AutoCloseable {
         public void run() {
             ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos(); // null moduleId
             while (this.isInterrupted() == false) {
         public void run() {
             ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos(); // null moduleId
             while (this.isInterrupted() == false) {
-                ModuleIdentifierWithNanos copy = new ModuleIdentifierWithNanos(DeadlockMonitor.this.top);
+                ModuleIdentifierWithNanos copy;
+                synchronized(this) {
+                    copy = new ModuleIdentifierWithNanos(DeadlockMonitor.this.top);
+                }
+
                 if (old.moduleIdentifier == null || old.equals(copy) == false) {
                     // started
                     old = copy;
                 if (old.moduleIdentifier == null || old.equals(copy) == false) {
                     // started
                     old = copy;
@@ -89,7 +93,7 @@ public class DeadlockMonitor implements AutoCloseable {
                     }
                 }
                 try {
                     }
                 }
                 try {
-                    sleep(1000);
+                    sleep(WARN_AFTER_MILLIS);
                 } catch (InterruptedException e) {
                     interrupt();
                 }
                 } catch (InterruptedException e) {
                     interrupt();
                 }