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