use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.
the class FrontendReadWriteTransactionTest method testDuplicateCoordinated.
@Test
public void testDuplicateCoordinated() throws RequestException {
final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(TX_ID, mock(ActorRef.class));
b.setSequence(0);
b.setCommit(true);
final TransactionRequest<?> readyReq = b.build();
assertNull(handleRequest(readyReq));
verify(mockParent).finishTransaction(same(shardTransaction));
assertNull(handleRequest(readyReq));
verifyNoMoreInteractions(mockParent);
}
use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.
the class FrontendReadWriteTransactionTest method testDuplicateModifyAbort.
@Test
public void testDuplicateModifyAbort() throws RequestException {
final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(TX_ID, mock(ActorRef.class));
b.setSequence(0);
b.setAbort();
final TransactionRequest<?> abortReq = b.build();
assertNull(handleRequest(abortReq));
verify(mockParent).abortTransaction(same(shardTransaction), any(Runnable.class));
assertNull(handleRequest(abortReq));
verifyNoMoreInteractions(mockParent);
}
use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.
the class LocalReadWriteProxyTransaction method flushState.
@Override
Optional<ModifyTransactionRequest> flushState() {
final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(getIdentifier(), localActor());
b.setSequence(0);
sealedModification.applyToCursor(new AbstractDataTreeModificationCursor() {
@Override
public void write(final PathArgument child, final NormalizedNode<?, ?> data) {
b.addModification(new TransactionWrite(current().node(child), data));
}
@Override
public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
b.addModification(new TransactionMerge(current().node(child), data));
}
@Override
public void delete(final PathArgument child) {
b.addModification(new TransactionDelete(current().node(child)));
}
});
return Optional.of(b.build());
}
use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.
the class TransmittingTransmitQueueTest method testSlicingFailureOnTransmit.
@Test
public void testSlicingFailureOnTransmit() throws Exception {
doAnswer(invocation -> {
invocation.getArgumentAt(0, SliceOptions.class).getOnFailureCallback().accept(new Exception("mock"));
return Boolean.FALSE;
}).when(mockMessageSlicer).slice(any());
ModifyTransactionRequestBuilder reqBuilder = new ModifyTransactionRequestBuilder(TRANSACTION_IDENTIFIER, probe.ref());
reqBuilder.setSequence(0L);
final long now = now();
Optional<TransmittedConnectionEntry> transmitted = queue.transmit(new ConnectionEntry(reqBuilder.build(), createConsumerMock(), now), now);
assertTrue(transmitted.isPresent());
verify(mockMessageSlicer).slice(any());
probe.expectMsgClass(FailureEnvelope.class);
}
use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.
the class TransmittingTransmitQueueTest method testRequestSlicingOnTransmit.
@Test
public void testRequestSlicingOnTransmit() throws Exception {
doReturn(true).when(mockMessageSlicer).slice(any());
ModifyTransactionRequestBuilder reqBuilder = new ModifyTransactionRequestBuilder(TRANSACTION_IDENTIFIER, probe.ref());
reqBuilder.setSequence(0L);
final Request<?, ?> request = reqBuilder.build();
final long now = now();
final Consumer<Response<?, ?>> mockConsumer = createConsumerMock();
Optional<TransmittedConnectionEntry> transmitted = queue.transmit(new ConnectionEntry(request, mockConsumer, now), now);
assertTrue(transmitted.isPresent());
ArgumentCaptor<SliceOptions> sliceOptions = ArgumentCaptor.forClass(SliceOptions.class);
verify(mockMessageSlicer).slice(sliceOptions.capture());
assertTrue(sliceOptions.getValue().getMessage() instanceof RequestEnvelope);
RequestEnvelope requestEnvelope = (RequestEnvelope) sliceOptions.getValue().getMessage();
assertEquals(request, requestEnvelope.getMessage());
final Request<?, ?> request2 = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 1L, probe.ref());
transmitted = queue.transmit(new ConnectionEntry(request2, mockConsumer, now), now);
assertFalse(transmitted.isPresent());
}
Aggregations