X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractShardTest.java;h=05d9943622301212c4c1f222a834ef7eb181a81b;hb=0a2ed6b43f45b92f09c291e99e2e66a7fa18085f;hp=d0302eb6feae94a6acb525a5a048a67a437fe275;hpb=5464f50be733df1bbbe31cf05665d542d3b7c5e7;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 d0302eb6fe..05d9943622 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 @@ -31,7 +31,6 @@ import akka.util.Timeout; import com.google.common.base.Optional; import com.google.common.primitives.UnsignedLong; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.Uninterruptibles; import java.io.IOException; import java.util.Collections; @@ -57,9 +56,10 @@ import org.opendaylight.controller.cluster.datastore.modification.MutableComposi 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.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; @@ -125,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 { @@ -206,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)); @@ -220,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; } @@ -314,7 +310,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1); DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); batched.apply(modification); - store.commit(modification); + store.notifyListeners(store.commit(modification)); } public static void writeToStore(final DataTree store, final YangInstanceIdentifier id, @@ -338,7 +334,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { DataTreeModification modification = store.getDataTree().takeSnapshot().newModification(); batched.apply(modification); - store.commit(modification); + store.notifyListeners(store.commit(modification)); } DataTree setupInMemorySnapshotStore() throws DataValidationFailedException { @@ -350,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 PreBoronShardDataTreeSnapshot(root)), + Collections.emptyList(), 0, 1, -1, -1, 1, null, null)); return testStore; } @@ -437,7 +433,7 @@ public abstract class AbstractShardTest extends AbstractActorTest { private FutureCallback preCommit; private FutureCallback commit; - public void setDelegate(ShardDataTreeCohort delegate) { + public void setDelegate(final ShardDataTreeCohort delegate) { this.delegate = delegate; } @@ -472,25 +468,25 @@ public abstract class AbstractShardTest extends AbstractActorTest { } @Override - public void canCommit(FutureCallback callback) { + public void canCommit(final FutureCallback callback) { canCommit = mockFutureCallback(callback); delegate.canCommit(canCommit); } @Override - public void preCommit(FutureCallback callback) { + public void preCommit(final FutureCallback callback) { preCommit = mockFutureCallback(callback); delegate.preCommit(preCommit); } @Override - public void commit(FutureCallback callback) { + public void commit(final FutureCallback callback) { commit = mockFutureCallback(callback); delegate.commit(commit); } @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)); @@ -506,8 +502,8 @@ public abstract class AbstractShardTest extends AbstractActorTest { } @Override - public ListenableFuture abort() { - return delegate.abort(); + public void abort(final FutureCallback callback) { + delegate.abort(callback); } @Override