}
private Object readResolve() throws ObjectStreamException {
- return org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot.forShardList(shardList);
+ return new org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot(shardList);
}
}
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
import org.opendaylight.controller.cluster.raft.Snapshot;
import org.opendaylight.controller.cluster.raft.persisted.EmptyState;
new ArrayList<>(size());
for (DatastoreSnapshot legacy: this) {
snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot(
- legacy.getType(), legacy.getShardManagerSnapshot(), fromLegacy(legacy.getShardSnapshots())));
+ legacy.getType(), deserializeShardManagerSnapshot(legacy.getShardManagerSnapshot()),
+ fromLegacy(legacy.getShardSnapshots())));
}
return new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList(snapshots);
}
+ private static org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot
+ deserializeShardManagerSnapshot(byte [] bytes) throws IOException, ClassNotFoundException {
+ if (bytes == null) {
+ return null;
+ }
+
+ try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
+ return (ShardManagerSnapshot) ois.readObject();
+ }
+ }
+
private static List<org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot>
fromLegacy(List<DatastoreSnapshot.ShardSnapshot> from) throws IOException, ClassNotFoundException {
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(), deserialize(legacy.getSnapshot())));
+ legacy.getName(), deserializeShardSnapshot(legacy.getSnapshot())));
}
return snapshots;
}
- private static org.opendaylight.controller.cluster.raft.persisted.Snapshot deserialize(byte[] bytes)
+ private static org.opendaylight.controller.cluster.raft.persisted.Snapshot deserializeShardSnapshot(byte[] bytes)
throws IOException, ClassNotFoundException {
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
Snapshot legacy = (Snapshot) ois.readObject();
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
String type = (String)in.readObject();
- byte[] shardManagerSnapshot = (byte[]) in.readObject();
+ ShardManagerSnapshot shardManagerSnapshot = (ShardManagerSnapshot) in.readObject();
int size = in.readInt();
List<ShardSnapshot> shardSnapshots = new ArrayList<>(size);
}
private final String type;
- private final byte[] shardManagerSnapshot;
+ private final ShardManagerSnapshot 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,
+ public DatastoreSnapshot(@Nonnull String type, @Nullable ShardManagerSnapshot shardManagerSnapshot,
@Nonnull List<ShardSnapshot> shardSnapshots) {
this.type = Preconditions.checkNotNull(type);
this.shardManagerSnapshot = shardManagerSnapshot;
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() {
+ public ShardManagerSnapshot getShardManagerSnapshot() {
return shardManagerSnapshot;
}
--- /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.persisted;
+
+import com.google.common.collect.ImmutableList;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+
+/**
+ * Represents the persisted snapshot state for the ShardManager.
+ *
+ * @author Thomas Pantelis
+ */
+public class ShardManagerSnapshot implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private static final class Proxy implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ private ShardManagerSnapshot snapshot;
+
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
+ // For Externalizable
+ }
+
+ Proxy(final ShardManagerSnapshot snapshot) {
+ this.snapshot = snapshot;
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(snapshot.shardList.size());
+ for (String shard: snapshot.shardList) {
+ out.writeObject(shard);
+ }
+ }
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ int size = in.readInt();
+ List<String> shardList = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ shardList.add((String) in.readObject());
+ }
+
+ snapshot = new ShardManagerSnapshot(shardList);
+ }
+
+ private Object readResolve() {
+ return snapshot;
+ }
+ }
+
+ private final List<String> shardList;
+
+ public ShardManagerSnapshot(@Nonnull final List<String> shardList) {
+ this.shardList = ImmutableList.copyOf(shardList);
+ }
+
+ public List<String> getShardList() {
+ return this.shardList;
+ }
+
+ @SuppressWarnings("static-method")
+ private Object writeReplace() {
+ return new Proxy(this);
+ }
+
+ @Override
+ public String toString() {
+ return "ShardManagerSnapshot [ShardList = " + shardList + " ]";
+ }
+}
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Supplier;
-import org.apache.commons.lang3.SerializationUtils;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersistentActorWithMetering;
import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
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.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
return;
}
- byte[] shardManagerSnapshot = null;
- if (currentSnapshot != null) {
- shardManagerSnapshot = SerializationUtils.serialize(currentSnapshot);
- }
-
ActorRef replyActor = getContext().actorOf(ShardManagerGetSnapshotReplyActor.props(
- new ArrayList<>(localShards.keySet()), type, shardManagerSnapshot , getSender(), persistenceId(),
+ new ArrayList<>(localShards.keySet()), type, currentSnapshot , getSender(), persistenceId(),
datastoreContextFactory.getBaseDatastoreContext().getShardInitializationTimeout().duration()));
for (ShardInformation shardInfo: localShards.values()) {
if (currentSnapshot == null && restoreFromSnapshot != null
&& restoreFromSnapshot.getShardManagerSnapshot() != null) {
- try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
- restoreFromSnapshot.getShardManagerSnapshot()))) {
- ShardManagerSnapshot snapshot = (ShardManagerSnapshot) ois.readObject();
+ ShardManagerSnapshot snapshot = restoreFromSnapshot.getShardManagerSnapshot();
- LOG.debug("{}: Deserialized restored ShardManagerSnapshot: {}", persistenceId(), snapshot);
+ LOG.debug("{}: Restoring from ShardManagerSnapshot: {}", persistenceId(), snapshot);
- applyShardManagerSnapshot(snapshot);
- } catch (ClassNotFoundException | IOException e) {
- LOG.error("{}: Error deserializing restored ShardManagerSnapshot", persistenceId(), e);
- }
+ applyShardManagerSnapshot(snapshot);
}
createLocalShards();
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- public static Props props(Collection<String> shardNames, String datastoreType, byte[] shardManagerSnapshot,
- ActorRef replyToActor, String id, Duration receiveTimeout) {
+ public static Props props(Collection<String> shardNames, String datastoreType,
+ ShardManagerSnapshot shardManagerSnapshot, ActorRef replyToActor, String id, Duration receiveTimeout) {
return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType,
shardManagerSnapshot, replyToActor, id, receiveTimeout));
}
private static final class Params {
final Collection<String> shardNames;
final String datastoreType;
- final byte[] shardManagerSnapshot;
+ final ShardManagerSnapshot shardManagerSnapshot;
final ActorRef replyToActor;
final String id;
final Duration receiveTimeout;
- Params(Collection<String> shardNames, String datastoreType, byte[] shardManagerSnapshot, ActorRef replyToActor,
- String id, Duration receiveTimeout) {
+ Params(Collection<String> shardNames, String datastoreType, ShardManagerSnapshot shardManagerSnapshot,
+ ActorRef replyToActor, String id, Duration receiveTimeout) {
this.shardNames = shardNames;
this.datastoreType = datastoreType;
this.shardManagerSnapshot = shardManagerSnapshot;
/**
* Persisted data of the ShardManager.
+ *
+ * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot} instead.
*/
-// FIXME: make this package-protected once forShardList is removed.
+@Deprecated
public final class ShardManagerSnapshot implements Serializable {
private static final long serialVersionUID = 1L;
private final List<String> shardList;
- ShardManagerSnapshot(final @Nonnull List<String> shardList) {
+ ShardManagerSnapshot(@Nonnull final List<String> shardList) {
this.shardList = ImmutableList.copyOf(shardList);
}
return new ShardManagerSnapshot(shardList);
}
+ private Object readResolve() {
+ return new org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot(shardList);
+ }
+
@Override
public String toString() {
return "ShardManagerSnapshot [ShardList = " + shardList + " ]";
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Objects;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.After;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList;
import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
-import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
assertTrue("Failed to mkdir " + restoreDirectoryPath, restoreDirectoryFile.mkdirs());
final DatastoreSnapshot configSnapshot = new DatastoreSnapshot("config",
- SerializationUtils.serialize(newShardManagerSnapshot("config-one", "config-two")),
+ newShardManagerSnapshot("config-one", "config-two"),
Arrays.asList(new DatastoreSnapshot.ShardSnapshot("config-one", newSnapshot(CarsModel.BASE_PATH,
CarsModel.newCarsNode(CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima",
BigInteger.valueOf(20000L)),CarsModel.newCarEntry("sportage",
private static void assertDatastoreSnapshotEquals(DatastoreSnapshot expected, DatastoreSnapshot actual) {
assertNotNull("DatastoreSnapshot is null", actual);
assertEquals("getType", expected.getType(), actual.getType());
- assertTrue("ShardManager snapshots don't match", Objects.deepEquals(expected.getShardManagerSnapshot(),
- actual.getShardManagerSnapshot()));
+
+ if (expected.getShardManagerSnapshot() == null) {
+ assertNull("Expected null ShardManagerSnapshot", actual.getShardManagerSnapshot());
+ } else {
+ assertEquals("ShardManagerSnapshot", expected.getShardManagerSnapshot().getShardList(),
+ actual.getShardManagerSnapshot().getShardList());
+ }
+
assertEquals("ShardSnapshots size", expected.getShardSnapshots().size(), actual.getShardSnapshots().size());
for (int i = 0; i < expected.getShardSnapshots().size(); i++) {
assertEquals("ShardSnapshot " + (i + 1) + " name", expected.getShardSnapshots().get(i).getName(),
}
private static ShardManagerSnapshot newShardManagerSnapshot(String... shards) {
- return ShardManagerSnapshot.forShardList(Arrays.asList(shards));
+ return new ShardManagerSnapshot(Arrays.asList(shards));
}
private static Snapshot newSnapshot(YangInstanceIdentifier path, NormalizedNode<?, ?> node)
NormalizedNode<?, ?> legacyConfigRoot2 = toRootNode(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
+ ShardManagerSnapshot legacyShardManagerSnapshot = newLegacyShardManagerSnapshot("config-one", "config-two");
DatastoreSnapshot legacyConfigSnapshot = new DatastoreSnapshot("config",
- SerializationUtils.serialize(newLegacyShardManagerSnapshot("config-one", "config-two")),
+ SerializationUtils.serialize(legacyShardManagerSnapshot),
Arrays.asList(newLegacyShardSnapshot("config-one", newLegacySnapshot(legacyConfigRoot1)),
newLegacyShardSnapshot("config-two", newLegacySnapshot(legacyConfigRoot2))));
SerializationUtils.clone(legacy);
assertEquals("DatastoreSnapshotList size", 2, cloned.size());
- assertDatastoreSnapshotEquals(legacyConfigSnapshot, cloned.get(0), Optional.of(legacyConfigRoot1),
- Optional.of(legacyConfigRoot2));
- assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1), Optional.empty());
+ assertDatastoreSnapshotEquals(legacyConfigSnapshot, cloned.get(0),
+ new org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot(
+ legacyShardManagerSnapshot.getShardList()),
+ Optional.of(legacyConfigRoot1), Optional.of(legacyConfigRoot2));
+ assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1),
+ (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)null,
+ Optional.empty());
}
+ @SuppressWarnings("unchecked")
private void assertDatastoreSnapshotEquals(DatastoreSnapshot legacy,
org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual,
+ org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot expShardMgrSnapshot,
Optional<NormalizedNode<?, ?>>... shardRoots) throws IOException {
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(),
+ org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot actualShardManagerSnapshot =
+ (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)
+ SerializationUtils.deserialize(legacy.getShardManagerSnapshot());
+ assertEquals("ShardManagerSnapshot", expShardMgrSnapshot.getShardList(),
actualShardManagerSnapshot.getShardList());
}
--- /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.persisted;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import org.apache.commons.lang.SerializationUtils;
+import org.junit.Test;
+
+/**
+ * Unit tests for ShardManagerSnapshot.
+ *
+ * @author Thomas Pantelis
+ */
+public class ShardManagerSnapshotTest {
+
+ @Test
+ public void testSerialization() {
+ ShardManagerSnapshot expected = new ShardManagerSnapshot(Arrays.asList("shard1", "shard2"));
+ ShardManagerSnapshot cloned = (ShardManagerSnapshot) SerializationUtils.clone(expected);
+
+ assertEquals("getShardList", expected.getShardList(), cloned.getShardList());
+ }
+}
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
-import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import akka.actor.ActorRef;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import org.opendaylight.controller.cluster.raft.persisted.ByteState;
public void testSuccess() {
JavaTestKit kit = new JavaTestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
+ List<String> shardList = Arrays.asList("shard1", "shard2", "shard3");
+ ShardManagerSnapshot shardManagerSnapshot = new ShardManagerSnapshot(shardList);
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1", "shard2", "shard3"), "config", shardManagerSnapshot, kit.getRef(),
+ shardList, "config", shardManagerSnapshot, kit.getRef(),
"shard-manager", Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
kit.watch(replyActor);
DatastoreSnapshot datastoreSnapshot = kit.expectMsgClass(DatastoreSnapshot.class);
assertEquals("getType", "config", datastoreSnapshot.getType());
- assertArrayEquals("getShardManagerSnapshot", shardManagerSnapshot, datastoreSnapshot.getShardManagerSnapshot());
+ assertEquals("getShardManagerSnapshot", shardManagerSnapshot.getShardList(),
+ datastoreSnapshot.getShardManagerSnapshot().getShardList());
List<ShardSnapshot> shardSnapshots = datastoreSnapshot.getShardSnapshots();
assertEquals("ShardSnapshot size", 3, shardSnapshots.size());
assertEquals("ShardSnapshot 1 getName", "shard1", shardSnapshots.get(0).getName());
public void testGetSnapshotFailureReply() {
JavaTestKit kit = new JavaTestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1", "shard2"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+ Arrays.asList("shard1", "shard2"), "config", null, kit.getRef(), "shard-manager",
Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
kit.watch(replyActor);
public void testGetSnapshotTimeout() {
JavaTestKit kit = new JavaTestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+ Arrays.asList("shard1"), "config", null, kit.getRef(), "shard-manager",
Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
kit.watch(replyActor);
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.SerializationUtils;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
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.persisted.ShardManagerSnapshot;
import org.opendaylight.controller.cluster.datastore.utils.ForwardingActor;
import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper;
import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration;
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"), Sets.newHashSet(
Lists.transform(datastoreSnapshot.getShardSnapshots(), shardNameTransformer)));
- byte[] snapshotBytes = datastoreSnapshot.getShardManagerSnapshot();
- assertNotNull("Expected ShardManagerSnapshot", snapshotBytes);
- ShardManagerSnapshot snapshot = SerializationUtils.deserialize(snapshotBytes);
+ ShardManagerSnapshot snapshot = datastoreSnapshot.getShardManagerSnapshot();
+ assertNotNull("Expected ShardManagerSnapshot", snapshot);
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"),
Sets.newHashSet(snapshot.getShardList()));
.put("astronauts", Collections.<String>emptyList()).build());
ShardManagerSnapshot snapshot = new ShardManagerSnapshot(Arrays.asList("shard1", "shard2", "astronauts"));
- DatastoreSnapshot restoreFromSnapshot = new DatastoreSnapshot(shardMrgIDSuffix,
- SerializationUtils.serialize(snapshot), Collections.<ShardSnapshot>emptyList());
+ DatastoreSnapshot restoreFromSnapshot = new DatastoreSnapshot(shardMrgIDSuffix, snapshot,
+ Collections.<ShardSnapshot>emptyList());
TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(newTestShardMgrBuilder(mockConfig)
.restoreFromSnapshot(restoreFromSnapshot).props().withDispatcher(Dispatchers.DefaultDispatcherId()));
assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
- byte[] snapshotBytes = datastoreSnapshot.getShardManagerSnapshot();
- assertNotNull("Expected ShardManagerSnapshot", snapshotBytes);
- snapshot = SerializationUtils.deserialize(snapshotBytes);
+ assertNotNull("Expected ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"),
- Sets.newHashSet(snapshot.getShardList()));
+ Sets.newHashSet(datastoreSnapshot.getShardManagerSnapshot().getShardList()));
LOG.info("testRestoreFromSnapshot ending");
}