Move ShardManagerSnapshot to new package 98/36598/4
authorRobert Varga <rovarga@cisco.com>
Wed, 23 Mar 2016 13:27:17 +0000 (14:27 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 29 Mar 2016 18:32:30 +0000 (18:32 +0000)
This creates a copy of the ShardManagerSnapshot in the new package and uses
readResolve() to perform migration.

Change-Id: I976adbaafd74de64a90d3970e17ce4ea52bdbe40
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardManagerSnapshot.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java

index 4cc54dd..3e7274c 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Preconditions;
 package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Preconditions;
+import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
@@ -16,8 +17,11 @@ import javax.annotation.Nonnull;
 
 /**
  * Persisted data of the ShardManager
 
 /**
  * Persisted data of the ShardManager
+ *
+ * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot} instead.
+ *             This class is scheduled for removal once persistence migration from Beryllium is no longer needed.
  */
  */
-
+@Deprecated
 public class ShardManagerSnapshot implements Serializable {
     private static final long serialVersionUID = 1L;
     private final List<String> shardList;
 public class ShardManagerSnapshot implements Serializable {
     private static final long serialVersionUID = 1L;
     private final List<String> shardList;
@@ -34,4 +38,8 @@ public class ShardManagerSnapshot implements Serializable {
     public String toString() {
         return "ShardManagerSnapshot [ShardList = " + shardList + " ]";
     }
     public String toString() {
         return "ShardManagerSnapshot [ShardList = " + shardList + " ]";
     }
+
+    private Object readResolve() throws ObjectStreamException {
+        return org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot.forShardList(shardList);
+    }
 }
 }
index 7a41021..dd60dca 100644 (file)
@@ -58,7 +58,6 @@ import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.Shard;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.Shard;
-import org.opendaylight.controller.cluster.datastore.ShardManagerSnapshot;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
 import org.opendaylight.controller.cluster.datastore.exceptions.AlreadyExistsException;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
 import org.opendaylight.controller.cluster.datastore.exceptions.AlreadyExistsException;
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerSnapshot.java
new file mode 100644 (file)
index 0000000..b6fe842
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015 Dell 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.shardmanager;
+
+import com.google.common.collect.ImmutableList;
+import java.io.Serializable;
+import java.util.List;
+import javax.annotation.Nonnull;
+
+/**
+ * Persisted data of the ShardManager
+ */
+// FIXME: make this package-protected once forShardList is removed.
+public final class ShardManagerSnapshot implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private final List<String> shardList;
+
+    ShardManagerSnapshot(final @Nonnull List<String> shardList) {
+        this.shardList = ImmutableList.copyOf(shardList);
+    }
+
+    List<String> getShardList() {
+        return this.shardList;
+    }
+
+    /**
+     * @deprecated This method is for migration only and should me removed once
+     *             org.opendaylight.controller.cluster.datastore.ShardManagerSnapshot is removed.
+     */
+    @Deprecated
+    public static ShardManagerSnapshot forShardList(final @Nonnull List<String> shardList) {
+        return new ShardManagerSnapshot(shardList);
+    }
+
+    @Override
+    public String toString() {
+        return "ShardManagerSnapshot [ShardList = " + shardList + " ]";
+    }
+}
index e5e5bf1..ae281c6 100644 (file)
@@ -72,7 +72,6 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.Shard;
 import org.opendaylight.controller.cluster.datastore.ShardManager.SchemaContextModules;
 import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.Shard;
 import org.opendaylight.controller.cluster.datastore.ShardManager.SchemaContextModules;
-import org.opendaylight.controller.cluster.datastore.ShardManagerSnapshot;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider;

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