use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier 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 in project controller by opendaylight.
the class BindingDOMDataBrokerAdapterTest method testClusteredDataChangeListernerRegisteration.
@Test
public void testClusteredDataChangeListernerRegisteration() {
final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker, codec)) {
Mockito.when(this.codecRegistry.toYangInstanceIdentifier(TOP_PATH)).thenReturn(this.yangInstanceIdentifier);
final ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor.forClass(ClusteredDOMDataChangeListener.class);
final ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor.forClass(LogicalDatastoreType.class);
final ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor.forClass(AsyncDataBroker.DataChangeScope.class);
final ArgumentCaptor<YangInstanceIdentifier> yangIidCapture = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final TestListener listener = new TestListener();
bindingDOMDataBrokerAdapter.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, TOP_PATH, listener, AsyncDataBroker.DataChangeScope.BASE);
Mockito.verify(this.dataBroker).registerDataChangeListener(logicalDatastoreType.capture(), yangIidCapture.capture(), clusteredDOMListener.capture(), dataChangeScope.capture());
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class BindingDOMMountPointServiceAdapter method getMountPoint.
@Override
public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint) {
YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint);
Optional<DOMMountPoint> domMount = mountService.getMountPoint(domPath);
if (domMount.isPresent()) {
return Optional.<MountPoint>fromNullable(bindingMountpoints.getUnchecked(domMount.get()));
}
return Optional.absent();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class AbstractForwardedDataBroker method toBinding.
protected Set<InstanceIdentifier<?>> toBinding(final InstanceIdentifier<?> path, final Set<YangInstanceIdentifier> normalized) {
final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
for (final YangInstanceIdentifier normalizedPath : normalized) {
try {
final Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
if (potential.isPresent()) {
final InstanceIdentifier<? extends DataObject> binding = potential.get();
hashSet.add(binding);
} else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) {
hashSet.add(path);
}
} catch (final DeserializationException e) {
LOG.warn("Failed to transform {}, omitting it", normalizedPath, e);
}
}
return hashSet;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class PruningDataTreeModificationTest method testDeleteOnException.
@Test
public void testDeleteOnException() {
YangInstanceIdentifier path = CarsModel.BASE_PATH;
doThrow(SchemaValidationFailedException.class).when(mockModification).delete(path);
pruningDataTreeModification.delete(path);
verify(mockModification, times(1)).delete(path);
}
Aggregations