2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.sharding;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.mockito.ArgumentMatchers.anyCollection;
15 import static org.mockito.ArgumentMatchers.anyMap;
16 import static org.mockito.Mockito.doNothing;
17 import static org.mockito.Mockito.doReturn;
18 import static org.mockito.Mockito.mock;
19 import static org.mockito.Mockito.timeout;
20 import static org.mockito.Mockito.verify;
21 import static org.mockito.Mockito.verifyNoMoreInteractions;
22 import static org.opendaylight.controller.cluster.datastore.IntegrationTestKit.findLocalShard;
23 import static org.opendaylight.controller.cluster.datastore.IntegrationTestKit.waitUntilShardIsDown;
25 import akka.actor.ActorRef;
26 import akka.actor.ActorSystem;
27 import akka.actor.Address;
28 import akka.actor.AddressFromURIString;
29 import akka.actor.Props;
30 import akka.cluster.Cluster;
31 import akka.testkit.javadsl.TestKit;
32 import com.google.common.collect.Lists;
33 import com.google.common.util.concurrent.FluentFuture;
34 import com.google.common.util.concurrent.ListenableFuture;
35 import com.typesafe.config.ConfigFactory;
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.List;
41 import java.util.Optional;
43 import java.util.concurrent.CompletionStage;
44 import java.util.concurrent.TimeUnit;
45 import org.junit.After;
46 import org.junit.Assert;
47 import org.junit.Before;
48 import org.junit.Ignore;
49 import org.junit.Test;
50 import org.mockito.ArgumentCaptor;
51 import org.mockito.Captor;
52 import org.mockito.Mockito;
53 import org.mockito.MockitoAnnotations;
54 import org.opendaylight.controller.cluster.ActorSystemProvider;
55 import org.opendaylight.controller.cluster.access.concepts.MemberName;
56 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory;
57 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
58 import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient;
59 import org.opendaylight.controller.cluster.databroker.actors.dds.SimpleDataStoreClientActor;
60 import org.opendaylight.controller.cluster.datastore.AbstractTest;
61 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
62 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
63 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
64 import org.opendaylight.controller.cluster.datastore.IntegrationTestKit;
65 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
66 import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
67 import org.opendaylight.controller.cluster.dom.api.CDSDataTreeProducer;
68 import org.opendaylight.controller.cluster.dom.api.CDSShardAccess;
69 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
70 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
71 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
72 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
73 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
74 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
75 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
76 import org.opendaylight.mdsal.dom.api.DOMDataTreeListener;
77 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
78 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
79 import org.opendaylight.yangtools.yang.common.QName;
80 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
81 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
82 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
83 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
84 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
85 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
86 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
87 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
88 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
89 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
90 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
91 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
92 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
93 import org.slf4j.Logger;
94 import org.slf4j.LoggerFactory;
96 public class DistributedShardedDOMDataTreeTest extends AbstractTest {
98 private static final Logger LOG = LoggerFactory.getLogger(DistributedShardedDOMDataTreeRemotingTest.class);
100 private static final Address MEMBER_1_ADDRESS =
101 AddressFromURIString.parse("akka.tcp://cluster-test@127.0.0.1:2558");
103 private static final DOMDataTreeIdentifier TEST_ID =
104 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
106 private static final DOMDataTreeIdentifier INNER_LIST_ID =
107 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
108 YangInstanceIdentifier.create(getOuterListIdFor(0).getPathArguments())
109 .node(TestModel.INNER_LIST_QNAME));
110 private static final Set<MemberName> SINGLE_MEMBER = Collections.singleton(AbstractTest.MEMBER_NAME);
112 private static final String MODULE_SHARDS_CONFIG = "module-shards-default-member-1.conf";
114 private ActorSystem leaderSystem;
116 private final Builder leaderDatastoreContextBuilder =
117 DatastoreContext.newBuilder()
118 .shardHeartbeatIntervalInMillis(100)
119 .shardElectionTimeoutFactor(2)
120 .logicalStoreType(LogicalDatastoreType.CONFIGURATION);
122 private DistributedDataStore leaderDistributedDataStore;
123 private DistributedDataStore operDistributedDatastore;
124 private IntegrationTestKit leaderTestKit;
126 private DistributedShardedDOMDataTree leaderShardFactory;
129 private ArgumentCaptor<Collection<DataTreeCandidate>> captorForChanges;
131 private ArgumentCaptor<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> captorForSubtrees;
133 private ActorSystemProvider leaderSystemProvider;
136 public void setUp() {
137 MockitoAnnotations.initMocks(this);
139 InMemoryJournal.clear();
140 InMemorySnapshotStore.clear();
142 leaderSystem = ActorSystem.create("cluster-test", ConfigFactory.load().getConfig("Member1"));
143 Cluster.get(leaderSystem).join(MEMBER_1_ADDRESS);
145 leaderSystemProvider = Mockito.mock(ActorSystemProvider.class);
146 doReturn(leaderSystem).when(leaderSystemProvider).getActorSystem();
150 public void tearDown() {
151 if (leaderDistributedDataStore != null) {
152 leaderDistributedDataStore.close();
155 if (operDistributedDatastore != null) {
156 operDistributedDatastore.close();
159 TestKit.shutdownActorSystem(leaderSystem);
161 InMemoryJournal.clear();
162 InMemorySnapshotStore.clear();
165 private void initEmptyDatastores() throws Exception {
166 leaderTestKit = new IntegrationTestKit(leaderSystem, leaderDatastoreContextBuilder);
168 leaderDistributedDataStore = leaderTestKit.setupDistributedDataStore(
169 "config", MODULE_SHARDS_CONFIG, "empty-modules.conf", true,
170 SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext());
172 operDistributedDatastore = leaderTestKit.setupDistributedDataStore(
173 "operational", MODULE_SHARDS_CONFIG, "empty-modules.conf",true,
174 SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext());
176 leaderShardFactory = new DistributedShardedDOMDataTree(leaderSystemProvider,
177 operDistributedDatastore,
178 leaderDistributedDataStore);
180 leaderShardFactory.init();
185 public void testWritesIntoDefaultShard() throws Exception {
186 initEmptyDatastores();
188 final DOMDataTreeIdentifier configRoot =
189 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
191 final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot));
193 final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true);
194 final DOMDataTreeWriteCursor cursor =
195 tx.createCursor(new DOMDataTreeIdentifier(
196 LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()));
197 Assert.assertNotNull(cursor);
199 final ContainerNode test =
200 ImmutableContainerNodeBuilder.create()
201 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
203 cursor.write(test.getIdentifier(), test);
210 public void testSingleNodeWritesAndRead() throws Exception {
211 initEmptyDatastores();
213 final DistributedShardRegistration shardRegistration = waitOnAsyncTask(
214 leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
215 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
217 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
218 ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()));
220 final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(TEST_ID));
222 final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true);
223 final DOMDataTreeWriteCursor cursor = tx.createCursor(TEST_ID);
224 Assert.assertNotNull(cursor);
225 final YangInstanceIdentifier nameId =
226 YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(TestModel.NAME_QNAME).build();
227 final LeafNode<String> valueToCheck = ImmutableLeafNodeBuilder.<String>create().withNodeIdentifier(
228 new NodeIdentifier(TestModel.NAME_QNAME)).withValue("Test Value").build();
229 LOG.debug("Writing data {} at {}, cursor {}", nameId.getLastPathArgument(), valueToCheck, cursor);
230 cursor.write(nameId.getLastPathArgument(),
234 LOG.debug("Got to pre submit");
238 final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
239 doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
241 leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
242 true, Collections.emptyList());
244 verify(mockedDataTreeListener, timeout(1000).times(1)).onDataTreeChanged(captorForChanges.capture(),
245 captorForSubtrees.capture());
246 final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
248 final Optional<NormalizedNode<?, ?>> dataAfter =
249 capturedValue.get(0).iterator().next().getRootNode().getDataAfter();
251 final NormalizedNode<?,?> expected = ImmutableContainerNodeBuilder.create()
252 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).withChild(valueToCheck).build();
253 assertEquals(expected, dataAfter.get());
255 verifyNoMoreInteractions(mockedDataTreeListener);
257 final String shardName = ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier());
258 LOG.debug("Creating distributed datastore client for shard {}", shardName);
260 final ActorUtils actorUtils = leaderDistributedDataStore.getActorUtils();
261 final Props distributedDataStoreClientProps =
262 SimpleDataStoreClientActor.props(actorUtils.getCurrentMemberName(), "Shard-" + shardName, actorUtils,
265 final ActorRef clientActor = leaderSystem.actorOf(distributedDataStoreClientProps);
266 final DataStoreClient distributedDataStoreClient = SimpleDataStoreClientActor
267 .getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS);
269 final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory();
270 final ClientTransaction tx2 = localHistory.createTransaction();
271 final FluentFuture<Optional<NormalizedNode<?, ?>>> read = tx2.read(YangInstanceIdentifier.empty());
273 final Optional<NormalizedNode<?, ?>> optional = read.get();
275 localHistory.close();
277 shardRegistration.close().toCompletableFuture().get();
282 public void testMultipleWritesIntoSingleMapEntry() throws Exception {
283 initEmptyDatastores();
285 final DistributedShardRegistration shardRegistration = waitOnAsyncTask(
286 leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
287 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
289 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
290 ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()));
292 LOG.warn("Got after waiting for nonleader");
293 final ActorRef leaderShardManager = leaderDistributedDataStore.getActorUtils().getShardManager();
295 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
296 ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
298 final YangInstanceIdentifier oid1 = getOuterListIdFor(0);
299 final DOMDataTreeIdentifier outerListPath = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1);
301 final DistributedShardRegistration outerListShardReg = waitOnAsyncTask(
302 leaderShardFactory.createDistributedShard(outerListPath, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
303 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
305 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
306 ClusterUtils.getCleanShardName(outerListPath.getRootIdentifier()));
308 final DOMDataTreeProducer shardProducer = leaderShardFactory.createProducer(
309 Collections.singletonList(outerListPath));
311 final DOMDataTreeCursorAwareTransaction tx = shardProducer.createTransaction(false);
312 final DOMDataTreeWriteCursor cursor =
313 tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1));
314 assertNotNull(cursor);
316 MapNode innerList = ImmutableMapNodeBuilder
318 .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
321 cursor.write(new NodeIdentifier(TestModel.INNER_LIST_QNAME), innerList);
325 final ArrayList<ListenableFuture<?>> futures = new ArrayList<>();
326 for (int i = 0; i < 1000; i++) {
327 final Collection<MapEntryNode> innerListMapEntries = createInnerListMapEntries(1000, "run-" + i);
328 for (final MapEntryNode innerListMapEntry : innerListMapEntries) {
329 final DOMDataTreeCursorAwareTransaction tx1 = shardProducer.createTransaction(false);
330 final DOMDataTreeWriteCursor cursor1 = tx1.createCursor(
331 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
332 oid1.node(new NodeIdentifier(TestModel.INNER_LIST_QNAME))));
333 cursor1.write(innerListMapEntry.getIdentifier(), innerListMapEntry);
335 futures.add(tx1.commit());
339 futures.get(futures.size() - 1).get();
341 final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
342 doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
344 leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_LIST_ID),
345 true, Collections.emptyList());
347 verify(mockedDataTreeListener, timeout(1000).times(1)).onDataTreeChanged(captorForChanges.capture(),
348 captorForSubtrees.capture());
349 verifyNoMoreInteractions(mockedDataTreeListener);
350 final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
352 final NormalizedNode<?,?> expected =
353 ImmutableMapNodeBuilder
355 .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
356 // only the values from the last run should be present
357 .withValue(createInnerListMapEntries(1000, "run-999"))
360 assertEquals("List values dont match the expected values from the last run",
361 expected, capturedValue.get(0).iterator().next().getRootNode().getDataAfter().get());
365 // top level shard at TEST element, with subshards on each outer-list map entry
368 public void testMultipleShardLevels() throws Exception {
369 initEmptyDatastores();
371 final DistributedShardRegistration testShardReg = waitOnAsyncTask(
372 leaderShardFactory.createDistributedShard(TEST_ID, SINGLE_MEMBER),
373 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
375 final ArrayList<DistributedShardRegistration> registrations = new ArrayList<>();
376 final int listSize = 5;
377 for (int i = 0; i < listSize; i++) {
378 final YangInstanceIdentifier entryYID = getOuterListIdFor(i);
379 final CompletionStage<DistributedShardRegistration> future = leaderShardFactory.createDistributedShard(
380 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, entryYID), SINGLE_MEMBER);
382 registrations.add(waitOnAsyncTask(future, DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION));
385 final DOMDataTreeIdentifier rootId =
386 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
387 final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singletonList(
390 DOMDataTreeCursorAwareTransaction transaction = producer.createTransaction(false);
392 DOMDataTreeWriteCursor cursor = transaction.createCursor(rootId);
393 assertNotNull(cursor);
395 final MapNode outerList =
396 ImmutableMapNodeBuilder.create()
397 .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build();
399 final ContainerNode testNode =
400 ImmutableContainerNodeBuilder.create()
401 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
402 .withChild(outerList)
405 cursor.write(testNode.getIdentifier(), testNode);
408 transaction.commit().get();
410 final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
411 doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
413 final MapNode wholeList = ImmutableMapNodeBuilder.create(outerList)
414 .withValue(createOuterEntries(listSize, "testing-values")).build();
416 transaction = producer.createTransaction(false);
417 cursor = transaction.createCursor(TEST_ID);
418 assertNotNull(cursor);
420 cursor.write(wholeList.getIdentifier(), wholeList);
423 transaction.commit().get();
425 leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
426 true, Collections.emptyList());
428 verify(mockedDataTreeListener, timeout(35000).atLeast(2)).onDataTreeChanged(captorForChanges.capture(),
429 captorForSubtrees.capture());
430 verifyNoMoreInteractions(mockedDataTreeListener);
431 final List<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> allSubtrees = captorForSubtrees.getAllValues();
433 final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> lastSubtree = allSubtrees.get(allSubtrees.size() - 1);
435 final NormalizedNode<?, ?> actual = lastSubtree.get(TEST_ID);
436 assertNotNull(actual);
438 final NormalizedNode<?, ?> expected =
439 ImmutableContainerNodeBuilder.create()
440 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
441 .withChild(ImmutableMapNodeBuilder.create(outerList)
442 .withValue(createOuterEntries(listSize, "testing-values")).build())
446 for (final DistributedShardRegistration registration : registrations) {
447 waitOnAsyncTask(registration.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
450 waitOnAsyncTask(testShardReg.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
452 assertEquals(expected, actual);
456 public void testMultipleRegistrationsAtOnePrefix() throws Exception {
457 initEmptyDatastores();
459 for (int i = 0; i < 10; i++) {
460 LOG.debug("Round {}", i);
461 final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard(
462 TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
463 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
465 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
466 ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
468 assertNotNull(findLocalShard(leaderDistributedDataStore.getActorUtils(),
469 ClusterUtils.getCleanShardName(TestModel.TEST_PATH)));
471 waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
473 waitUntilShardIsDown(leaderDistributedDataStore.getActorUtils(),
474 ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
479 public void testCDSDataTreeProducer() throws Exception {
480 initEmptyDatastores();
482 final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard(
483 TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
484 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
486 leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorUtils(),
487 ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
489 assertNotNull(findLocalShard(leaderDistributedDataStore.getActorUtils(),
490 ClusterUtils.getCleanShardName(TestModel.TEST_PATH)));
493 final DOMDataTreeIdentifier configRoot =
494 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
495 final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot));
497 assertTrue(producer instanceof CDSDataTreeProducer);
499 final CDSDataTreeProducer cdsProducer = (CDSDataTreeProducer) producer;
500 CDSShardAccess shardAccess = cdsProducer.getShardAccess(TEST_ID);
501 assertEquals(shardAccess.getShardIdentifier(), TEST_ID);
503 shardAccess = cdsProducer.getShardAccess(INNER_LIST_ID);
504 assertEquals(TEST_ID, shardAccess.getShardIdentifier());
506 shardAccess = cdsProducer.getShardAccess(configRoot);
507 assertEquals(configRoot, shardAccess.getShardIdentifier());
509 waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
512 private static Collection<MapEntryNode> createOuterEntries(final int amount, final String valuePrefix) {
513 final Collection<MapEntryNode> ret = new ArrayList<>();
514 for (int i = 0; i < amount; i++) {
515 ret.add(ImmutableNodes.mapEntryBuilder()
516 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
517 QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
518 .withChild(ImmutableNodes
519 .leafNode(QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
520 .withChild(createWholeInnerList(amount, "outer id: " + i + " " + valuePrefix))
527 private static MapNode createWholeInnerList(final int amount, final String valuePrefix) {
528 return ImmutableMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
529 .withValue(createInnerListMapEntries(amount, valuePrefix)).build();
532 private static Collection<MapEntryNode> createInnerListMapEntries(final int amount, final String valuePrefix) {
533 final Collection<MapEntryNode> ret = new ArrayList<>();
534 for (int i = 0; i < amount; i++) {
535 ret.add(ImmutableNodes.mapEntryBuilder()
536 .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME,
537 QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i)))
538 .withChild(ImmutableNodes
539 .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "value"), valuePrefix + "-" + i))
546 private static YangInstanceIdentifier getOuterListIdFor(final int id) {
547 return TestModel.OUTER_LIST_PATH.node(NodeIdentifierWithPredicates.of(
548 TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), id));