Search in sources :

Example 11 with RpcError

use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.

the class RpcErrorsException method getRpcErrors.

public Collection<RpcError> getRpcErrors() {
    final Collection<RpcError> rpcErrors = new ArrayList<>();
    for (final RpcErrorData ed : rpcErrorDataList) {
        final RpcError rpcError = ed.severity == ErrorSeverity.ERROR ? RpcResultBuilder.newError(ed.errorType, ed.tag, ed.message, ed.applicationTag, ed.info, ed.cause) : RpcResultBuilder.newWarning(ed.errorType, ed.tag, ed.message, ed.applicationTag, ed.info, ed.cause);
        rpcErrors.add(rpcError);
    }
    return rpcErrors;
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) ArrayList(java.util.ArrayList)

Example 12 with RpcError

use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.

the class ClusterAdminRpcServiceTest method verifyFailedRpcResult.

private static void verifyFailedRpcResult(RpcResult<?> rpcResult) {
    assertFalse("RpcResult", rpcResult.isSuccessful());
    assertEquals("RpcResult errors size", 1, rpcResult.getErrors().size());
    RpcError error = Iterables.getFirst(rpcResult.getErrors(), null);
    assertNotNull("RpcResult error message null", error.getMessage());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 13 with RpcError

use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.

the class HandshakeManagerImpl method sendHelloMessage.

/**
 * send hello reply without versionBitmap.
 *
 * @param helloVersion initial hello version for openflow connection negotiation
 * @param helloXid     transaction id
 */
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
    HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
    final SettableFuture<Void> resultFtr = SettableFuture.create();
    LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
    Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
    ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
    Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
                resultFtr.set(null);
            } else {
                for (RpcError error : result.getErrors()) {
                    LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
                    if (error.getCause() != null) {
                        LOG.trace("DETAIL of sending hello failure", error.getCause());
                    }
                }
                resultFtr.cancel(false);
                handshakeListener.onHandshakeFailure();
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
            resultFtr.cancel(false);
            handshakeListener.onHandshakeFailure();
        }
    }, MoreExecutors.directExecutor());
    LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
    return resultFtr;
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 14 with RpcError

use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.

the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithNotMultiNoMultipart.

@Test
public void testOnSuccessWithNotMultiNoMultipart() throws Exception {
    final HelloMessage mockedHelloMessage = mock(HelloMessage.class);
    multipartRequestOnTheFlyCallback.onSuccess(mockedHelloMessage);
    final RpcResult<List<MultipartReply>> expectedRpcResult = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass())).build();
    final RpcResult<List<MultipartReply>> actualResult = dummyRequestContext.getFuture().get();
    assertNotNull(actualResult.getErrors());
    assertEquals(1, actualResult.getErrors().size());
    final RpcError actualError = actualResult.getErrors().iterator().next();
    assertEquals(actualError.getMessage(), String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass()));
    assertEquals(actualError.getErrorType(), RpcError.ErrorType.APPLICATION);
    assertEquals(expectedRpcResult.getResult(), actualResult.getResult());
    assertEquals(expectedRpcResult.isSuccessful(), actualResult.isSuccessful());
    Mockito.verify(mockedDeviceContext, Mockito.never()).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier>any(), Matchers.<DataObject>any());
    Mockito.verify(mockedDeviceContext).submitTransaction();
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcError(org.opendaylight.yangtools.yang.common.RpcError) List(java.util.List) Test(org.junit.Test)

Example 15 with RpcError

use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.

the class OpendaylightDirectStatisticsServiceImplTest method testGetFlowStatisticsFail.

@Test
public void testGetFlowStatisticsFail() throws Exception {
    RpcResult<GetFlowStatisticsOutput> result = emptyService.getFlowStatistics(getFlowStatisticsInput).get();
    assertFalse(result.isSuccessful());
    for (RpcError error : result.getErrors()) {
        assertTrue(error.getMessage().contains(AbstractFlowDirectStatisticsService.class.getSimpleName()));
    }
    verify(flowDirectStatisticsService, times(0)).handleAndReply(getFlowStatisticsInput);
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) Test(org.junit.Test)

Aggregations

RpcError (org.opendaylight.yangtools.yang.common.RpcError)49 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)20 Test (org.junit.Test)13 ExecutionException (java.util.concurrent.ExecutionException)8 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)6 ArrayList (java.util.ArrayList)5 TimeoutException (java.util.concurrent.TimeoutException)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 Collection (java.util.Collection)3 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 DistributedShardRegistration (org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration)2 RoutedGetConstantService (org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstantService)2 YnlListener (org.opendaylight.controller.clustering.it.provider.impl.YnlListener)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 ActorRef (akka.actor.ActorRef)1 Props (akka.actor.Props)1 Optional (com.google.common.base.Optional)1 Preconditions (com.google.common.base.Preconditions)1