use of org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest in project controller by opendaylight.
the class RequestEnvelopeTest method doAdditionalAssertions.
@Override
protected void doAdditionalAssertions(final RequestEnvelope envelope, final RequestEnvelope resolvedObject) {
final Request<?, ?> actual = resolvedObject.getMessage();
Assert.assertTrue(actual instanceof TransactionPurgeRequest);
final TransactionPurgeRequest purgeRequest = (TransactionPurgeRequest) actual;
Assert.assertEquals(replyTo, purgeRequest.getReplyTo());
final TransactionPurgeResponse response = new TransactionPurgeResponse(OBJECT, 2L);
resolvedObject.sendSuccess(response, 11L);
final SuccessEnvelope successEnvelope = replyToProbe.expectMsgClass(SuccessEnvelope.class);
Assert.assertEquals(response, successEnvelope.getMessage());
final RuntimeRequestException failResponse = new RuntimeRequestException("fail", new RuntimeException());
resolvedObject.sendFailure(failResponse, 11L);
final FailureEnvelope failureEnvelope = replyToProbe.expectMsgClass(FailureEnvelope.class);
Assert.assertEquals(failResponse, failureEnvelope.getMessage().getCause());
}
use of org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest in project controller by opendaylight.
the class RemoteProxyTransaction method handleForwardedRequest.
void handleForwardedRequest(final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback) {
if (request instanceof ModifyTransactionRequest) {
handleForwardedModifyTransactionRequest(callback, (ModifyTransactionRequest) request);
} else if (request instanceof ReadTransactionRequest) {
ensureFlushedBuider();
sendRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ReadTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
callback.accept(resp);
});
} else if (request instanceof ExistsTransactionRequest) {
ensureFlushedBuider();
sendRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), ((ExistsTransactionRequest) request).getPath(), isSnapshotOnly()), resp -> {
recordFinishedRequest(resp);
callback.accept(resp);
});
} else if (request instanceof TransactionPreCommitRequest) {
ensureFlushedBuider();
final TransactionRequest<?> tmp = new TransactionPreCommitRequest(getIdentifier(), nextSequence(), localActor());
sendRequest(tmp, resp -> {
recordSuccessfulRequest(tmp);
callback.accept(resp);
});
} else if (request instanceof TransactionDoCommitRequest) {
ensureFlushedBuider();
sendRequest(new TransactionDoCommitRequest(getIdentifier(), nextSequence(), localActor()), callback);
} else if (request instanceof TransactionAbortRequest) {
ensureFlushedBuider();
sendDoAbort(callback);
} else if (request instanceof TransactionPurgeRequest) {
enqueuePurge(callback);
} else {
throw new IllegalArgumentException("Unhandled request {}" + request);
}
}
use of org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest in project controller by opendaylight.
the class AbstractTransmitQueueTest method testPoison.
@Test
public void testPoison() throws Exception {
final Request<?, ?> request = new TransactionPurgeRequest(TRANSACTION_IDENTIFIER, 0L, probe.ref());
final Consumer<Response<?, ?>> callback = createConsumerMock();
final long now = Ticker.systemTicker().read();
queue.enqueueOrForward(new ConnectionEntry(request, callback, now), now);
queue.poison(new RuntimeRequestException("fail", new RuntimeException("fail")));
verify(callback).accept(any(TransactionFailure.class));
Assert.assertTrue(queue.isEmpty());
}
use of org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest in project controller by opendaylight.
the class RequestEnvelopeTest method createEnvelope.
@Override
protected RequestEnvelope createEnvelope() {
replyToProbe = new TestProbe(system);
replyTo = replyToProbe.ref();
final TransactionPurgeRequest message = new TransactionPurgeRequest(OBJECT, 2L, replyTo);
return new RequestEnvelope(message, 1L, 2L);
}
use of org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest in project controller by opendaylight.
the class AbstractProxyTransactionTest method testForwardToRemotePurge.
@Test
public void testForwardToRemotePurge() throws Exception {
final TestProbe probe = new TestProbe(system);
final TransactionPurgeRequest request = new TransactionPurgeRequest(TRANSACTION_ID, 0L, probe.ref());
testForwardToRemote(request, TransactionPurgeRequest.class);
}
Aggregations