use of org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest in project netconf by opendaylight.
the class ReadTransactionActorTestAdapter method testExistsFailure.
@Test
public void testExistsFailure() {
final ReadFailedException cause = new ReadFailedException("fail");
doReturn(immediateFailedFluentFuture(cause)).when(mockReadTx).exists(STORE, PATH);
actorRef.tell(new ExistsRequest(STORE, PATH), probe.ref());
verify(mockReadTx).exists(STORE, PATH);
final Failure response = probe.expectMsgClass(Failure.class);
assertEquals(cause, response.cause());
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest in project netconf by opendaylight.
the class ProxyReadWriteTransactionTest method testExists.
@Test
public void testExists() throws Exception {
ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
final ListenableFuture<Boolean> read = tx.exists(STORE, PATH);
final ExistsRequest existsRequest = masterActor.expectMsgClass(ExistsRequest.class);
assertEquals(STORE, existsRequest.getStore());
assertEquals(PATH, existsRequest.getPath());
masterActor.reply(Boolean.TRUE);
final Boolean result = read.get(5, TimeUnit.SECONDS);
assertTrue(result);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest in project netconf by opendaylight.
the class ReadTransactionActorTestAdapter method testExists.
@Test
public void testExists() {
doReturn(immediateTrueFluentFuture()).when(mockReadTx).exists(STORE, PATH);
actorRef.tell(new ExistsRequest(STORE, PATH), probe.ref());
verify(mockReadTx).exists(STORE, PATH);
probe.expectMsg(Boolean.TRUE);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest in project netconf by opendaylight.
the class ActorProxyTransactionFacade method exists.
@Override
public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
LOG.debug("{}: Exists {} {} via actor {}", id, store, path, masterTxActor);
final Future<Object> future = Patterns.ask(masterTxActor, new ExistsRequest(store, path), askTimeout);
final SettableFuture<Boolean> settableFuture = SettableFuture.create();
future.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
LOG.debug("{}: Exists {} {} failed", id, store, path, failure);
final Throwable processedFailure = processFailure(failure);
if (processedFailure instanceof ReadFailedException) {
settableFuture.setException(processedFailure);
} else {
settableFuture.setException(new ReadFailedException("Exists of store " + store + " path " + path + " failed", processedFailure));
}
return;
}
LOG.debug("{}: Exists {} {} succeeded: {}", id, store, path, response);
settableFuture.set((Boolean) response);
}
}, executionContext);
return FluentFuture.from(settableFuture);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest in project netconf by opendaylight.
the class ReadAdapter method handle.
@SuppressWarnings("checkstyle:IllegalThrows")
public void handle(final Object message, final ActorRef sender, final ActorRef self) {
if (message instanceof ReadRequest) {
final ReadRequest readRequest = (ReadRequest) message;
final YangInstanceIdentifier path = readRequest.getPath();
final LogicalDatastoreType store = readRequest.getStore();
read(path, store, sender, self);
} else if (message instanceof ExistsRequest) {
final ExistsRequest readRequest = (ExistsRequest) message;
final YangInstanceIdentifier path = readRequest.getPath();
final LogicalDatastoreType store = readRequest.getStore();
exists(path, store, sender, self);
}
}
Aggregations