use of org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess in project controller by opendaylight.
the class ReconnectingClientConnectionTest method testSendRequestReceiveResponse.
@Override
@Test
public void testSendRequestReceiveResponse() throws Exception {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request = createRequest(replyToProbe.ref());
connection.sendRequest(request, callback);
backendProbe.expectNoMsg();
final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(CLIENT_ID, 0L);
final RequestSuccess<?, ?> message = new TransactionAbortSuccess(new TransactionIdentifier(historyId, 0L), 0L);
final ResponseEnvelope<?> envelope = new SuccessEnvelope(message, 0L, 0L, 0L);
connection.receiveResponse(envelope);
verify(callback, after(1000).never()).accept(any());
}
use of org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess in project controller by opendaylight.
the class FrontendReadWriteTransaction method handleTransactionAbort.
private TransactionAbortSuccess handleTransactionAbort(final long sequence, final RequestEnvelope envelope, final long now) {
if (state instanceof Open) {
final ReadWriteShardDataTreeTransaction openTransaction = checkOpen();
startAbort();
openTransaction.abort(() -> {
recordAndSendSuccess(envelope, now, new TransactionAbortSuccess(getIdentifier(), sequence));
finishAbort();
});
return null;
}
if (ABORTING.equals(state)) {
LOG.debug("{}: Transaction {} already aborting", persistenceId(), getIdentifier());
return null;
}
if (ABORTED.equals(state)) {
// We should have recorded the reply
LOG.warn("{}: Transaction {} already aborted", persistenceId(), getIdentifier());
return new TransactionAbortSuccess(getIdentifier(), sequence);
}
final Ready ready = checkReady();
startAbort();
ready.readyCohort.abort(new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
recordAndSendSuccess(envelope, now, new TransactionAbortSuccess(getIdentifier(), sequence));
finishAbort();
}
@Override
public void onFailure(final Throwable failure) {
recordAndSendFailure(envelope, now, new RuntimeRequestException("Abort failed", failure));
LOG.warn("{}: Transaction {} abort failed", persistenceId(), getIdentifier(), failure);
finishAbort();
}
});
return null;
}
use of org.opendaylight.controller.cluster.access.commands.TransactionAbortSuccess in project controller by opendaylight.
the class AbstractClientConnectionTest method testSendRequestReceiveResponse.
@Test
public void testSendRequestReceiveResponse() throws Exception {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
final Request<?, ?> request = createRequest(replyToProbe.ref());
connection.sendRequest(request, callback);
final RequestEnvelope requestEnvelope = backendProbe.expectMsgClass(RequestEnvelope.class);
Assert.assertEquals(request, requestEnvelope.getMessage());
final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(CLIENT_ID, 0L);
final RequestSuccess<?, ?> message = new TransactionAbortSuccess(new TransactionIdentifier(historyId, 0L), 0L);
final ResponseEnvelope<?> envelope = new SuccessEnvelope(message, 0L, 0L, 0L);
connection.receiveResponse(envelope);
verify(callback, timeout(1000)).accept(isA(TransactionAbortSuccess.class));
}
Aggregations