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;
import akka.cluster.Cluster;
import akka.testkit.javadsl.TestKit;
import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import com.typesafe.config.ConfigFactory;
import java.util.ArrayList;
import java.util.Collection;
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;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeListener;
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 =
cursor.write(test.getIdentifier(), test);
cursor.close();
- tx.submit().checkedGet();
+ tx.commit().get();
}
@Test
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));
cursor.close();
LOG.debug("Got to pre submit");
- tx.submit().checkedGet();
+ tx.commit().get();
final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
captorForSubtrees.capture());
final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
- final java.util.Optional<NormalizedNode<?, ?>> dataAfter =
+ final Optional<NormalizedNode<?, ?>> dataAfter =
capturedValue.get(0).iterator().next().getRootNode().getDataAfter();
final NormalizedNode<?,?> expected = ImmutableContainerNodeBuilder.create()
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
final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory();
final ClientTransaction tx2 = localHistory.createTransaction();
- final FluentFuture<Optional<NormalizedNode<?, ?>>> read = tx2.read(YangInstanceIdentifier.EMPTY);
+ final FluentFuture<Optional<NormalizedNode<?, ?>>> read = tx2.read(YangInstanceIdentifier.empty());
final Optional<NormalizedNode<?, ?>> optional = read.get();
tx2.abort();
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);
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(
cursor.write(new NodeIdentifier(TestModel.INNER_LIST_QNAME), innerList);
cursor.close();
- tx.submit().checkedGet();
+ tx.commit().get();
- final ArrayList<CheckedFuture<Void, TransactionCommitFailedException>> futures = new ArrayList<>();
+ final ArrayList<ListenableFuture<?>> futures = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
final Collection<MapEntryNode> innerListMapEntries = createInnerListMapEntries(1000, "run-" + i);
for (final MapEntryNode innerListMapEntry : innerListMapEntries) {
oid1.node(new NodeIdentifier(TestModel.INNER_LIST_QNAME))));
cursor1.write(innerListMapEntry.getIdentifier(), innerListMapEntry);
cursor1.close();
- futures.add(tx1.submit());
+ futures.add(tx1.commit());
}
}
- futures.get(futures.size() - 1).checkedGet();
+ futures.get(futures.size() - 1).get();
final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
}
final DOMDataTreeIdentifier rootId =
- new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singletonList(
rootId));
cursor.write(testNode.getIdentifier(), testNode);
cursor.close();
- transaction.submit().checkedGet();
+ transaction.commit().get();
final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
cursor.write(wholeList.getIdentifier(), wholeList);
cursor.close();
- transaction.submit().checkedGet();
+ transaction.commit().get();
leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
true, Collections.emptyList());
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));
}
}
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);
final Collection<MapEntryNode> 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))
final Collection<MapEntryNode> 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))
}
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));
}
}