+ transaction.submit().checkedGet();
+
+ leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
+ true, Collections.emptyList());
+
+ // need 6 invocations, first initial thats from the parent shard, and then each individual subshard
+ verify(mockedDataTreeListener, timeout(10000).times(6)).onDataTreeChanged(captorForChanges.capture(),
+ captorForSubtrees.capture());
+ verifyNoMoreInteractions(mockedDataTreeListener);
+ final List<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> allSubtrees = captorForSubtrees.getAllValues();
+
+ final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> lastSubtree = allSubtrees.get(allSubtrees.size() - 1);
+
+ final NormalizedNode<?, ?> actual = lastSubtree.get(TEST_ID);
+ assertNotNull(actual);
+
+ final NormalizedNode<?, ?> expected =
+ ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(ImmutableMapNodeBuilder.create(outerList)
+ .withValue(createOuterEntries(listSize, "testing-values")).build())
+ .build();
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testDistributedData() throws Exception {
+ initEmptyDatastore("config");
+
+ waitOnAsyncTask(
+ leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ waitOnAsyncTask(
+ leaderShardFactory.createDistributedShard(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_CONTAINER_PATH),
+ Lists.newArrayList(AbstractTest.MEMBER_NAME)),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ waitOnAsyncTask(
+ leaderShardFactory.createDistributedShard(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.INNER_LIST_PATH),
+ Lists.newArrayList(AbstractTest.MEMBER_NAME)),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ waitOnAsyncTask(
+ leaderShardFactory.createDistributedShard(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.JUNK_PATH),
+ Lists.newArrayList(AbstractTest.MEMBER_NAME)),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
+ leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH));
+ leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH));
+ leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.JUNK_PATH));
+
+ }
+
+ @Test
+ public void testMultipleRegistrationsAtOnePrefix() throws Exception {
+ initEmptyDatastore("config");
+
+ for (int i = 0; i < 10; i++) {
+ LOG.debug("Round {}", i);
+ final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard(
+ TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
+ DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
+
+ assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.TEST_PATH)));
+
+ waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
+
+ waitUntilShardIsDown(leaderDistributedDataStore.getActorContext(),
+ ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
+ }
+ }
+
+ private static Collection<MapEntryNode> createOuterEntries(final int amount, final String valuePrefix) {
+ final Collection<MapEntryNode> ret = new ArrayList<>();
+ for (int i = 0; i < amount; i++) {
+ ret.add(ImmutableNodes.mapEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
+ QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
+ .withChild(ImmutableNodes
+ .leafNode(QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
+ .withChild(createWholeInnerList(amount, "outer id: " + i + " " + valuePrefix))
+ .build());
+ }
+
+ return ret;
+ }
+
+ private static MapNode createWholeInnerList(final int amount, final String valuePrefix) {
+ return ImmutableMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+ .withValue(createInnerListMapEntries(amount, valuePrefix)).build();
+ }
+
+ private static Collection<MapEntryNode> createInnerListMapEntries(final int amount, final String valuePrefix) {
+ final Collection<MapEntryNode> ret = new ArrayList<>();
+ for (int i = 0; i < amount; i++) {
+ ret.add(ImmutableNodes.mapEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifierWithPredicates(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))
+ .build());
+ }
+
+ return ret;
+ }