Bug 8380: Fix unhandled messages in ShardManager 15/56615/2
authorTom Pantelis <tompantelis@gmail.com>
Fri, 5 May 2017 18:21:50 +0000 (14:21 -0400)
committerRobert Varga <nite@hq.sk>
Sat, 6 May 2017 10:01:39 +0000 (10:01 +0000)
Added trace logging for RegisterRoleChangeListenerReply and other
MemberEvent (ie MemberJoined, MemberLeft).

The DeleteMessagesSuccess message was the result of deleting legacy
journal messages (SchemaContextModules) that were kept for backwards
compatibility with Helium. I removed the associated code and the
deprecated ShardManager class that was kept for the SchemaContextModules
inner class.

Also added logging for DeleteSnapshotsFailure and DeleteSnapshotsSuccess.

Change-Id: I145ea815b191f1e167e73029df348c7d15732c4f
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java

diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManager.java
deleted file mode 100644 (file)
index 3021080..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.cluster.datastore;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * Manages shards.
- *
- * @deprecated This is a deprecated placeholder to keep its inner class present. It serves no other purpose.
- */
-@Deprecated
-public final class ShardManager {
-    /**
-     * We no longer persist SchemaContextModules but keep this class around for now for backwards
-     * compatibility so we don't get de-serialization failures on upgrade from Helium.
-     */
-    @Deprecated
-    public static class SchemaContextModules implements Serializable {
-        private static final long serialVersionUID = -8884620101025936590L;
-
-        private final Set<String> modules;
-
-        public SchemaContextModules(Set<String> modules) {
-            this.modules = modules;
-        }
-
-        public Set<String> getModules() {
-            return modules;
-        }
-    }
-
-    private ShardManager() {
-        throw new UnsupportedOperationException("deprecated outer class");
-    }
-}
index bb289bc..d3d8ce3 100644 (file)
@@ -25,6 +25,8 @@ import akka.dispatch.Futures;
 import akka.dispatch.OnComplete;
 import akka.japi.Function;
 import akka.pattern.Patterns;
+import akka.persistence.DeleteSnapshotsFailure;
+import akka.persistence.DeleteSnapshotsSuccess;
 import akka.persistence.RecoveryCompleted;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
@@ -86,6 +88,7 @@ import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
 import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
 import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
 import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener;
+import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListenerReply;
 import org.opendaylight.controller.cluster.notifications.RoleChangeNotification;
 import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus;
 import org.opendaylight.controller.cluster.raft.base.messages.SwitchBehavior;
@@ -294,6 +297,15 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
             onGetLocalShardIds();
         } else if (message instanceof RunnableMessage) {
             ((RunnableMessage)message).run();
+        } else if (message instanceof DeleteSnapshotsFailure) {
+            LOG.warn("{}: Failed to delete prior snapshots", persistenceId(),
+                    ((DeleteSnapshotsFailure) message).cause());
+        } else if (message instanceof DeleteSnapshotsSuccess) {
+            LOG.debug("{}: Successfully deleted prior snapshots", persistenceId(), message);
+        } else if (message instanceof RegisterRoleChangeListenerReply) {
+            LOG.trace("{}: Received RegisterRoleChangeListenerReply", persistenceId());
+        } else if (message instanceof ClusterEvent.MemberEvent) {
+            LOG.trace("{}: Received other ClusterEvent.MemberEvent: {}", persistenceId(), message);
         } else {
             unknownMessage(message);
         }
@@ -840,10 +852,6 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
     private void onRecoveryCompleted() {
         LOG.info("Recovery complete : {}", persistenceId());
 
-        // We no longer persist SchemaContext modules so delete all the prior messages from the akka
-        // journal on upgrade from Helium.
-        deleteMessages(lastSequenceNr());
-
         if (currentSnapshot == null && restoreFromSnapshot != null
                 && restoreFromSnapshot.getShardManagerSnapshot() != null) {
             ShardManagerSnapshot snapshot = restoreFromSnapshot.getShardManagerSnapshot();
index 5efd094..6e37a97 100644 (file)
@@ -40,7 +40,6 @@ import akka.util.Timeout;
 import com.google.common.base.Function;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -68,7 +67,6 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
 import org.opendaylight.controller.cluster.datastore.Shard;
-import org.opendaylight.controller.cluster.datastore.ShardManager.SchemaContextModules;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider;
 import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
@@ -118,7 +116,6 @@ import org.opendaylight.controller.cluster.raft.messages.ServerChangeReply;
 import org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus;
 import org.opendaylight.controller.cluster.raft.messages.ServerRemoved;
 import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
-import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
@@ -989,24 +986,6 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         LOG.info("testOnReceiveFindLocalShardWaitForShardInitialized starting");
     }
 
-    @Test
-    public void testOnRecoveryJournalIsCleaned() {
-        String persistenceID = "shard-manager-" + shardMrgIDSuffix;
-        InMemoryJournal.addEntry(persistenceID, 1L, new SchemaContextModules(ImmutableSet.of("foo")));
-        InMemoryJournal.addEntry(persistenceID, 2L, new SchemaContextModules(ImmutableSet.of("bar")));
-        InMemoryJournal.addDeleteMessagesCompleteLatch(persistenceID);
-
-        newTestShardManager();
-
-        InMemoryJournal.waitForDeleteMessagesComplete(persistenceID);
-
-        // Journal entries up to the last one should've been deleted
-        Map<Long, Object> journal = InMemoryJournal.get(persistenceID);
-        synchronized (journal) {
-            assertEquals("Journal size", 0, journal.size());
-        }
-    }
-
     @Test
     public void testRoleChangeNotificationAndShardLeaderStateChangedReleaseReady() throws Exception {
         TestShardManager shardManager = newTestShardManager();

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