import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.messages.AddShardReplica;
import org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshotList;
import org.opendaylight.controller.cluster.datastore.messages.FlipShardMembersVotingStatus;
import org.opendaylight.controller.cluster.datastore.messages.RemoveShardReplica;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshot;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddReplicasForAllShardsOutput;
import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.CreateShard;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.raft.RaftState;
import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry;
import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
org.opendaylight.controller.cluster.datastore;
org.opendaylight.controller.cluster.datastore.config;
org.opendaylight.controller.cluster.datastore.messages;
+ org.opendaylight.controller.cluster.datastore.persisted;
org.opendaylight.controller.cluster.datastore.utils;
</Export-Package>
<Import-Package>
import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardManagerIdentifier;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.DatastoreConfigurationMXBeanImpl;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.DatastoreInfoMXBeanImpl;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerCreator;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshotList;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.controller.cluster.databroker.ClientBackedDataStore;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.ForwardedReadyTransaction;
import org.opendaylight.controller.cluster.datastore.messages.GetShardDataTree;
import org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState;
import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged;
import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener;
* Stores a snapshot of the internal state of a data store.
*
* @author Thomas Pantelis
+ *
+ * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot} instead.
*/
+@Deprecated
public class DatastoreSnapshot implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Stores a list of DatastoreSnapshot instances.
+ *
+ * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList} instead.
*/
+@Deprecated
public class DatastoreSnapshotList extends ArrayList<DatastoreSnapshot> {
private static final long serialVersionUID = 1L;
public DatastoreSnapshotList(List<DatastoreSnapshot> snapshots) {
super(snapshots);
}
+
+ private Object readResolve() {
+ List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot> snapshots =
+ new ArrayList<>(size());
+ for (DatastoreSnapshot legacy: this) {
+ snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot(
+ legacy.getType(), legacy.getShardManagerSnapshot(), fromLegacy(legacy.getShardSnapshots())));
+ }
+
+ return new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList(snapshots);
+ }
+
+ private List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot> fromLegacy(
+ List<DatastoreSnapshot.ShardSnapshot> from) {
+ List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot> snapshots =
+ new ArrayList<>(from.size());
+ for (DatastoreSnapshot.ShardSnapshot legacy: from) {
+ snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot(
+ legacy.getName(), legacy.getSnapshot()));
+ }
+
+ return snapshots;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications 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.persisted;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.io.Serializable;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Stores a snapshot of the internal state of a data store.
+ *
+ * @author Thomas Pantelis
+ */
+public class DatastoreSnapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final String type;
+ private final byte[] shardManagerSnapshot;
+ private final List<ShardSnapshot> shardSnapshots;
+
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] "
+ + "object but this is OK since this class is merely a DTO and does not process byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
+ public DatastoreSnapshot(@Nonnull String type, @Nullable byte[] shardManagerSnapshot,
+ @Nonnull List<ShardSnapshot> shardSnapshots) {
+ this.type = Preconditions.checkNotNull(type);
+ this.shardManagerSnapshot = shardManagerSnapshot;
+ this.shardSnapshots = ImmutableList.copyOf(Preconditions.checkNotNull(shardSnapshots));
+ }
+
+ @Nonnull
+ public String getType() {
+ return type;
+ }
+
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
+ @Nullable
+ public byte[] getShardManagerSnapshot() {
+ return shardManagerSnapshot;
+ }
+
+ @Nonnull
+ public List<ShardSnapshot> getShardSnapshots() {
+ return shardSnapshots;
+ }
+
+ public static class ShardSnapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final String name;
+ private final byte[] snapshot;
+
+ public ShardSnapshot(@Nonnull String name, @Nonnull byte[] snapshot) {
+ this.name = Preconditions.checkNotNull(name);
+ this.snapshot = Preconditions.checkNotNull(snapshot);
+ }
+
+ @Nonnull
+ public String getName() {
+ return name;
+ }
+
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
+ @Nonnull
+ public byte[] getSnapshot() {
+ return snapshot;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Brocade Communications 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.persisted;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Stores a list of DatastoreSnapshot instances.
+ */
+public class DatastoreSnapshotList extends ArrayList<DatastoreSnapshot> {
+ private static final long serialVersionUID = 1L;
+
+ public DatastoreSnapshotList() {
+ }
+
+ public DatastoreSnapshotList(List<DatastoreSnapshot> snapshots) {
+ super(snapshots);
+ }
+}
import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
public abstract class AbstractShardManagerCreator<T extends AbstractShardManagerCreator<T>> {
import org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus;
import org.opendaylight.controller.cluster.datastore.messages.CreatePrefixedShard;
import org.opendaylight.controller.cluster.datastore.messages.CreateShard;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
import org.opendaylight.controller.cluster.datastore.messages.FlipShardMembersVotingStatus;
import org.opendaylight.controller.cluster.datastore.messages.RemoveShardReplica;
import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged;
import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
new AutoFindPrimaryFailureResponseHandler(getSender(), shardName, persistenceId(), getSelf()) {
@Override
public void onRemotePrimaryShardFound(final RemotePrimaryShardFound response) {
- getSelf().tell(new RunnableMessage() {
- @Override
- public void run() {
- addShard(getShardName(), response, getSender());
- }
- }, getTargetActor());
+ getSelf().tell((RunnableMessage) () -> addShard(getShardName(), response, getSender()),
+ getTargetActor());
}
@Override
import java.util.Set;
import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.shardList = ImmutableList.copyOf(shardList);
}
- List<String> getShardList() {
+ public List<String> getShardList() {
return this.shardList;
}
import org.apache.commons.lang3.SerializationUtils;
import org.junit.After;
import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshotList;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList;
/**
* Unit tests for DatastoreSnapshotRestore.
import org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker;
import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener;
import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
--- /dev/null
+/*
+ * Copyright (c) 2017 Brocade Communications 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.messages;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayOutputStream;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.AbstractShardTest;
+import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
+import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
+import org.opendaylight.controller.cluster.raft.Snapshot;
+import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
+import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
+import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
+import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
+
+/**
+ * Unit tests for DatastoreSnapshotList.
+ *
+ * @author Thomas Pantelis
+ */
+@Deprecated
+public class DatastoreSnapshotListTest {
+ @Test
+ public void testSerialization() throws Exception {
+ DatastoreSnapshot legacyConfigSnapshot = new DatastoreSnapshot("config",
+ SerializationUtils.serialize(newLegacyShardManagerSnapshot("config-one", "config-two")),
+ Arrays.asList(newLegacyShardSnapshot("config-one", newLegacySnapshot(CarsModel.BASE_PATH,
+ CarsModel.newCarsNode(CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima",
+ BigInteger.valueOf(20000L)),CarsModel.newCarEntry("sportage",
+ BigInteger.valueOf(30000L)))))),
+ newLegacyShardSnapshot("config-two", newLegacySnapshot(PeopleModel.BASE_PATH,
+ PeopleModel.emptyContainer()))));
+
+ DatastoreSnapshot legacyOperSnapshot = new DatastoreSnapshot("oper",
+ null, Arrays.asList(newLegacyShardSnapshot("oper-one", newLegacySnapshot(TestModel.TEST_PATH,
+ ImmutableNodes.containerNode(TestModel.TEST_QNAME)))));
+
+ DatastoreSnapshotList legacy = new DatastoreSnapshotList(Arrays.asList(legacyConfigSnapshot,
+ legacyOperSnapshot));
+
+ org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList cloned =
+ (org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList)
+ SerializationUtils.clone(legacy);
+
+ assertEquals("DatastoreSnapshotList size", 2, cloned.size());
+ assertDatastoreSnapshotEquals(legacyConfigSnapshot, cloned.get(0));
+ assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1));
+ }
+
+ private void assertDatastoreSnapshotEquals(DatastoreSnapshot legacy,
+ org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual) {
+ assertEquals("Type", legacy.getType(), actual.getType());
+
+ if (legacy.getShardManagerSnapshot() == null) {
+ assertNull("Expected null ShardManagerSnapshot", actual.getShardManagerSnapshot());
+ } else {
+ ShardManagerSnapshot legacyShardManagerSnapshot =
+ (ShardManagerSnapshot) SerializationUtils.deserialize(legacy.getShardManagerSnapshot());
+ ShardManagerSnapshot actualShardManagerSnapshot =
+ (ShardManagerSnapshot) SerializationUtils.deserialize(actual.getShardManagerSnapshot());
+ assertEquals("ShardManagerSnapshot", legacyShardManagerSnapshot.getShardList(),
+ actualShardManagerSnapshot.getShardList());
+ }
+
+ assertEquals("ShardSnapshots size", legacy.getShardSnapshots().size(), actual.getShardSnapshots().size());
+
+ for (int i = 0; i < actual.getShardSnapshots().size(); i++) {
+ ShardSnapshot legacyShardSnapshot = legacy.getShardSnapshots().get(i);
+ org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot
+ actualShardSnapshot = actual.getShardSnapshots().get(i);
+ assertEquals("Shard name", legacyShardSnapshot.getName(), actualShardSnapshot.getName());
+ assertSnapshotEquals((Snapshot) SerializationUtils.deserialize(legacyShardSnapshot.getSnapshot()),
+ (Snapshot) SerializationUtils.deserialize(actualShardSnapshot.getSnapshot()));
+ }
+ }
+
+ private static void assertSnapshotEquals(Snapshot expected, Snapshot actual) {
+ assertEquals("lastIndex", expected.getLastIndex(), actual.getLastIndex());
+ assertEquals("lastTerm", expected.getLastTerm(), actual.getLastTerm());
+ assertEquals("lastAppliedIndex", expected.getLastAppliedIndex(), actual.getLastAppliedIndex());
+ assertEquals("lastAppliedTerm", expected.getLastAppliedTerm(), actual.getLastAppliedTerm());
+ assertEquals("unAppliedEntries", expected.getUnAppliedEntries(), actual.getUnAppliedEntries());
+ assertEquals("electionTerm", expected.getElectionTerm(), actual.getElectionTerm());
+ assertEquals("electionVotedFor", expected.getElectionVotedFor(), actual.getElectionVotedFor());
+ assertArrayEquals("state", expected.getState(), actual.getState());
+ }
+
+ private static ShardManagerSnapshot newLegacyShardManagerSnapshot(String... shards) {
+ return ShardManagerSnapshot.forShardList(Arrays.asList(shards));
+ }
+
+ private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(String name,
+ org.opendaylight.controller.cluster.raft.Snapshot snapshot) {
+ return new DatastoreSnapshot.ShardSnapshot(name, SerializationUtils.serialize(snapshot));
+ }
+
+ private static Snapshot newLegacySnapshot(YangInstanceIdentifier path, NormalizedNode<?, ?> node)
+ throws Exception {
+ DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+ dataTree.setSchemaContext(SchemaContextHelper.full());
+ AbstractShardTest.writeToStore(dataTree, path, node);
+ NormalizedNode<?, ?> root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY);
+
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ new MetadataShardDataTreeSnapshot(root).serialize(bos);
+ return Snapshot.create(bos.toByteArray(), Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1,
+ "member-1", null);
+ }
+}
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
import org.opendaylight.controller.cluster.datastore.messages.AddShardReplica;
import org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus;
import org.opendaylight.controller.cluster.datastore.messages.CreateShard;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
import org.opendaylight.controller.cluster.datastore.messages.FindPrimary;
import org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound;
import org.opendaylight.controller.cluster.datastore.messages.RemoveShardReplica;
import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged;
import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ForwardingActor;
import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;