use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class TxchainDomWrite method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
final DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
int writeCnt = 0;
for (MapEntryNode element : this.list) {
YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
if (oper == StartTestInput.Operation.PUT) {
tx.put(dsType, yid, element);
} else {
tx.merge(dsType, yid, element);
}
writeCnt++;
// Start performing the operation; submit the transaction at every n-th operation
if (writeCnt == writesPerTx) {
txSubmitted++;
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
txOk++;
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Transaction failed, {}", t);
txError++;
}
});
tx = chain.newWriteOnlyTransaction();
writeCnt = 0;
}
}
try {
txSubmitted++;
tx.submit().checkedGet();
txOk++;
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed", e);
txError++;
}
try {
chain.close();
} catch (final IllegalStateException e) {
LOG.error("Transaction close failed,", e);
}
LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class ProduceTransactionsHandler method execWrite.
@Override
ListenableFuture<Void> execWrite(final long txId) {
final int i = random.nextInt(MAX_ITEM + 1);
final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false);
final DOMDataTreeWriteCursor cursor = tx.createCursor(idListItem);
final NodeIdentifierWithPredicates entryId = new NodeIdentifierWithPredicates(ITEM, NUMBER, i);
if (usedValues.contains(i)) {
LOG.debug("Deleting item: {}", i);
deleteTx++;
cursor.delete(entryId);
usedValues.remove(i);
} else {
LOG.debug("Inserting item: {}", i);
insertTx++;
final MapEntryNode entry = ImmutableNodes.mapEntryBuilder().withNodeIdentifier(entryId).withChild(ImmutableNodes.leafNode(NUMBER, i)).build();
cursor.write(entryId, entry);
usedValues.add(i);
}
cursor.close();
return tx.submit();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class NormalizedNodeInputStreamReader method readNormalizedNodeInternal.
private NormalizedNode<?, ?> readNormalizedNodeInternal() throws IOException {
// each node should start with a byte
byte nodeType = input.readByte();
if (nodeType == NodeTypes.END_NODE) {
LOG.trace("End node reached. return");
lastLeafSetQName = null;
return null;
}
switch(nodeType) {
case NodeTypes.AUGMENTATION_NODE:
YangInstanceIdentifier.AugmentationIdentifier augIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(readQNameSet());
LOG.trace("Reading augmentation node {} ", augIdentifier);
return addDataContainerChildren(Builders.augmentationBuilder().withNodeIdentifier(augIdentifier)).build();
case NodeTypes.LEAF_SET_ENTRY_NODE:
QName name = lastLeafSetQName;
if (name == null) {
name = readQName();
}
Object value = readObject();
NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(name, value);
LOG.trace("Reading leaf set entry node {}, value {}", leafIdentifier, value);
return leafSetEntryBuilder().withNodeIdentifier(leafIdentifier).withValue(value).build();
case NodeTypes.MAP_ENTRY_NODE:
NodeIdentifierWithPredicates entryIdentifier = new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
LOG.trace("Reading map entry node {} ", entryIdentifier);
return addDataContainerChildren(Builders.mapEntryBuilder().withNodeIdentifier(entryIdentifier)).build();
default:
return readNodeIdentifierDependentNode(nodeType, new NodeIdentifier(readQName()));
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.
the class LabeledUnicastIpv6RIBSupportTest method testRoutePath.
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.
the class LinkstateRIBSupport method createRouteKey.
private static NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode linkstate) {
final ByteBuf buffer = Unpooled.buffer();
final CLinkstateDestination cLinkstateDestination = LinkstateNlriParser.extractLinkstateDestination(linkstate);
SimpleNlriTypeRegistry.getInstance().serializeNlriType(cLinkstateDestination, buffer);
return new NodeIdentifierWithPredicates(LinkstateRoute.QNAME, ROUTE_KEY_QNAME, ByteArray.readAllBytes(buffer));
}
Aggregations