BUG-4514: clear destroyed modules
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / DeadlockMonitor.java
index d34a739703e8f8eba7d60a90ca6fa713a301f802..e3fbcd0edb97d0b55b91e01b7804539ff04ea30d 100644 (file)
@@ -1,17 +1,24 @@
-package org.opendaylight.controller.config.manager.impl;
+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.opendaylight.controller.config.manager.impl;
 
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.GuardedBy;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DeadlockMonitor implements AutoCloseable {
-    private static final Logger logger = LoggerFactory.getLogger(DeadlockMonitorRunnable.class);
+    private static final Logger LOG = LoggerFactory.getLogger(DeadlockMonitor.class);
 
     private static final long WARN_AFTER_MILLIS = 5000;
 
@@ -43,7 +50,7 @@ public class DeadlockMonitor implements AutoCloseable {
             moduleIdentifierWithNanosStack.push(current);
             top = current;
         }
-        logger.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
+        LOG.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
     }
 
     public boolean isAlive() {
@@ -78,7 +85,7 @@ public class DeadlockMonitor implements AutoCloseable {
                     // is the getInstance() running longer than WARN_AFTER_MILLIS ?
                     long runningTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - copy.nanoTime);
                     if (runningTime > WARN_AFTER_MILLIS) {
-                        logger.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
+                        LOG.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
                     }
                 }
                 try {
@@ -87,7 +94,7 @@ public class DeadlockMonitor implements AutoCloseable {
                     interrupt();
                 }
             }
-            logger.trace("Exiting {}", this);
+            LOG.trace("Exiting {}", this);
         }
 
         @Override
@@ -122,14 +129,21 @@ public class DeadlockMonitor implements AutoCloseable {
 
         @Override
         public boolean equals(Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
 
             ModuleIdentifierWithNanos that = (ModuleIdentifierWithNanos) o;
 
-            if (nanoTime != that.nanoTime) return false;
-            if (moduleIdentifier != null ? !moduleIdentifier.equals(that.moduleIdentifier) : that.moduleIdentifier != null)
+            if (nanoTime != that.nanoTime) {
+                return false;
+            }
+            if (moduleIdentifier != null ? !moduleIdentifier.equals(that.moduleIdentifier) : that.moduleIdentifier != null) {
                 return false;
+            }
 
             return true;
         }