import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.ReadFailedException;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
this.outstanding = total;
}
- static BatchedExistenceCheck start(final DOMTransactionChain transactionChain,
+ static BatchedExistenceCheck start(final DOMDataTreeReadOperations tx,
final LogicalDatastoreType datastore, final YangInstanceIdentifier parentPath,
final Collection<? extends NormalizedNode<?, ?>> children) {
final BatchedExistenceCheck ret = new BatchedExistenceCheck(children.size());
- try (DOMDataTreeReadTransaction tx = transactionChain.newReadOnlyTransaction()) {
- for (NormalizedNode<?, ?> child : children) {
- final YangInstanceIdentifier path = parentPath.node(child.getIdentifier());
- tx.exists(datastore, path).addCallback(new FutureCallback<Boolean>() {
- @Override
- public void onSuccess(final Boolean result) {
- ret.complete(path, result);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
- public void onFailure(final Throwable throwable) {
- final Exception e;
- if (throwable instanceof Exception) {
- e = (Exception) throwable;
- } else {
- e = new ExecutionException(throwable);
- }
+ for (NormalizedNode<?, ?> child : children) {
+ final YangInstanceIdentifier path = parentPath.node(child.getIdentifier());
+ tx.exists(datastore, path).addCallback(new FutureCallback<Boolean>() {
+ @Override
+ public void onSuccess(final Boolean result) {
+ ret.complete(path, result);
+ }
- ret.complete(path, ReadFailedException.MAPPER.apply(e));
+ @Override
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
+ public void onFailure(final Throwable throwable) {
+ final Exception e;
+ if (throwable instanceof Exception) {
+ e = (Exception) throwable;
+ } else {
+ e = new ExecutionException(throwable);
}
- }, MoreExecutors.directExecutor());
- }
- return ret;
+
+ ret.complete(path, ReadFailedException.MAPPER.apply(e));
+ }
+ }, MoreExecutors.directExecutor());
}
+ return ret;
}
Entry<YangInstanceIdentifier, ReadFailedException> getFailure() throws InterruptedException {
private final DOMTransactionChain transactionChain;
private DOMDataTreeReadWriteTransaction rwTx;
- MdsalRestconfTransaction(DOMTransactionChain transactionChain) {
+ MdsalRestconfTransaction(final DOMTransactionChain transactionChain) {
this.transactionChain = requireNonNull(transactionChain);
this.rwTx = transactionChain.newReadWriteTransaction();
}
final Collection<? extends NormalizedNode<?, ?>> children =
((NormalizedNodeContainer<?, ?, ?>) data).getValue();
final BatchedExistenceCheck check =
- BatchedExistenceCheck.start(transactionChain, LogicalDatastoreType.CONFIGURATION, path, children);
+ BatchedExistenceCheck.start(verifyNotNull(rwTx), LogicalDatastoreType.CONFIGURATION, path, children);
for (final NormalizedNode<?, ?> child : children) {
final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
final YangInstanceIdentifier node =
payload.getInstanceIdentifierContext().getInstanceIdentifier().node(identifier);
doReturn(immediateFalseFluentFuture())
- .when(this.read).exists(LogicalDatastoreType.CONFIGURATION, node);
+ .when(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
doNothing().when(this.readWrite).put(LogicalDatastoreType.CONFIGURATION, node, entryNode);
doReturn(UriBuilder.fromUri("http://localhost:8181/restconf/15/")).when(this.uriInfo).getBaseUriBuilder();
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
@Mock
private DOMDataTreeReadWriteTransaction readWrite;
@Mock
- private DOMDataTreeReadTransaction read;
- @Mock
private UriInfo uriInfo;
@Mock
private DOMDataBroker mockDataBroker;
final NodeIdentifierWithPredicates identifier = entryNode.getIdentifier();
final YangInstanceIdentifier node =
payload.getInstanceIdentifierContext().getInstanceIdentifier().node(identifier);
- doReturn(read).when(this.transactionChain).newReadOnlyTransaction();
- doReturn(immediateFalseFluentFuture()).when(this.read).exists(LogicalDatastoreType.CONFIGURATION, node);
+ doReturn(immediateFalseFluentFuture()).when(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
doNothing().when(this.readWrite).put(LogicalDatastoreType.CONFIGURATION, node, entryNode);
doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit();
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(this.netconfService)
assertEquals(201, response.getStatus());
assertThat(URLDecoder.decode(response.getLocation().toString(), StandardCharsets.UTF_8),
containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
- verify(this.read).exists(LogicalDatastoreType.CONFIGURATION, node);
+ verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
verify(this.readWrite).put(LogicalDatastoreType.CONFIGURATION, node, entryNode);
response = PostDataTransactionUtil.postData(this.uriInfo, payload,