Add AbstractDOMBrokerTransaction.toString() 00/68400/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 23 Jan 2018 18:13:10 +0000 (19:13 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 19 Feb 2018 10:38:12 +0000 (10:38 +0000)
It is quite common for applications to mis-synchronize transaction
chain closure, which may lead to stale transactions. Unfortunately
the message produced in such situations:

2017-12-21 14:21:56,008 | ERROR | CommitFutures-48 | ExecutionList                    | 38 - com.google.guava - 18.0.0 | RuntimeException while executing runnable com.google.common.util.concurrent.Futures$6@6d954ae with executor INSTANCE
java.lang.IllegalStateException: Attempted to close chain with outstanding transaction PingPongTransaction{delegate=org.opendaylight.controller.cluster.databroker.DOMBrokerReadWriteTransaction@7523c916}

does not give us enough information to correlate the impact of such
failures.

Add AbstractDOMBrokerTransaction.toString(), which results
in the message having actual transaction identifier, so that these
failures can be correlated.

Change-Id: Id4620df4285ec6d3ba24bbcd8f5ab8c1a29e0687
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransaction.java

index 800460c..180623e 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.controller.cluster.databroker;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.EnumMap;
@@ -105,4 +107,13 @@ public abstract class AbstractDOMBrokerTransaction<T extends DOMStoreTransaction
     protected DOMStoreTransactionFactory getTxFactory(LogicalDatastoreType type) {
         return storeTxFactories.get(type);
     }
+
+    @Override
+    public final String toString() {
+        return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
+    }
+
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return toStringHelper.add("identifier", identifier);
+    }
 }
index cfc6c28..7d519ba 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.cluster.databroker;
 
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -159,4 +160,8 @@ public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteT
         Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
     }
 
+    @Override
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return super.addToStringAttributes(toStringHelper).add("running", commitImpl == null);
+    }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.