X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractShardTest.java;h=e99710e2fc9edcfc3f0b86e50bc2a6074dce4f5b;hb=b5cb353e3553a39f576c284119af75ffa5ea66a9;hp=ab7e8f040159471c3290713797d2105a321584a8;hpb=5fd8e6506248cc34da72281a1662612f6c2b2f9a;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java index ab7e8f0401..e99710e2fc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java @@ -55,10 +55,11 @@ import org.opendaylight.controller.cluster.datastore.modification.MergeModificat import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload; -import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot; +import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.Snapshot; import org.opendaylight.controller.cluster.raft.TestActorFactory; +import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; @@ -124,7 +125,8 @@ public abstract class AbstractShardTest extends AbstractActorTest { } protected Shard.Builder newShardBuilder() { - return Shard.builder().id(shardID).datastoreContext(newDatastoreContext()).schemaContext(SCHEMA_CONTEXT); + return Shard.builder().id(shardID).datastoreContext(newDatastoreContext()) + .schemaContextProvider(() -> SCHEMA_CONTEXT); } protected void testRecovery(final Set listEntryKeys) throws Exception { @@ -205,9 +207,8 @@ public abstract class AbstractShardTest extends AbstractActorTest { return null; }).when(mock).validate(any(DataTreeModification.class)); - doAnswer(invocation -> { - return actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class)); - }).when(mock).prepare(any(DataTreeModification.class)); + doAnswer(invocation -> actual.prepare(invocation.getArgumentAt(0, DataTreeModification.class))).when( + mock).prepare(any(DataTreeModification.class)); doAnswer(invocation -> { actual.commit(invocation.getArgumentAt(0, DataTreeCandidate.class)); @@ -219,13 +220,9 @@ public abstract class AbstractShardTest extends AbstractActorTest { return null; }).when(mock).setSchemaContext(any(SchemaContext.class)); - doAnswer(invocation -> { - return actual.takeSnapshot(); - }).when(mock).takeSnapshot(); + doAnswer(invocation -> actual.takeSnapshot()).when(mock).takeSnapshot(); - doAnswer(invocation -> { - return actual.getRootPath(); - }).when(mock).getRootPath(); + doAnswer(invocation -> actual.getRootPath()).when(mock).getRootPath(); return mock; } @@ -309,11 +306,11 @@ public abstract class AbstractShardTest extends AbstractActorTest { } public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id, - final NormalizedNode node) throws Exception { + final NormalizedNode node) throws DataValidationFailedException { BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1); DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); batched.apply(modification); - store.commit(modification); + store.notifyListeners(commitTransaction(store.getDataTree(), modification)); } public static void writeToStore(final DataTree store, final YangInstanceIdentifier id, @@ -328,7 +325,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { } public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id, - final NormalizedNode node) throws Exception { + final NormalizedNode node) throws DataValidationFailedException { final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION); batched.addModification(new MergeModification(id, node)); batched.setReady(true); @@ -337,7 +334,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); batched.apply(modification); - store.commit(modification); + store.notifyListeners(commitTransaction(store.getDataTree(), modification)); } DataTree setupInMemorySnapshotStore() throws DataValidationFailedException { @@ -349,8 +346,8 @@ public abstract class AbstractShardTest extends AbstractActorTest { final NormalizedNode root = readStore(testStore, YangInstanceIdentifier.EMPTY); InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create( - new PreBoronShardDataTreeSnapshot(root).serialize(), - Collections.emptyList(), 0, 1, -1, -1)); + new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)), + Collections.emptyList(), 0, 1, -1, -1, 1, null, null)); return testStore; } @@ -409,11 +406,13 @@ public abstract class AbstractShardTest extends AbstractActorTest { return mockCandidate; } - static void commitTransaction(final DataTree store, final DataTreeModification modification) + static DataTreeCandidate commitTransaction(final DataTree store, final DataTreeModification modification) throws DataValidationFailedException { modification.ready(); store.validate(modification); - store.commit(store.prepare(modification)); + final DataTreeCandidate candidate = store.prepare(modification); + store.commit(candidate); + return candidate; } @SuppressWarnings("serial") @@ -489,7 +488,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { } @SuppressWarnings("unchecked") - private FutureCallback mockFutureCallback(final FutureCallback actual ) { + private static FutureCallback mockFutureCallback(final FutureCallback actual) { FutureCallback mock = mock(FutureCallback.class); doAnswer(invocation -> { actual.onFailure(invocation.getArgumentAt(0, Throwable.class));