Search in sources :

Example 1 with ExistsRequest

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());
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) ExistsRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest) Failure(akka.actor.Status.Failure) Test(org.junit.Test)

Example 2 with ExistsRequest

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);
}
Also used : ExistsRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest) Test(org.junit.Test)

Example 3 with ExistsRequest

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);
}
Also used : ExistsRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest) Test(org.junit.Test)

Example 4 with ExistsRequest

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);
}
Also used : ExistsRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException)

Example 5 with ExistsRequest

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);
    }
}
Also used : ExistsRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ReadRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest)

Aggregations

ExistsRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.ExistsRequest)5 Test (org.junit.Test)3 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)2 Failure (akka.actor.Status.Failure)1 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)1 ReadRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1