BUG 3340 : Log the count of modifications on a given transaction context 16/21916/1
authorMoiz Raja <moraja@cisco.com>
Thu, 4 Jun 2015 18:40:57 +0000 (11:40 -0700)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 5 Jun 2015 01:44:21 +0000 (01:44 +0000)
This log statement is to give a quick summary count - I found it useful for
debugging

Change-Id: I5ec2cb13fb75182bc94b3728188378fae2e55b43
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 48df31d5e46dd06aa97bb2ab0c0def2d28ed491d)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java

index 81605d8..df478b0 100644 (file)
@@ -8,9 +8,15 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 abstract class AbstractTransactionContext implements TransactionContext {
 
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractTransactionContext.class);
+
+    private long modificationCount = 0;
+
     private final TransactionIdentifier identifier;
 
     protected AbstractTransactionContext(TransactionIdentifier identifier) {
@@ -20,4 +26,12 @@ abstract class AbstractTransactionContext implements TransactionContext {
     protected final TransactionIdentifier getIdentifier() {
         return identifier;
     }
+
+    protected void incrementModificationCount(){
+        modificationCount++;
+    }
+
+    protected void logModificationCount(){
+        LOG.debug("Total modifications on Tx {} = [ {} ]", identifier, modificationCount);
+    }
 }
\ No newline at end of file
index e72c8a3..3648b97 100644 (file)
@@ -44,18 +44,21 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
 
     @Override
     public void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+        incrementModificationCount();
         getWriteDelegate().write(path, data);
         completer.onComplete(null, null);
     }
 
     @Override
     public void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+        incrementModificationCount();
         getWriteDelegate().merge(path, data);
         completer.onComplete(null, null);
     }
 
     @Override
     public void deleteData(YangInstanceIdentifier path) {
+        incrementModificationCount();
         getWriteDelegate().delete(path);
         completer.onComplete(null, null);
     }
@@ -95,6 +98,7 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
     }
 
     private LocalThreePhaseCommitCohort ready() {
+        logModificationCount();
         LocalThreePhaseCommitCohort ready = (LocalThreePhaseCommitCohort) getWriteDelegate().ready();
         completer.onComplete(null, null);
         return ready;
index a25ddc8..7429ca0 100644 (file)
@@ -107,6 +107,8 @@ public class RemoteTransactionContext extends AbstractTransactionContext {
 
     @Override
     public Future<ActorSelection> readyTransaction() {
+        logModificationCount();
+
         LOG.debug("Tx {} readyTransaction called", getIdentifier());
 
         // Send the remaining batched modifications, if any, with the ready flag set.
@@ -128,6 +130,7 @@ public class RemoteTransactionContext extends AbstractTransactionContext {
     }
 
     private void batchModification(Modification modification) {
+        incrementModificationCount();
         if(batchedModifications == null) {
             batchedModifications = newBatchedModifications();
         }