Search in sources :

Example 1 with DOMRpcImplementationNotAvailableException

use of org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException in project controller by opendaylight.

the class RpcBrokerTest method testExecuteRpcFailureWithException.

@Test
public void testExecuteRpcFailureWithException() {
    new TestKit(node1) {

        {
            when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.<NormalizedNode<?, ?>>any())).thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("NOT FOUND")));
            final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
            rpcInvoker1.tell(executeMsg, getRef());
            final Failure rpcResponse = expectMsgClass(duration("5 seconds"), akka.actor.Status.Failure.class);
            Assert.assertTrue(rpcResponse.cause() instanceof DOMRpcException);
        }
    };
}
Also used : DOMRpcImplementationNotAvailableException(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) TestKit(akka.testkit.javadsl.TestKit) DOMRpcException(org.opendaylight.controller.md.sal.dom.api.DOMRpcException) Failure(akka.actor.Status.Failure) Test(org.junit.Test)

Example 2 with DOMRpcImplementationNotAvailableException

use of org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException in project controller by opendaylight.

the class RoutedDOMRpcRoutingTableEntry method invokeRpc.

@Override
protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
    final Optional<NormalizedNode<?, ?>> maybeKey = NormalizedNodes.findNode(input, keyId);
    // Routing key is present, attempt to deliver as a routed RPC
    if (maybeKey.isPresent()) {
        final NormalizedNode<?, ?> key = maybeKey.get();
        final Object value = key.getValue();
        if (value instanceof YangInstanceIdentifier) {
            final YangInstanceIdentifier iid = (YangInstanceIdentifier) value;
            // Find a DOMRpcImplementation for a specific iid
            final List<DOMRpcImplementation> specificImpls = getImplementations(iid);
            if (specificImpls != null) {
                return specificImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
            }
            LOG.debug("No implementation for context {} found will now look for wildcard id", iid);
            // Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register an
            // implementation this way
            final List<DOMRpcImplementation> mayBeRemoteImpls = getImplementations(YangInstanceIdentifier.EMPTY);
            if (mayBeRemoteImpls != null) {
                return mayBeRemoteImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
            }
        } else {
            LOG.warn("Ignoring wrong context value {}", value);
        }
    }
    final List<DOMRpcImplementation> impls = getImplementations(null);
    if (impls != null) {
        return impls.get(0).invokeRpc(globalRpcId, input);
    } else {
        return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", getSchemaPath()));
    }
}
Also used : DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DOMRpcImplementation(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation) DOMRpcImplementationNotAvailableException(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) DOMRpcException(org.opendaylight.controller.md.sal.dom.api.DOMRpcException) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Aggregations

DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)2 DOMRpcImplementationNotAvailableException (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException)2 Failure (akka.actor.Status.Failure)1 TestKit (akka.testkit.javadsl.TestKit)1 Test (org.junit.Test)1 DOMRpcImplementation (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation)1 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)1 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1