Merge "Split off tracking of node presence"
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / NodeStatisticsHandler.java
index 6d0b5ea0e31bdb75046ff157071a4ded54bfcaa7..e9cecc521e2c8f24f828019dca70d4652ffdbf45 100644 (file)
@@ -103,7 +103,7 @@ import com.google.common.base.Preconditions;
  *
  * @author avishnoi@in.ibm.com
  */
-public class NodeStatisticsHandler {
+public class NodeStatisticsHandler implements AutoCloseable {
     private static final Logger logger = LoggerFactory.getLogger(NodeStatisticsHandler.class);
     private static final int NUMBER_OF_WAIT_CYCLES = 2;
 
@@ -122,7 +122,7 @@ public class NodeStatisticsHandler {
         this.targetNodeIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey).build();
     }
 
-    public class FlowEntry {
+    private static class FlowEntry {
         private final Short tableId;
         private final Flow flow;
 
@@ -143,7 +143,6 @@ public class NodeStatisticsHandler {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + getOuterType().hashCode();
             result = prime * result + ((flow == null) ? 0 : flow.hashCode());
             result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
             return result;
@@ -158,8 +157,6 @@ public class NodeStatisticsHandler {
             if (getClass() != obj.getClass())
                 return false;
             FlowEntry other = (FlowEntry) obj;
-            if (!getOuterType().equals(other.getOuterType()))
-                return false;
             if (flow == null) {
                 if (other.flow != null)
                     return false;
@@ -172,10 +169,6 @@ public class NodeStatisticsHandler {
                 return false;
             return true;
         }
-
-        private NodeStatisticsHandler getOuterType() {
-            return NodeStatisticsHandler.this;
-        }
     }
 
     private static final class QueueEntry{
@@ -774,4 +767,10 @@ public class NodeStatisticsHandler {
         InstanceIdentifier<?> nodeGroupStatisticsAugmentation = groupRef.augmentation(NodeGroupStatistics.class).toInstance();
         trans.removeOperationalData(nodeGroupStatisticsAugmentation);
     }
+
+    @Override
+    public void close() {
+        // FIXME: cleanup any resources we hold (registrations, etc.)
+        logger.debug("Statistics handler for {} shut down", targetNodeKey.getId());
+    }
 }