import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.Collection;
+import javax.annotation.Nonnull;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCursor;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@Beta
public final class ClientTransaction extends AbstractClientHandle<AbstractProxyTransaction> {
+ private ClientTransactionCursor cursor;
+
ClientTransaction(final AbstractClientHistory parent, final TransactionIdentifier transactionId) {
super(parent, transactionId);
}
-
private AbstractProxyTransaction createProxy(final Long shard) {
return parent().createTransactionProxy(getIdentifier(), shard);
}
return ensureProxy(path, this::createProxy);
}
+ public DOMDataTreeWriteCursor openCursor() {
+ Preconditions.checkState(cursor == null, "Transaction %s has open cursor", getIdentifier());
+ cursor = new ClientTransactionCursor(this);
+ return cursor;
+ }
+
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
return ensureTransactionProxy(path).exists(path);
}
return parent().onTransactionReady(this, cohort);
}
+
+ void closeCursor(@Nonnull final DOMDataTreeCursor cursor) {
+ if (cursor.equals(this.cursor)) {
+ this.cursor = null;
+ }
+ }
}