Fix bug 2450 - Statistics collection slow - performance
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / impl / StatAbstractNotifyCommit.java
index 08871e99806c7b51be2480f40b2d50914d96c0f9..3f0e5e430e5db9c8c72098241e2d6e6fa513812f 100644 (file)
@@ -84,9 +84,9 @@ public abstract class StatAbstractNotifyCommit<N extends NotificationListener> i
         return manager.isProvidedFlowNodeActive(nodeIdent);
     }
 
-    protected void notifyToCollectNextStatistics(final InstanceIdentifier<Node> nodeIdent) {
+    protected void notifyToCollectNextStatistics(final InstanceIdentifier<Node> nodeIdent, final TransactionId xid) {
         Preconditions.checkNotNull(nodeIdent, "FlowCapableNode ident can not be null!");
-        manager.collectNextStatistics(nodeIdent);
+        manager.collectNextStatistics(nodeIdent, xid);
     }
 
     /**
@@ -110,6 +110,29 @@ public abstract class StatAbstractNotifyCommit<N extends NotificationListener> i
         return txContainer;
     }
 
+    /**
+     * Method validate TransactionCacheContainer. It needs to call before every txCacheContainer processing.
+     *
+     * @param txCacheContainer
+     * @return
+     */
+    protected boolean isTransactionCacheContainerValid(final Optional<TransactionCacheContainer<?>> txCacheContainer) {
+        if ( ! txCacheContainer.isPresent()) {
+            LOG.debug("Transaction Cache Container is not presented!");
+            return false;
+        }
+        if (txCacheContainer.get().getNodeId() == null) {
+            LOG.debug("Transaction Cache Container {} don't have Node ID!", txCacheContainer.get().getId());
+            return false;
+        }
+        if (txCacheContainer.get().getNotifications() == null) {
+            LOG.debug("Transaction Cache Container {} for {} node don't have Notifications!",
+                    txCacheContainer.get().getId(), txCacheContainer.get().getNodeId());
+            return false;
+        }
+        return true;
+    }
+
     /**
      * Wrapping Future object call to {@link org.opendaylight.controller.md.statistics.manager.StatRpcMsgManager}
      * isExpectedStatistics with 10sec TimeOut.