BUG-8159: add payload debugs 84/54884/5
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Apr 2017 15:59:33 +0000 (17:59 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Thu, 13 Apr 2017 14:49:13 +0000 (14:49 +0000)
This patch adds debugging of metadata snapshot application
and recovery operations.

Change-Id: I9498f53af6ddc8fecf42eb239c7da7da08d3f0c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendClientMetadata.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendHistoryMetadata.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java

index ec2cdb6..a13899c 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Collections2;
@@ -175,4 +176,10 @@ final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
     private FrontendHistoryMetadataBuilder getHistory(final TransactionIdentifier txId) {
         return currentHistories.get(txId.getHistoryId());
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).add("identifier", identifier).add("current", currentHistories)
+                .add("purged", purgedHistories).toString();
+    }
 }
index 5f86125..39d0428 100644 (file)
@@ -48,15 +48,22 @@ final class FrontendMetadata extends ShardDataTreeMetadata<FrontendShardDataTree
 
     @Override
     void reset() {
+        LOG.debug("{}: clearing clients {}", shardName, clients);
         clients.clear();
     }
 
     @Override
     void doApplySnapshot(final FrontendShardDataTreeSnapshotMetadata snapshot) {
+        LOG.debug("{}: applying snapshot {} over clients {}", shardName, snapshot, clients);
         clients.clear();
 
         for (FrontendClientMetadata m : snapshot.getClients()) {
-            clients.put(m.getIdentifier().getFrontendId(), new FrontendClientMetadataBuilder(m));
+            LOG.debug("{}: applying metadata {}", shardName, m);
+            final FrontendClientMetadataBuilder b = new FrontendClientMetadataBuilder(m);
+            final FrontendIdentifier client = m.getIdentifier().getFrontendId();
+
+            LOG.debug("{}: client {} updated to {}", shardName, client, b);
+            clients.put(client, b);
         }
     }
 
index 20cee65..dffb69c 100644 (file)
@@ -409,12 +409,6 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             } else {
                 allMetadataClosedLocalHistory(((CloseLocalHistoryPayload) payload).getIdentifier());
             }
-        } else if (payload instanceof CloseLocalHistoryPayload) {
-            if (identifier != null) {
-                payloadReplicationComplete((CloseLocalHistoryPayload) payload);
-            } else {
-                allMetadataClosedLocalHistory(((CloseLocalHistoryPayload) payload).getIdentifier());
-            }
         } else if (payload instanceof CreateLocalHistoryPayload) {
             if (identifier != null) {
                 payloadReplicationComplete((CreateLocalHistoryPayload)payload);
index 93e1d87..c8f62e2 100644 (file)
@@ -65,7 +65,10 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort {
     @Override
     public void createSnapshot(final ActorRef actorRef, final Optional<OutputStream> installSnapshotStream) {
         // Forward the request to the snapshot actor
-        ShardSnapshotActor.requestSnapshot(snapshotActor, store.takeStateSnapshot(), installSnapshotStream, actorRef);
+        final ShardDataTreeSnapshot snapshot = store.takeStateSnapshot();
+        log.debug("{}: requesting serialization of snapshot {}", logId, snapshot);
+
+        ShardSnapshotActor.requestSnapshot(snapshotActor, snapshot, installSnapshotStream, actorRef);
     }
 
     @Override
@@ -94,7 +97,7 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort {
     }
 
     @Override
-    public State deserializeSnapshot(ByteSource snapshotBytes) throws IOException {
+    public State deserializeSnapshot(final ByteSource snapshotBytes) throws IOException {
         try (final ObjectInputStream in = new ObjectInputStream(snapshotBytes.openStream())) {
             return new ShardSnapshotState(ShardDataTreeSnapshot.deserialize(in));
         }
index 91c81ed..48f0a1e 100644 (file)
@@ -91,7 +91,7 @@ public final class FrontendClientMetadata implements Identifiable<ClientIdentifi
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(FrontendClientMetadata.class).add("Identifier", identifier)
-                .add("CurrentHistory", currentHistories).add("Range", purgedHistories).toString();
+        return MoreObjects.toStringHelper(FrontendClientMetadata.class).add("identifer", identifier)
+                .add("current", currentHistories).add("purged", purgedHistories).toString();
     }
 }
index 5429fd1..2cdda9f 100644 (file)
@@ -111,7 +111,7 @@ public final class FrontendHistoryMetadata implements WritableObject {
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(FrontendHistoryMetadata.class).add("historiId", historyId)
+        return MoreObjects.toStringHelper(FrontendHistoryMetadata.class).add("historyId", historyId)
                 .add("cookie", cookie).add("closed", closed).add("closedTransactions", closedTransactions)
                 .add("purgedTransactions", purgedTransactions).toString();
     }
index 5cabd71..05dc4cc 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.datastore.persisted;
 
 import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableMap;
@@ -125,4 +126,8 @@ public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardD
         return new Proxy(this);
     }
 
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).add("metadata", metadata).toString();
+    }
 }

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