use of org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess in project controller by opendaylight.
the class LocalProxyTransactionTest method testHandleForwardedRemoteExistsRequest.
@Test
public void testHandleForwardedRemoteExistsRequest() throws Exception {
final TestProbe probe = createProbe();
final ExistsTransactionRequest request = new ExistsTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, true);
final Consumer<Response<?, ?>> callback = createCallbackMock();
setupExecuteInActor();
transaction.handleReplayedRemoteRequest(request, callback, Ticker.systemTicker().read());
final ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
verify(callback).accept(captor.capture());
final Response<?, ?> value = captor.getValue();
Assert.assertTrue(value instanceof ExistsTransactionSuccess);
final ExistsTransactionSuccess success = (ExistsTransactionSuccess) value;
Assert.assertTrue(success.getExists());
}
use of org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess in project controller by opendaylight.
the class RemoteProxyTransactionTest method testExists.
@Override
@Test
public void testExists() throws Exception {
final TransactionTester<RemoteProxyTransaction> tester = getTester();
final CheckedFuture<Boolean, ReadFailedException> exists = transaction.exists(PATH_1);
final ExistsTransactionRequest req = tester.expectTransactionRequest(ExistsTransactionRequest.class);
final boolean existsResult = true;
tester.replySuccess(new ExistsTransactionSuccess(TRANSACTION_ID, req.getSequence(), existsResult));
assertFutureEquals(existsResult, exists);
}
use of org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess in project controller by opendaylight.
the class LocalProxyTransaction method handleReadRequest.
private boolean handleReadRequest(final TransactionRequest<?> request, @Nullable final Consumer<Response<?, ?>> callback) {
// listeners, which we do not want to execute while we are reconnecting.
if (request instanceof ReadTransactionRequest) {
final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
final Optional<NormalizedNode<?, ?>> result = Optional.fromJavaUtil(readOnlyView().readNode(path));
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(), request.getSequence(), result)));
}
return true;
} else if (request instanceof ExistsTransactionRequest) {
final YangInstanceIdentifier path = ((ExistsTransactionRequest) request).getPath();
final boolean result = readOnlyView().readNode(path).isPresent();
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
executeInActor(() -> fbIsStupid.accept(new ExistsTransactionSuccess(request.getTarget(), request.getSequence(), result)));
}
return true;
} else {
return false;
}
}
Aggregations