BUG-8618: improve logging 14/60414/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Jul 2017 15:30:43 +0000 (17:30 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 15 Jul 2017 08:47:56 +0000 (08:47 +0000)
While target sequence is important, we also need to log transmit
sequence, too.

Since this issue involves a state mismatch on the backend, improve
ShardDataTreeCohort logging to include transaction identifier
and state.

Change-Id: I21735870a9ae7983dc14a8f8f4d7464d3448ca60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d2d9179e52a0d87aae2b9014b4c36384e24692e3)

opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/SimpleShardDataTreeCohort.java

index 33e0c56..3587045 100644 (file)
@@ -225,8 +225,8 @@ public abstract class ClientActorBehavior<T extends BackendInfo> extends
                 // Already reconnecting, do not churn the logs
                 return this;
             } else if (conn != null) {
-                LOG.info("{}: connection {} indicated no sequencing mismatch on {} sequence {}, reconnecting it",
-                    persistenceId(), conn, failure.getTarget(), failure.getSequence(), cause);
+                LOG.info("{}: connection {} indicated sequencing mismatch on {} sequence {} ({}), reconnecting it",
+                    persistenceId(), conn, failure.getTarget(), failure.getSequence(), command.getTxSequence(), cause);
                 return conn.reconnect(this, cause);
             }
         }
index 6cb9bad..d989cbf 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -57,4 +59,13 @@ public abstract class ShardDataTreeCohort implements Identifiable<TransactionIde
     public abstract boolean isFailed();
 
     public abstract State getState();
+
+    @Override
+    public final String toString() {
+        return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
+    }
+
+    ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return toStringHelper.add("id", getIdentifier()).add("state", getState());
+    }
 }
index b9e3997..6c159b1 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.dispatch.ExecutionContexts;
 import akka.dispatch.Futures;
 import akka.dispatch.OnComplete;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.primitives.UnsignedLong;
@@ -40,6 +41,11 @@ abstract class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
         void throwCanCommitFailure() throws Exception {
             throw failure;
         }
+
+        @Override
+        ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+            return super.addToStringAttributes(toStringHelper).add("failure", failure);
+        }
     }
 
     static final class Normal extends SimpleShardDataTreeCohort {
@@ -261,4 +267,9 @@ abstract class SimpleShardDataTreeCohort extends ShardDataTreeCohort {
     public boolean isFailed() {
         return state == State.FAILED || nextFailure != null;
     }
+
+    @Override
+    ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return super.addToStringAttributes(toStringHelper).add("nextFailure", nextFailure);
+    }
 }

©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.