From 90735c91ce3390a731afc446b4e7314c544ab9d6 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Tue, 30 May 2017 08:15:18 -0400 Subject: [PATCH] Remove deprecated Snapshot and related code Carbon will create a new snapshot when it encounters a pre-Carbon Snapshot so we can remove the pre-Carbon Snapshot and related code. Change-Id: Iae5f140aadb458eaa59ea4cc8be6054bbde090e4 Signed-off-by: Tom Pantelis --- .../cluster/example/ExampleActor.java | 9 +- .../cluster/raft/RaftActorRecoveryCohort.java | 11 -- .../raft/RaftActorRecoverySupport.java | 14 +- .../controller/cluster/raft/Snapshot.java | 116 ------------ .../cluster/raft/MigratedMessagesTest.java | 47 ----- .../cluster/raft/MockRaftActor.java | 5 - .../raft/RaftActorRecoverySupportTest.java | 50 ------ .../datastore/ShardRecoveryCoordinator.java | 14 -- .../datastore/messages/DatastoreSnapshot.java | 84 --------- .../messages/DatastoreSnapshotList.java | 88 --------- ...bstractVersionedShardDataTreeSnapshot.java | 27 --- .../persisted/ShardDataTreeSnapshot.java | 21 --- .../DistributedDataStoreIntegrationTest.java | 48 ----- .../messages/DatastoreSnapshotListTest.java | 168 ------------------ 14 files changed, 3 insertions(+), 699 deletions(-) delete mode 100644 opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java delete mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshot.java delete mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java delete mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotListTest.java diff --git a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java index 5cd4c14ee4..9eb8fd6ed1 100644 --- a/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java +++ b/opendaylight/md-sal/sal-akka-raft-example/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java @@ -201,21 +201,16 @@ public class ExampleActor extends RaftActor implements RaftActorRecoveryCohort, return null; } + @SuppressWarnings("unchecked") @Override public Snapshot.State deserializeSnapshot(ByteSource snapshotBytes) { try { - return deserializePreCarbonSnapshot(snapshotBytes.read()); + return new MapState((Map) SerializationUtils.deserialize(snapshotBytes.read())); } catch (IOException e) { throw Throwables.propagate(e); } } - @SuppressWarnings("unchecked") - @Override - public Snapshot.State deserializePreCarbonSnapshot(byte[] from) { - return new MapState((Map) SerializationUtils.deserialize(from)); - } - private static class MapState implements Snapshot.State { private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java index f948769c9c..e107be96c4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoveryCohort.java @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.cluster.raft; -import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; @@ -55,14 +54,4 @@ public interface RaftActorRecoveryCohort { */ @Nullable Snapshot getRestoreFromSnapshot(); - - /** - * This method is called during recovery to de-serialize a snapshot that was persisted in the pre-Carbon format. - * - * @param from the snaphot bytes - * @return a Snapshot.State instance - */ - @Deprecated - @Nonnull - Snapshot.State deserializePreCarbonSnapshot(byte [] from); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java index a31bf4bf41..1b9343c1f3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java @@ -110,19 +110,7 @@ class RaftActorRecoverySupport { initRecoveryTimer(); - Object snapshotObj = offer.snapshot(); - Snapshot snapshot; - if (snapshotObj instanceof org.opendaylight.controller.cluster.raft.Snapshot) { - org.opendaylight.controller.cluster.raft.Snapshot legacy = - (org.opendaylight.controller.cluster.raft.Snapshot)snapshotObj; - snapshot = Snapshot.create(cohort.deserializePreCarbonSnapshot(legacy.getState()), - legacy.getUnAppliedEntries(), legacy.getLastIndex(), legacy.getLastTerm(), - legacy.getLastAppliedIndex(), legacy.getLastAppliedTerm(), - legacy.getElectionTerm(), legacy.getElectionVotedFor(), legacy.getServerConfiguration()); - hasMigratedDataRecovered = true; - } else { - snapshot = (Snapshot) offer.snapshot(); - } + Snapshot snapshot = (Snapshot) offer.snapshot(); for (ReplicatedLogEntry entry: snapshot.getUnAppliedEntries()) { if (isMigratedPayload(entry)) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java deleted file mode 100644 index 93226ccab2..0000000000 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/Snapshot.java +++ /dev/null @@ -1,116 +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.raft; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.Serializable; -import java.util.List; -import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload; - -/** - * Represents a snapshot of the raft data. - * - * @author Moiz Raja - * @author Thomas Pantelis - * - * @deprecated Use {@link org.opendaylight.controller.cluster.raft.persisted.Snapshot} instead. - */ -@Deprecated -public class Snapshot implements Serializable { - private static final long serialVersionUID = -8298574936724056236L; - - private final byte[] state; - private final List unAppliedEntries; - private final long lastIndex; - private final long lastTerm; - private final long lastAppliedIndex; - private final long lastAppliedTerm; - private final long electionTerm; - private final String electionVotedFor; - private final ServerConfigurationPayload serverConfig; - - private Snapshot(byte[] state, List unAppliedEntries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, - ServerConfigurationPayload serverConfig) { - this.state = state; - this.unAppliedEntries = unAppliedEntries; - this.lastIndex = lastIndex; - this.lastTerm = lastTerm; - this.lastAppliedIndex = lastAppliedIndex; - this.lastAppliedTerm = lastAppliedTerm; - this.electionTerm = electionTerm; - this.electionVotedFor = electionVotedFor; - this.serverConfig = serverConfig; - } - - public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm) { - return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, -1, null, null); - } - - public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor) { - return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, - electionTerm, electionVotedFor, null); - } - - public static Snapshot create(byte[] state, List entries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, - ServerConfigurationPayload serverConfig) { - return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, - electionTerm, electionVotedFor, serverConfig); - } - - @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 the byte[] internally. " - + "Also it would be inefficient to create a return copy as the byte[] could be large.") - public byte[] getState() { - return state; - } - - public List getUnAppliedEntries() { - return unAppliedEntries; - } - - public long getLastTerm() { - return lastTerm; - } - - public long getLastAppliedIndex() { - return lastAppliedIndex; - } - - public long getLastAppliedTerm() { - return lastAppliedTerm; - } - - public long getLastIndex() { - return this.lastIndex; - } - - public long getElectionTerm() { - return electionTerm; - } - - - public String getElectionVotedFor() { - return electionVotedFor; - } - - public ServerConfigurationPayload getServerConfiguration() { - return serverConfig; - } - - @Override - public String toString() { - return "Snapshot [lastIndex=" + lastIndex + ", lastTerm=" + lastTerm + ", lastAppliedIndex=" + lastAppliedIndex - + ", lastAppliedTerm=" + lastAppliedTerm + ", unAppliedEntries size=" + unAppliedEntries.size() - + ", state size=" + state.length + ", electionTerm=" + electionTerm + ", electionVotedFor=" - + electionVotedFor + ", ServerConfigPayload=" + serverConfig + "]"; - } -} diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MigratedMessagesTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MigratedMessagesTest.java index 70f45045b7..0b58c8927d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MigratedMessagesTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MigratedMessagesTest.java @@ -14,26 +14,18 @@ import akka.dispatch.Dispatchers; import akka.testkit.TestActorRef; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; import com.google.common.io.ByteSource; import com.google.common.util.concurrent.Uninterruptibles; import java.io.OutputStream; -import java.io.Serializable; -import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.cluster.raft.MockRaftActor.MockSnapshotState; -import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply; import org.opendaylight.controller.cluster.raft.persisted.ApplyJournalEntries; import org.opendaylight.controller.cluster.raft.persisted.ByteState; -import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload; -import org.opendaylight.controller.cluster.raft.persisted.ServerInfo; import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.persisted.Snapshot.State; @@ -109,45 +101,6 @@ public class MigratedMessagesTest extends AbstractActorTest { TEST_LOG.info("testNoSnapshotAfterStartupWithNoMigratedMessages ending"); } - @Test - public void testSnapshotAfterStartupWithMigratedSnapshot() throws Exception { - TEST_LOG.info("testSnapshotAfterStartupWithMigratedSnapshot starting"); - - String persistenceId = factory.generateActorId("test-actor-"); - - List snapshotData = Arrays.asList(new MockPayload("1")); - final MockSnapshotState snapshotState = new MockSnapshotState(snapshotData); - - org.opendaylight.controller.cluster.raft.Snapshot legacy = org.opendaylight.controller.cluster.raft.Snapshot - .create(SerializationUtils.serialize((Serializable) snapshotData), - Arrays.asList(new SimpleReplicatedLogEntry(6, 2, new MockPayload("payload"))), - 6, 2, 5, 1, 3, "member-1", new ServerConfigurationPayload(Arrays.asList( - new ServerInfo(persistenceId, true), new ServerInfo("2", false)))); - InMemorySnapshotStore.addSnapshot(persistenceId, legacy); - - doTestSnapshotAfterStartupWithMigratedMessage(persistenceId, true, snapshot -> { - assertEquals("getLastIndex", legacy.getLastIndex(), snapshot.getLastIndex()); - assertEquals("getLastTerm", legacy.getLastTerm(), snapshot.getLastTerm()); - assertEquals("getLastAppliedIndex", legacy.getLastAppliedIndex(), snapshot.getLastAppliedIndex()); - assertEquals("getLastAppliedTerm", legacy.getLastAppliedTerm(), snapshot.getLastAppliedTerm()); - assertEquals("getState", snapshotState, snapshot.getState()); - assertEquals("Unapplied entries size", legacy.getUnAppliedEntries().size(), - snapshot.getUnAppliedEntries().size()); - assertEquals("Unapplied entry term", legacy.getUnAppliedEntries().get(0).getTerm(), - snapshot.getUnAppliedEntries().get(0).getTerm()); - assertEquals("Unapplied entry index", legacy.getUnAppliedEntries().get(0).getIndex(), - snapshot.getUnAppliedEntries().get(0).getIndex()); - assertEquals("Unapplied entry data", legacy.getUnAppliedEntries().get(0).getData(), - snapshot.getUnAppliedEntries().get(0).getData()); - assertEquals("getElectionVotedFor", legacy.getElectionVotedFor(), snapshot.getElectionVotedFor()); - assertEquals("getElectionTerm", legacy.getElectionTerm(), snapshot.getElectionTerm()); - assertEquals("getServerConfiguration", Sets.newHashSet(legacy.getServerConfiguration().getServerConfig()), - Sets.newHashSet(snapshot.getServerConfiguration().getServerConfig())); - }, snapshotState); - - TEST_LOG.info("testSnapshotAfterStartupWithMigratedSnapshot ending"); - } - @SuppressWarnings("checkstyle:IllegalCatch") private TestActorRef doTestSnapshotAfterStartupWithMigratedMessage(String id, boolean persistent, Consumer snapshotVerifier, final State snapshotState) { diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java index ae26383283..7f3b12c54b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java @@ -205,11 +205,6 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort, } } - @Override - public Snapshot.State deserializePreCarbonSnapshot(byte[] from) { - return new MockSnapshotState(SerializationUtils.deserialize(from)); - } - @Override protected void onStateChanged() { actorDelegate.onStateChanged(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupportTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupportTest.java index 828e3eb89e..897294718f 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupportTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupportTest.java @@ -13,7 +13,6 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; @@ -24,11 +23,8 @@ import akka.persistence.RecoveryCompleted; import akka.persistence.SnapshotMetadata; import akka.persistence.SnapshotOffer; import com.google.common.collect.Sets; -import java.io.Serializable; import java.util.Arrays; import java.util.Collections; -import java.util.List; -import org.apache.commons.lang3.SerializationUtils; import org.hamcrest.Description; import org.junit.Before; import org.junit.Test; @@ -208,52 +204,6 @@ public class RaftActorRecoverySupportTest { verify(mockCohort).applyRecoverySnapshot(snapshotState); } - @Deprecated - @Test - public void testOnSnapshotOfferWithPreCarbonSnapshot() { - - ReplicatedLogEntry unAppliedEntry1 = new SimpleReplicatedLogEntry(4, 1, - new MockRaftActorContext.MockPayload("4", 4)); - - ReplicatedLogEntry unAppliedEntry2 = new SimpleReplicatedLogEntry(5, 1, - new MockRaftActorContext.MockPayload("5", 5)); - - long lastAppliedDuringSnapshotCapture = 3; - long lastIndexDuringSnapshotCapture = 5; - long electionTerm = 2; - String electionVotedFor = "member-2"; - - List snapshotData = Arrays.asList(new MockPayload("1")); - final MockSnapshotState snapshotState = new MockSnapshotState(snapshotData); - - org.opendaylight.controller.cluster.raft.Snapshot snapshot = org.opendaylight.controller.cluster.raft.Snapshot - .create(SerializationUtils.serialize((Serializable) snapshotData), - Arrays.asList(unAppliedEntry1, unAppliedEntry2), lastIndexDuringSnapshotCapture, 1, - lastAppliedDuringSnapshotCapture, 1, electionTerm, electionVotedFor, null); - - SnapshotMetadata metadata = new SnapshotMetadata("test", 6, 12345); - SnapshotOffer snapshotOffer = new SnapshotOffer(metadata , snapshot); - - doAnswer(invocation -> new MockSnapshotState(SerializationUtils.deserialize( - invocation.getArgumentAt(0, byte[].class)))) - .when(mockCohort).deserializePreCarbonSnapshot(any(byte[].class)); - - sendMessageToSupport(snapshotOffer); - - assertEquals("Journal log size", 2, context.getReplicatedLog().size()); - assertEquals("Journal data size", 9, context.getReplicatedLog().dataSize()); - assertEquals("Last index", lastIndexDuringSnapshotCapture, context.getReplicatedLog().lastIndex()); - assertEquals("Last applied", lastAppliedDuringSnapshotCapture, context.getLastApplied()); - assertEquals("Commit index", lastAppliedDuringSnapshotCapture, context.getCommitIndex()); - assertEquals("Snapshot term", 1, context.getReplicatedLog().getSnapshotTerm()); - assertEquals("Snapshot index", lastAppliedDuringSnapshotCapture, context.getReplicatedLog().getSnapshotIndex()); - assertEquals("Election term", electionTerm, context.getTermInformation().getCurrentTerm()); - assertEquals("Election votedFor", electionVotedFor, context.getTermInformation().getVotedFor()); - assertFalse("Dynamic server configuration", context.isDynamicServerConfigurationInUse()); - - verify(mockCohort).applyRecoverySnapshot(snapshotState); - } - @Test public void testOnRecoveryCompletedWithRemainingBatch() { ReplicatedLog replicatedLog = context.getReplicatedLog(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java index a916ea6dea..6e5886132a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java @@ -8,15 +8,12 @@ package org.opendaylight.controller.cluster.datastore; import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; import java.io.File; -import java.io.IOException; import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; import org.opendaylight.controller.cluster.datastore.utils.NormalizedNodeXMLOutput; import org.opendaylight.controller.cluster.raft.RaftActorRecoveryCohort; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; -import org.opendaylight.controller.cluster.raft.persisted.Snapshot.State; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; @@ -112,15 +109,4 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort { public Snapshot getRestoreFromSnapshot() { return restoreFromSnapshot; } - - @Override - @Deprecated - public State deserializePreCarbonSnapshot(final byte[] from) { - try { - return new ShardSnapshotState(ShardDataTreeSnapshot.deserializePreCarbon(from)); - } catch (IOException e) { - log.error("{}: failed to deserialize snapshot", shardName, e); - throw Throwables.propagate(e); - } - } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshot.java deleted file mode 100644 index 9c223b4f5a..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshot.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.messages; - -import com.google.common.base.Preconditions; -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 - * - * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot} instead. - */ -@Deprecated -public class DatastoreSnapshot implements Serializable { - private static final long serialVersionUID = 1L; - - private final String type; - private final byte[] shardManagerSnapshot; - private final List 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 shardSnapshots) { - this.type = Preconditions.checkNotNull(type); - this.shardManagerSnapshot = shardManagerSnapshot; - this.shardSnapshots = 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 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; - } - } -} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java deleted file mode 100644 index 42f3129728..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotList.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.messages; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -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; - -/** - * Stores a list of DatastoreSnapshot instances. - * - * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshotList} instead. - */ -@Deprecated -public class DatastoreSnapshotList extends ArrayList { - private static final long serialVersionUID = 1L; - - public DatastoreSnapshotList() { - } - - public DatastoreSnapshotList(List snapshots) { - super(snapshots); - } - - private Object readResolve() throws IOException, ClassNotFoundException { - List snapshots = - new ArrayList<>(size()); - for (DatastoreSnapshot legacy: this) { - snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot( - 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 - fromLegacy(List from) throws IOException, ClassNotFoundException { - List snapshots = - new ArrayList<>(from.size()); - for (DatastoreSnapshot.ShardSnapshot legacy: from) { - snapshots.add(new org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot( - legacy.getName(), deserializeShardSnapshot(legacy.getSnapshot()))); - } - - return snapshots; - } - - 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(); - - org.opendaylight.controller.cluster.raft.persisted.Snapshot.State state = EmptyState.INSTANCE; - if (legacy.getState().length > 0) { - state = new ShardSnapshotState(ShardDataTreeSnapshot.deserializePreCarbon(legacy.getState())); - } - - return org.opendaylight.controller.cluster.raft.persisted.Snapshot.create( - state, legacy.getUnAppliedEntries(), legacy.getLastIndex(), - legacy.getLastTerm(), legacy.getLastAppliedIndex(), legacy.getLastAppliedTerm(), - legacy.getElectionTerm(), legacy.getElectionVotedFor(), legacy.getServerConfiguration()); - } - } -} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java index c12403f819..7ebb0055f2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractVersionedShardDataTreeSnapshot.java @@ -8,10 +8,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.base.Verify; -import java.io.DataInputStream; import java.io.IOException; import java.io.ObjectInput; -import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.util.Optional; import javax.annotation.Nonnull; @@ -28,31 +26,6 @@ import org.slf4j.LoggerFactory; abstract class AbstractVersionedShardDataTreeSnapshot extends ShardDataTreeSnapshot { private static final Logger LOG = LoggerFactory.getLogger(AbstractVersionedShardDataTreeSnapshot.class); - @SuppressWarnings("checkstyle:FallThrough") - @Deprecated - static ShardDataTreeSnapshot deserializePreCarbon(final DataInputStream is) throws IOException { - final PayloadVersion version = PayloadVersion.readFrom(is); - switch (version) { - case BORON: - // Boron snapshots use Java Serialization - try (ObjectInputStream ois = new ObjectInputStream(is)) { - return (ShardDataTreeSnapshot) ois.readObject(); - } catch (ClassNotFoundException e) { - LOG.error("Failed to serialize data tree snapshot", e); - throw new IOException("Snapshot failed to deserialize", e); - } - case TEST_FUTURE_VERSION: - case TEST_PAST_VERSION: - // These versions are never returned and this code is effectively dead - break; - default: - throw new IOException("Invalid payload version in snapshot"); - } - - // Not included as default in above switch to ensure we get warnings when new versions are added - throw new IOException("Encountered unhandled version" + version); - } - @SuppressWarnings("checkstyle:FallThrough") static ShardDataTreeSnapshot versionedDeserialize(final ObjectInput in) throws IOException { final PayloadVersion version = PayloadVersion.readFrom(in); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshot.java index 1dbab16c7b..fd35046f04 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshot.java @@ -8,10 +8,7 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.annotations.Beta; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Optional; @@ -32,24 +29,6 @@ public abstract class ShardDataTreeSnapshot { // Hidden to prevent subclassing from outside of this package } - @Deprecated - public static ShardDataTreeSnapshot deserializePreCarbon(final byte[] bytes) throws IOException { - try (InputStream is = new ByteArrayInputStream(bytes)) { - try (DataInputStream dis = new DataInputStream(is)) { - final ShardDataTreeSnapshot ret = AbstractVersionedShardDataTreeSnapshot.deserializePreCarbon(dis); - - // Make sure we consume all bytes, otherwise something went very wrong - final int bytesLeft = dis.available(); - if (bytesLeft != 0) { - throw new IOException("Deserialization left " + bytesLeft + " in the buffer"); - } - - - return ret; - } - } - } - public static ShardDataTreeSnapshot deserialize(final ObjectInput in) throws IOException { final ShardDataTreeSnapshot ret = AbstractVersionedShardDataTreeSnapshot.versionedDeserialize(in); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index 7773556eca..848a8a6cda 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -30,10 +30,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.Uninterruptibles; import com.typesafe.config.ConfigFactory; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; -import java.io.ObjectOutputStream; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -60,7 +57,6 @@ 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.PayloadVersion; import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener; import org.opendaylight.controller.cluster.datastore.utils.MockDataTreeChangeListener; @@ -1305,48 +1301,4 @@ public class DistributedDataStoreIntegrationTest { } }; } - - @Test - @Deprecated - public void testRecoveryFromPreCarbonSnapshot() throws Exception { - new IntegrationTestKit(getSystem(), datastoreContextBuilder) { - { - final String name = "testRecoveryFromPreCarbonSnapshot"; - - final ContainerNode carsNode = CarsModel.newCarsNode( - CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima", BigInteger.valueOf(20000L)), - CarsModel.newCarEntry("sportage", BigInteger.valueOf(30000L)))); - - DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - dataTree.setSchemaContext(SchemaContextHelper.full()); - AbstractShardTest.writeToStore(dataTree, CarsModel.BASE_PATH, carsNode); - NormalizedNode root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY); - - MetadataShardDataTreeSnapshot shardSnapshot = new MetadataShardDataTreeSnapshot(root); - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try (DataOutputStream dos = new DataOutputStream(bos)) { - PayloadVersion.BORON.writeTo(dos); - try (ObjectOutputStream oos = new ObjectOutputStream(dos)) { - oos.writeObject(shardSnapshot); - } - } - - final org.opendaylight.controller.cluster.raft.Snapshot snapshot = - org.opendaylight.controller.cluster.raft.Snapshot.create(bos.toByteArray(), - Collections.emptyList(), 2, 1, 2, 1, 1, "member-1", null); - - InMemorySnapshotStore.addSnapshot("member-1-shard-cars-" + name, snapshot); - - try (AbstractDataStore dataStore = setupAbstractDataStore( - testParameter, name, "module-shards-member1.conf", true, "cars")) { - - DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction(); - - Optional> optional = readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS); - assertEquals("isPresent", true, optional.isPresent()); - assertEquals("Data node", carsNode, optional.get()); - } - } - }; - } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotListTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotListTest.java deleted file mode 100644 index 021a60fbaf..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/DatastoreSnapshotListTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collections; -import java.util.Optional; -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.persisted.PayloadVersion; -import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot; -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.Snapshot; -import org.opendaylight.controller.cluster.raft.persisted.EmptyState; -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.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.DataValidationFailedException; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; -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 { - NormalizedNode legacyConfigRoot1 = toRootNode(CarsModel.BASE_PATH, - CarsModel.newCarsNode(CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima", - BigInteger.valueOf(20000L)),CarsModel.newCarEntry("sportage", - BigInteger.valueOf(30000L))))); - - NormalizedNode legacyConfigRoot2 = toRootNode(PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); - - ShardManagerSnapshot legacyShardManagerSnapshot = newLegacyShardManagerSnapshot("config-one", "config-two"); - DatastoreSnapshot legacyConfigSnapshot = new DatastoreSnapshot("config", - SerializationUtils.serialize(legacyShardManagerSnapshot), - Arrays.asList(newLegacyShardSnapshot("config-one", newLegacySnapshot(legacyConfigRoot1)), - newLegacyShardSnapshot("config-two", newLegacySnapshot(legacyConfigRoot2)))); - - DatastoreSnapshot legacyOperSnapshot = new DatastoreSnapshot("oper", - null, Arrays.asList(newLegacyShardSnapshot("oper-one", newLegacySnapshot(null)))); - - 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), - new org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot( - legacyShardManagerSnapshot.getShardList(), Collections.emptyMap()), - Optional.of(legacyConfigRoot1), Optional.of(legacyConfigRoot2)); - assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1), - (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)null, - Optional.empty()); - } - - @SuppressWarnings("unchecked") - private static void assertDatastoreSnapshotEquals(final DatastoreSnapshot legacy, - final org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual, - final org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot expShardMgrSnapshot, - final Optional>... shardRoots) throws IOException { - assertEquals("Type", legacy.getType(), actual.getType()); - - if (legacy.getShardManagerSnapshot() == null) { - assertNull("Expected null ShardManagerSnapshot", actual.getShardManagerSnapshot()); - } else { - 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()); - } - - 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()), - shardRoots[i], actualShardSnapshot.getSnapshot()); - } - } - - private static void assertSnapshotEquals(final Snapshot expected, final Optional> expRoot, - final org.opendaylight.controller.cluster.raft.persisted.Snapshot actual) throws IOException { - 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()); - - if (expRoot.isPresent()) { - ShardDataTreeSnapshot actualSnapshot = ((ShardSnapshotState)actual.getState()).getSnapshot(); - assertEquals("ShardDataTreeSnapshot type", MetadataShardDataTreeSnapshot.class, actualSnapshot.getClass()); - assertTrue("Expected root node present", actualSnapshot.getRootNode().isPresent()); - assertEquals("Root node", expRoot.get(), actualSnapshot.getRootNode().get()); - } else { - assertEquals("State type", EmptyState.class, actual.getState().getClass()); - } - } - - private static ShardManagerSnapshot newLegacyShardManagerSnapshot(final String... shards) { - return ShardManagerSnapshot.forShardList(Arrays.asList(shards)); - } - - private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(final String name, - final org.opendaylight.controller.cluster.raft.Snapshot snapshot) { - return new DatastoreSnapshot.ShardSnapshot(name, SerializationUtils.serialize(snapshot)); - } - - private static Snapshot newLegacySnapshot(final NormalizedNode root) - throws Exception { - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - if (root != null) { - MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(root); - try (DataOutputStream dos = new DataOutputStream(bos)) { - PayloadVersion.BORON.writeTo(dos); - try (ObjectOutputStream oos = new ObjectOutputStream(dos)) { - oos.writeObject(snapshot); - } - } - } - - return Snapshot.create(bos.toByteArray(), Collections.emptyList(), 2, 1, 2, 1, 1, - "member-1", null); - } - - private static NormalizedNode toRootNode(final YangInstanceIdentifier path, final NormalizedNode node) - throws DataValidationFailedException { - DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - dataTree.setSchemaContext(SchemaContextHelper.full()); - AbstractShardTest.writeToStore(dataTree, path, node); - return AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY); - } -} -- 2.36.6