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%2Fsharding%2FDistributedShardedDOMDataTreeTest.java;h=8f9002c2569f8022fcba7a05e6815a9084bd9024;hb=f8f30f62f7a7029ea878737251eb136f20da2fce;hp=6eada08acb33945602ca595d7c3836ad72a2fb3d;hpb=aea716f562ae010af4687812fab27af03f8a2a26;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java index 6eada08acb..8f9002c256 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java @@ -11,8 +11,8 @@ package org.opendaylight.controller.cluster.sharding; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyCollection; -import static org.mockito.Matchers.anyMap; +import static org.mockito.ArgumentMatchers.anyCollection; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -62,13 +62,12 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContext; import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder; import org.opendaylight.controller.cluster.datastore.DistributedDataStore; import org.opendaylight.controller.cluster.datastore.IntegrationTestKit; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils; import org.opendaylight.controller.cluster.dom.api.CDSDataTreeProducer; import org.opendaylight.controller.cluster.dom.api.CDSShardAccess; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; -import org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -187,14 +186,14 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { initEmptyDatastores(); final DOMDataTreeIdentifier configRoot = - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot)); final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true); final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier( - LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)); + LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())); Assert.assertNotNull(cursor); final ContainerNode test = @@ -215,7 +214,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(TEST_ID)); @@ -246,7 +245,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { captorForSubtrees.capture()); final List> capturedValue = captorForChanges.getAllValues(); - final java.util.Optional> dataAfter = + final Optional> dataAfter = capturedValue.get(0).iterator().next().getRootNode().getDataAfter(); final NormalizedNode expected = ImmutableContainerNodeBuilder.create() @@ -258,10 +257,10 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { final String shardName = ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()); LOG.debug("Creating distributed datastore client for shard {}", shardName); - final ActorContext actorContext = leaderDistributedDataStore.getActorContext(); + final ActorUtils actorUtils = leaderDistributedDataStore.getActorUtils(); final Props distributedDataStoreClientProps = - SimpleDataStoreClientActor.props(actorContext.getCurrentMemberName(), - "Shard-" + shardName, actorContext, shardName); + SimpleDataStoreClientActor.props(actorUtils.getCurrentMemberName(), "Shard-" + shardName, actorUtils, + shardName); final ActorRef clientActor = leaderSystem.actorOf(distributedDataStoreClientProps); final DataStoreClient distributedDataStoreClient = SimpleDataStoreClientActor @@ -269,7 +268,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory(); final ClientTransaction tx2 = localHistory.createTransaction(); - final FluentFuture>> read = tx2.read(YangInstanceIdentifier.EMPTY); + final FluentFuture>> read = tx2.read(YangInstanceIdentifier.empty()); final Optional> optional = read.get(); tx2.abort(); @@ -287,13 +286,13 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); LOG.warn("Got after waiting for nonleader"); - final ActorRef leaderShardManager = leaderDistributedDataStore.getActorContext().getShardManager(); + final ActorRef leaderShardManager = leaderDistributedDataStore.getActorUtils().getShardManager(); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); final YangInstanceIdentifier oid1 = getOuterListIdFor(0); @@ -303,7 +302,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { leaderShardFactory.createDistributedShard(outerListPath, Lists.newArrayList(AbstractTest.MEMBER_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(outerListPath.getRootIdentifier())); final DOMDataTreeProducer shardProducer = leaderShardFactory.createProducer( @@ -384,7 +383,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { } final DOMDataTreeIdentifier rootId = - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singletonList( rootId)); @@ -463,15 +462,15 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(), + assertNotNull(findLocalShard(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - waitUntilShardIsDown(leaderDistributedDataStore.getActorContext(), + waitUntilShardIsDown(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); } } @@ -484,15 +483,15 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(), + assertNotNull(findLocalShard(leaderDistributedDataStore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); final DOMDataTreeIdentifier configRoot = - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot)); assertTrue(producer instanceof CDSDataTreeProducer); @@ -514,7 +513,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { final Collection ret = new ArrayList<>(); for (int i = 0; i < amount; i++) { ret.add(ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, + .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), i)) .withChild(ImmutableNodes .leafNode(QName.create(TestModel.OUTER_LIST_QNAME, "id"), i)) @@ -534,7 +533,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { final Collection ret = new ArrayList<>(); for (int i = 0; i < amount; i++) { ret.add(ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.INNER_LIST_QNAME, + .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i))) .withChild(ImmutableNodes .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "value"), valuePrefix + "-" + i)) @@ -545,7 +544,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { } private static YangInstanceIdentifier getOuterListIdFor(final int id) { - return TestModel.OUTER_LIST_PATH.node(new NodeIdentifierWithPredicates( + return TestModel.OUTER_LIST_PATH.node(NodeIdentifierWithPredicates.of( TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), id)); } }