Search in sources :

Example 1 with TransactionCommitSuccess

use of org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess in project controller by opendaylight.

the class FrontendReadWriteTransaction method successfulCommit.

void successfulCommit(final RequestEnvelope envelope, final long startTime) {
    if (state instanceof Retired) {
        LOG.debug("{}: Suppressing commit response on retired transaction {}", persistenceId(), getIdentifier());
        return;
    }
    recordAndSendSuccess(envelope, startTime, new TransactionCommitSuccess(getIdentifier(), envelope.getMessage().getSequence()));
    state = COMMITTED;
}
Also used : TransactionCommitSuccess(org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess)

Example 2 with TransactionCommitSuccess

use of org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess in project controller by opendaylight.

the class ClientTransactionTest method testReady.

@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);
    Assert.assertEquals(modification, request.getModification());
    assertFutureEquals(true, actual);
    assertFutureEquals(null, cohort.preCommit());
    assertFutureEquals(null, cohort.commit());
}
Also used : TransactionCommitSuccess(org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess) DOMStoreThreePhaseCommitCohort(org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 3 with TransactionCommitSuccess

use of org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess in project controller by opendaylight.

the class DirectTransactionCommitCohortTest method testCanCommit.

@Test
public void testCanCommit() throws Exception {
    final ListenableFuture<Boolean> canCommit = cohort.canCommit();
    final ModifyTransactionRequest request = transaction.expectTransactionRequest(ModifyTransactionRequest.class);
    Assert.assertTrue(request.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.SIMPLE, request.getPersistenceProtocol().get());
    final RequestSuccess<?, ?> success = new TransactionCommitSuccess(transaction.getTransaction().getIdentifier(), transaction.getLastReceivedMessage().getSequence());
    transaction.replySuccess(success);
    Assert.assertTrue(getWithTimeout(canCommit));
}
Also used : TransactionCommitSuccess(org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 4 with TransactionCommitSuccess

use of org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess in project controller by opendaylight.

the class LocalReadWriteProxyTransactionTest method testDirectCommit.

@Test
@Override
public void testDirectCommit() throws Exception {
    transaction.seal();
    final ListenableFuture<Boolean> result = transaction.directCommit();
    final TransactionTester<LocalReadWriteProxyTransaction> tester = getTester();
    final CommitLocalTransactionRequest req = tester.expectTransactionRequest(CommitLocalTransactionRequest.class);
    tester.replySuccess(new TransactionCommitSuccess(TRANSACTION_ID, req.getSequence()));
    assertFutureEquals(true, result);
}
Also used : TransactionCommitSuccess(org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 5 with TransactionCommitSuccess

use of org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess in project controller by opendaylight.

the class RemoteProxyTransactionTest method testDirectCommit.

@Override
@Test
public void testDirectCommit() throws Exception {
    transaction.seal();
    final ListenableFuture<Boolean> result = transaction.directCommit();
    final TransactionTester<RemoteProxyTransaction> tester = getTester();
    final ModifyTransactionRequest req = tester.expectTransactionRequest(ModifyTransactionRequest.class);
    Assert.assertTrue(req.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.SIMPLE, req.getPersistenceProtocol().get());
    tester.replySuccess(new TransactionCommitSuccess(TRANSACTION_ID, req.getSequence()));
    assertFutureEquals(true, result);
}
Also used : TransactionCommitSuccess(org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Aggregations

TransactionCommitSuccess (org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess)6 Test (org.junit.Test)4 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)2 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)2 TransactionDoCommitRequest (org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest)1 RequestFailure (org.opendaylight.controller.cluster.access.concepts.RequestFailure)1 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)1