Search in sources :

Example 11 with ModifyTransactionRequest

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

the class RemoteProxyTransaction method flushBuilder.

private void flushBuilder(final Optional<Long> enqueuedTicks) {
    final ModifyTransactionRequest request = builder.build();
    builderBusy = false;
    sendModification(request, enqueuedTicks);
}
Also used : ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)

Example 12 with ModifyTransactionRequest

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

the class ClientTransactionCommitCohortTest method expectCanCommit.

private void expectCanCommit(final TransactionTester<RemoteProxyTransaction> tester) {
    final ModifyTransactionRequest request = tester.expectTransactionRequest(ModifyTransactionRequest.class);
    Assert.assertTrue(request.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.THREE_PHASE, request.getPersistenceProtocol().get());
}
Also used : ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)

Example 13 with ModifyTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest 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 14 with ModifyTransactionRequest

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

the class LocalReadWriteProxyTransactionTest method applyModifyTransactionRequest.

private void applyModifyTransactionRequest(final boolean coordinated) {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
    final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
    final TransactionModification delete = new TransactionDelete(PATH_3);
    builder.addModification(write);
    builder.addModification(merge);
    builder.addModification(delete);
    builder.setSequence(0L);
    builder.setCommit(coordinated);
    final ModifyTransactionRequest request = builder.build();
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
    verify(modification).write(PATH_1, DATA_1);
    verify(modification).merge(PATH_2, DATA_2);
    verify(modification).delete(PATH_3);
    final CommitLocalTransactionRequest commitRequest = getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
    Assert.assertEquals(modification, commitRequest.getModification());
    Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Example 15 with ModifyTransactionRequest

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

the class LocalReadWriteProxyTransactionTest method testFlushState.

@Test
public void testFlushState() throws Exception {
    final TransactionTester<RemoteProxyTransaction> transactionTester = createRemoteProxyTransactionTester();
    final RemoteProxyTransaction successor = transactionTester.getTransaction();
    doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
    transaction.sealOnly();
    final TransactionRequest<?> request = transaction.flushState().get();
    transaction.forwardToSuccessor(successor, request, null);
    verify(modification).applyToCursor(any());
    transactionTester.getTransaction().seal();
    transactionTester.getTransaction().directCommit();
    final ModifyTransactionRequest modifyRequest = transactionTester.expectTransactionRequest(ModifyTransactionRequest.class);
    checkModifications(modifyRequest);
}
Also used : ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Aggregations

ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)21 Test (org.junit.Test)12 TestProbe (akka.testkit.TestProbe)10 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)9 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)5 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)5 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)4 AbstractLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest)3 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)3 IncrementTransactionSequenceRequest (org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest)3 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)3 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)3 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)3 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)3 TransactionRequest (org.opendaylight.controller.cluster.access.commands.TransactionRequest)3 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)3 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)3 Optional (com.google.common.base.Optional)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)2