}
}
- list id-ints {
- description "A list of integers nested in list of ids.
- Ids are there to avoid OptimisticLockFailures from different writers.
- Typical use of the int list is to generate data change notifications.
- Config is true, in order to allow Restconf to reset content at will.
- Expected writes should create and delete items at random, values 0 .. 2^20.";
- ordered-by system;
- config true;
- key "id";
- uses llc:id-grouping;
- list item {
- description "Unsorted keyed list item. One write should create or delete up to one item.";
+ container id-ints {
+ list id-int {
+ description "A list of integers nested in list of ids.
+ Ids are there to avoid OptimisticLockFailures from different writers.
+ Typical use of the int list is to generate data change notifications.
+ Config is true, in order to allow Restconf to reset content at will.
+ Expected writes should create and delete items at random, values 0 .. 2^20.";
ordered-by system;
config true;
- key "number";
- leaf number {
- description "The integer value of this item.
- Not range restricted, to allow more scenarios.";
- type int32;
+ key "id";
+ uses llc:id-grouping;
+ list item {
+ description "Unsorted keyed list item. One write should create or delete up to one item.";
+ ordered-by system;
+ config true;
+ key "number";
+ leaf number {
+ description "The integer value of this item.
+ Not range restricted, to allow more scenarios.";
+ type int32;
+ }
}
}
}
-
}
dtclReg = domDataTreeChangeService
.registerDataTreeChangeListener(
new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier(
- CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INTS_YID),
+ CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID),
idIntsListener);
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
ddtlReg =
domDataTreeService.registerListener(idIntsDdtl,
Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
- ProduceTransactionsHandler.ID_INTS_YID))
+ ProduceTransactionsHandler.ID_INT_YID))
, true, Collections.emptyList());
} catch (DOMDataTreeLoopException e) {
LOG.error("Failed to register DOMDataTreeListener.", e);
}
final Optional<NormalizedNode<?, ?>> readResult =
- rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INTS_YID).checkedGet();
+ rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).checkedGet();
if (!readResult.isPresent()) {
final RpcError error = RpcResultBuilder.newError(
try {
final ListenerRegistration<ReadListener> registration = domDataTreeService.registerListener(readListener,
Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
- ProduceTransactionsHandler.ID_INTS_YID))
+ ProduceTransactionsHandler.ID_INT_YID))
, true, Collections.emptyList());
final DataTreeCandidate dataTreeCandidate = readListener.getFirstNotif().get();
RpcResultBuilder.success(new UnsubscribeDdtlOutputBuilder()
.setCopyMatches(idIntsDdtl.checkEqual(lastRead))).build());
-
} catch (final DOMDataTreeLoopException | InterruptedException | ExecutionException e) {
LOG.error("Unable to read data to verify ddtl data.", e);
final RpcError error = RpcResultBuilder.newError(
changes.forEach(change -> {
if (change.getRootNode().getDataAfter().isPresent()) {
- LOG.trace("Received change, data before: {}, data after: ", change.getRootNode().getDataBefore().get(),
+ LOG.trace("Received change, data before: {}, data after: ",
+ change.getRootNode().getDataBefore().isPresent()
+ ? change.getRootNode().getDataBefore().get() : "",
change.getRootNode().getDataAfter().get());
if (localCopy == null || checkEqual(change.getRootNode().getDataBefore().get())) {
changes.forEach(change -> {
if (change.getRootNode().getDataAfter().isPresent()) {
- LOG.trace("Received change, data before: {}, data after: ", change.getRootNode().getDataBefore().get(),
+ LOG.trace("Received change, data before: {}, data after: ",
+ change.getRootNode().getDataBefore().isPresent()
+ ? change.getRootNode().getDataBefore().get() : "",
change.getRootNode().getDataAfter().get());
if (localCopy == null || checkEqual(change.getRootNode().getDataBefore().get())) {
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final QName ID_INTS =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-ints");
+ private static final QName ID_INT =
+ QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-int");
private static final QName ID =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id");
private static final QName ITEM =
private static final QName NUMBER =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "number");
- public static final YangInstanceIdentifier ID_INTS_YID =
- YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(ID_INTS));
+ public static final YangInstanceIdentifier ID_INTS_YID = YangInstanceIdentifier.of(ID_INTS);
+ public static final YangInstanceIdentifier ID_INT_YID = ID_INTS_YID.node(ID_INT);
private final DOMDataTreeService domDataTreeService;
}
public void start(final SettableFuture<RpcResult<ProduceTransactionsOutput>> settableFuture) {
+ completionFuture = settableFuture;
if (ensureListExists(completionFuture) && fillInitialList(completionFuture)) {
startTime = System.nanoTime();
- completionFuture = settableFuture;
scheduledFuture = executor.scheduleAtFixedRate(this, 0, delay, TimeUnit.NANOSECONDS);
} else {
executor.shutdown();
private boolean ensureListExists(final SettableFuture<RpcResult<ProduceTransactionsOutput>> settableFuture) {
- final MapEntryNode entry = ImmutableNodes.mapEntryBuilder(ID_INTS, ID, id)
+ final MapEntryNode entry = ImmutableNodes.mapEntryBuilder(ID_INT, ID, id)
.withChild(ImmutableNodes.mapNodeBuilder(ITEM).build())
.build();
final MapNode mapNode =
- ImmutableNodes.mapNodeBuilder(ID_INTS)
+ ImmutableNodes.mapNodeBuilder(ID_INT)
.withChild(entry)
.build();
+ final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(ID_INTS))
+ .withChild(mapNode)
+ .build();
+
final DOMDataTreeProducer producer = domDataTreeService.createProducer(Collections.singleton(
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)));
tx.createCursor(new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY));
- idListWithKey = ID_INTS_YID.node(entry.getIdentifier());
+ idListWithKey = ID_INT_YID.node(entry.getIdentifier());
- cursor.merge(mapNode.getIdentifier(), mapNode);
+ cursor.merge(containerNode.getIdentifier(), containerNode);
cursor.close();
try {
final int i = random.nextInt(MAX_ITEM + 1);
final YangInstanceIdentifier entryId =
- idListWithKey.node(ITEM).node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(ITEM, NUMBER, i));
+ idListWithKey.node(ITEM).node(new NodeIdentifierWithPredicates(ITEM, NUMBER, i));
final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false);
final DOMDataTreeWriteCursor cursor = tx.createCursor(
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final QName ID_INTS =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-ints");
+ private static final QName ID_INT =
+ QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-int");
private static final QName ID =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id");
private static final QName ITEM =
QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "number");
public static final YangInstanceIdentifier ID_INTS_YID = YangInstanceIdentifier.of(ID_INTS);
+ public static final YangInstanceIdentifier ID_INT_YID = ID_INTS_YID.node(ID_INT);
private final DOMDataBroker domDataBroker;
private final Long timeToTake;
private boolean ensureListExists(final SettableFuture<RpcResult<WriteTransactionsOutput>> settableFuture) {
- final MapNode mapNode = ImmutableNodes.mapNodeBuilder(ID_INTS).build();
+ final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(ID_INTS))
+ .withChild(ImmutableNodes.mapNodeBuilder(ID_INT).build())
+ .build();
DOMDataWriteTransaction tx = txProvider.createTransaction();
// write only the top list
- tx.merge(LogicalDatastoreType.CONFIGURATION, ID_INTS_YID, mapNode);
+ tx.merge(LogicalDatastoreType.CONFIGURATION, ID_INTS_YID, containerNode);
try {
tx.submit().checkedGet();
} catch (final OptimisticLockFailedException e) {
return false;
}
- final MapEntryNode entry = ImmutableNodes.mapEntryBuilder(ID_INTS, ID, id)
+ final MapEntryNode entry = ImmutableNodes.mapEntryBuilder(ID_INT, ID, id)
.withChild(ImmutableNodes.mapNodeBuilder(ITEM).build())
.build();
- idListWithKey = ID_INTS_YID.node(entry.getIdentifier());
+ idListWithKey = ID_INT_YID.node(entry.getIdentifier());
tx = txProvider.createTransaction();
tx.merge(LogicalDatastoreType.CONFIGURATION, idListWithKey, entry);