Search in sources :

Example 1 with CommitLocalTransactionRequest

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

the class LocalProxyTransactionTest method testForwardToRemoteCommit.

@Override
@Test
public void testForwardToRemoteCommit() throws Exception {
    final TestProbe probe = createProbe();
    final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
    final CommitLocalTransactionRequest request = new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
    doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
    final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
    verify(modification).applyToCursor(any());
    Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.THREE_PHASE, modifyRequest.getPersistenceProtocol().get());
    checkModifications(modifyRequest);
}
Also used : TestProbe(akka.testkit.TestProbe) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 2 with CommitLocalTransactionRequest

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

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

the class LocalReadWriteProxyTransactionTest method testForwardToLocalCommit.

@Test
public void testForwardToLocalCommit() throws Exception {
    final TestProbe probe = createProbe();
    final DataTreeModification mod = mock(DataTreeModification.class);
    final TransactionRequest<?> request = new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), mod, null, false);
    testForwardToLocal(request, CommitLocalTransactionRequest.class);
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification) TestProbe(akka.testkit.TestProbe) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest) Test(org.junit.Test)

Example 4 with CommitLocalTransactionRequest

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

use of org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest 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)

Aggregations

CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)8 Test (org.junit.Test)5 TestProbe (akka.testkit.TestProbe)3 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)3 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)3 TransactionCommitSuccess (org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess)2 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)2 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)1 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)1 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)1 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)1 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)1 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)1 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)1 Response (org.opendaylight.controller.cluster.access.concepts.Response)1 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)1 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1