Search in sources :

Example 41 with RpcError

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

the class HandshakeManagerImpl method postHandshake.

/**
 * after handshake set features, register to session.
 *
 * @param proposedVersion proposed openflow version
 * @param xid             transaction id
 */
protected void postHandshake(final Short proposedVersion, final Long xid) {
    // set version
    version = proposedVersion;
    LOG.debug("version set: {}", proposedVersion);
    // request features
    GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
    featuresBuilder.setVersion(version).setXid(xid);
    LOG.debug("sending feature request for version={} and xid={}", version, xid);
    Future<RpcResult<GetFeaturesOutput>> featuresFuture = connectionAdapter.getFeatures(featuresBuilder.build());
    Futures.addCallback(JdkFutureAdapters.listenInPoolThread(featuresFuture), new FutureCallback<RpcResult<GetFeaturesOutput>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<GetFeaturesOutput> rpcFeatures) {
            LOG.trace("features are back");
            if (rpcFeatures.isSuccessful()) {
                GetFeaturesOutput featureOutput = rpcFeatures.getResult();
                LOG.debug("obtained features: datapathId={}", featureOutput.getDatapathId());
                LOG.debug("obtained features: auxiliaryId={}", featureOutput.getAuxiliaryId());
                LOG.trace("handshake SETTLED: version={}, datapathId={}, auxiliaryId={}", version, featureOutput.getDatapathId(), featureOutput.getAuxiliaryId());
                handshakeListener.onHandshakeSuccessful(featureOutput, proposedVersion);
            } else {
                // handshake failed
                LOG.warn("issuing disconnect during handshake [{}]", connectionAdapter.getRemoteAddress());
                for (RpcError rpcError : rpcFeatures.getErrors()) {
                    LOG.debug("handshake - features failure [{}]: i:{} | m:{} | s:{}", xid, rpcError.getInfo(), rpcError.getMessage(), rpcError.getSeverity(), rpcError.getCause());
                }
                handshakeListener.onHandshakeFailure();
            }
            LOG.debug("postHandshake DONE");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("getting feature failed seriously [{}, addr:{}]: {}", xid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
        }
    }, MoreExecutors.directExecutor());
    LOG.debug("future features [{}] hooked ..", xid);
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) GetFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 42 with RpcError

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

the class OpendaylightDirectStatisticsServiceImplTest method testGetNodeConnectorStatisticsFail.

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

Example 43 with RpcError

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

the class OpendaylightDirectStatisticsServiceImplTest method testGetQueueStatisticsFail.

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

Example 44 with RpcError

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

the class OpendaylightDirectStatisticsServiceImplTest method testGetGroupStatisticsFail.

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

Example 45 with RpcError

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

the class AbstractRpcListener method failedRpc.

protected final void failedRpc(final Throwable cause) {
    final RpcError rpcError = buildRpcError(failureInfo, "check switch connection", cause);
    result.set(RpcResultBuilder.<T>failed().withRpcError(rpcError).build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError)

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