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.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
this.outstanding = total;
}
- static BatchedExistenceCheck start(final RestconfStrategy read,
+ static BatchedExistenceCheck start(final DOMTransactionChain transactionChain,
final LogicalDatastoreType datastore, final YangInstanceIdentifier parentPath,
final Collection<? extends NormalizedNode<?, ?>> children) {
final BatchedExistenceCheck ret = new BatchedExistenceCheck(children.size());
- for (NormalizedNode<?, ?> child : children) {
- final YangInstanceIdentifier path = parentPath.node(child.getIdentifier());
- read.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);
+ 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);
}
- ret.complete(path, ReadFailedException.MAPPER.apply(e));
- }
- }, MoreExecutors.directExecutor());
- }
+ @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);
+ }
- return ret;
+ ret.complete(path, ReadFailedException.MAPPER.apply(e));
+ }
+ }, MoreExecutors.directExecutor());
+ }
+ return ret;
+ }
}
Entry<YangInstanceIdentifier, ReadFailedException> getFailure() throws InterruptedException {