Search in sources :

Example 1 with EmptyReadResponse

use of org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse in project netconf by opendaylight.

the class ProxyNetconfServiceTest method testGetConfigEmpty.

@Test
public void testGetConfigEmpty() throws Exception {
    ProxyNetconfService netconf = newSuccessfulProxyNetconfService();
    final ListenableFuture<Optional<NormalizedNode>> getConfig = netconf.getConfig(PATH);
    masterActor.expectMsgClass(GetConfigRequest.class);
    masterActor.reply(new EmptyReadResponse());
    final Optional<NormalizedNode> result = getConfig.get(5, TimeUnit.SECONDS);
    assertFalse(result.isPresent());
}
Also used : Optional(java.util.Optional) EmptyReadResponse(org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 2 with EmptyReadResponse

use of org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse in project netconf by opendaylight.

the class ProxyReadWriteTransactionTest method testReadEmpty.

@Test
public void testReadEmpty() throws Exception {
    ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
    final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
    masterActor.expectMsgClass(ReadRequest.class);
    masterActor.reply(new EmptyReadResponse());
    final Optional<NormalizedNode> result = read.get(5, TimeUnit.SECONDS);
    assertFalse(result.isPresent());
}
Also used : Optional(java.util.Optional) EmptyReadResponse(org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 3 with EmptyReadResponse

use of org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse in project netconf by opendaylight.

the class ProxyNetconfServiceTest method testGetEmpty.

@Test
public void testGetEmpty() throws Exception {
    ProxyNetconfService netconf = newSuccessfulProxyNetconfService();
    final ListenableFuture<Optional<NormalizedNode>> get = netconf.get(PATH);
    masterActor.expectMsgClass(GetRequest.class);
    masterActor.reply(new EmptyReadResponse());
    final Optional<NormalizedNode> result = get.get(5, TimeUnit.SECONDS);
    assertFalse(result.isPresent());
}
Also used : Optional(java.util.Optional) EmptyReadResponse(org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 4 with EmptyReadResponse

use of org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse in project netconf by opendaylight.

the class ActorProxyTransactionFacade method read.

@Override
public FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
    LOG.debug("{}: Read {} {} via actor {}", id, store, path, masterTxActor);
    final Future<Object> future = Patterns.ask(masterTxActor, new ReadRequest(store, path), askTimeout);
    final SettableFuture<Optional<NormalizedNode>> settableFuture = SettableFuture.create();
    future.onComplete(new OnComplete<>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                LOG.debug("{}: Read {} {} failed", id, store, path, failure);
                final Throwable processedFailure = processFailure(failure);
                if (processedFailure instanceof ReadFailedException) {
                    settableFuture.setException(processedFailure);
                } else {
                    settableFuture.setException(new ReadFailedException("Read of store " + store + " path " + path + " failed", processedFailure));
                }
                return;
            }
            LOG.debug("{}: Read {} {} succeeded: {}", id, store, path, response);
            if (response instanceof EmptyReadResponse) {
                settableFuture.set(Optional.empty());
                return;
            }
            if (response instanceof NormalizedNodeMessage) {
                final NormalizedNodeMessage data = (NormalizedNodeMessage) response;
                settableFuture.set(Optional.of(data.getNode()));
            }
        }
    }, executionContext);
    return FluentFuture.from(settableFuture);
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) NormalizedNodeMessage(org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage) Optional(java.util.Optional) EmptyReadResponse(org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse) ReadRequest(org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest)

Aggregations

Optional (java.util.Optional)4 EmptyReadResponse (org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyReadResponse)4 Test (org.junit.Test)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)1 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)1 ReadRequest (org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest)1