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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations