ClientTransaction extends AbstractClientHandle<AbstractProxyTransaction> { public DOMStoreThreePhaseCommitCohort ready() { final Collection<AbstractProxyTransaction> toReady = ensureClosed(); Preconditions.checkState(toReady != null, "Attempted to submit a closed transaction %s", this); toReady.forEach(AbstractProxyTransaction::seal); final AbstractTransactionCommitCohort cohort; switch (toReady.size()) { case 0: cohort = new EmptyTransactionCommitCohort(parent(), getIdentifier()); break; case 1: cohort = new DirectTransactionCommitCohort(parent(), getIdentifier(), Iterables.getOnlyElement(toReady)); break; default: cohort = new ClientTransactionCommitCohort(parent(), getIdentifier(), toReady); break; } return parent().onTransactionReady(this, cohort); } ClientTransaction(final AbstractClientHistory parent, final TransactionIdentifier transactionId); DOMDataTreeWriteCursor openCursor(); FluentFuture<Boolean> exists(final YangInstanceIdentifier path); FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path); void delete(final YangInstanceIdentifier path); void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data); void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data); DOMStoreThreePhaseCommitCohort ready();  }
@Test public void testReadyEmpty() throws Exception { final DOMStoreThreePhaseCommitCohort cohort = getHandle().ready(); assertFutureEquals(Boolean.TRUE, cohort.canCommit()); assertFutureEquals(null, cohort.preCommit()); assertFutureEquals(null, cohort.commit()); }
@Test public void testReady() throws Exception { getHandle().write(PATH, DATA); final DOMStoreThreePhaseCommitCohort cohort = getHandle().ready(); final TransactionCommitSuccess response = new TransactionCommitSuccess(TRANSACTION_ID, 0L); final ListenableFuture<Boolean> actual = cohort.canCommit(); final CommitLocalTransactionRequest request = backendRespondToRequest(CommitLocalTransactionRequest.class, response); assertEquals(modification, request.getModification()); assertFutureEquals(Boolean.TRUE, actual); assertFutureEquals(null, cohort.preCommit()); assertFutureEquals(null, cohort.commit()); }
@Test public void testReadyNoFurtherOperationsAllowed() throws Exception { getHandle().ready(); checkClosed(); }