+
+ private ListenableFuture<?> ensureListExists() {
+
+ final CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder = ImmutableNodes.mapNodeBuilder(ID_INT);
+
+ // hardcoded initial list population for parallel produce-transactions testing on multiple nodes
+ for (int i = 1; i < MAX_PREFIX; i++) {
+ mapBuilder.withChild(
+ ImmutableNodes.mapEntryBuilder(ID_INT, ID, PREFIX_TEMPLATE + i)
+ .withChild(ImmutableNodes.mapNodeBuilder(ITEM).build())
+ .build());
+ }
+ final MapNode mapNode = mapBuilder.build();
+
+ final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID_INTS))
+ .withChild(mapNode)
+ .build();
+
+ final DOMDataTreeProducer producer = domDataTreeService.createProducer(Collections.singleton(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())));
+
+ final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false);
+
+ final DOMDataTreeWriteCursor cursor =
+ tx.createCursor(new DOMDataTreeIdentifier(
+ LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()));
+
+ cursor.merge(containerNode.getIdentifier(), containerNode);
+ cursor.close();
+
+ final ListenableFuture<?> future = tx.commit();
+ Futures.addCallback(future, new FutureCallback<Object>() {
+ @Override
+ public void onSuccess(final Object result) {
+ try {
+ LOG.debug("Closing producer for initial list.");
+ producer.close();
+ } catch (DOMDataTreeProducerException e) {
+ LOG.warn("Error while closing producer.", e);
+ }
+ }
+
+ @Override
+ public void onFailure(final Throwable throwable) {
+ //NOOP handled by the caller of this method.
+ }
+ }, MoreExecutors.directExecutor());
+ return future;
+ }