Search in sources :

Example 31 with RpcError

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

the class MdsalLowLevelTestProvider method shutdownPrefixShardReplica.

@Override
public Future<RpcResult<Void>> shutdownPrefixShardReplica(final ShutdownPrefixShardReplicaInput input) {
    LOG.debug("Received shutdown-prefix-shard-replica rpc, input: {}", input);
    final InstanceIdentifier<?> shardPrefix = input.getPrefix();
    if (shardPrefix == null) {
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "bad-element", "A valid shard prefix must be specified");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(rpcError).build());
    }
    final YangInstanceIdentifier shardPath = bindingNormalizedNodeSerializer.toYangInstanceIdentifier(shardPrefix);
    final String cleanPrefixShardName = ClusterUtils.getCleanShardName(shardPath);
    return shutdownShardGracefully(cleanPrefixShardName);
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 32 with RpcError

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

the class MdsalLowLevelTestProvider method unregisterFlappingSingleton.

@Override
public Future<RpcResult<UnregisterFlappingSingletonOutput>> unregisterFlappingSingleton() {
    LOG.debug("unregister-flapping-singleton received.");
    if (flappingSingletonService == null) {
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No flapping-singleton registration present.");
        final RpcResult<UnregisterFlappingSingletonOutput> result = RpcResultBuilder.<UnregisterFlappingSingletonOutput>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
    final long flapCount = flappingSingletonService.setInactive();
    flappingSingletonService = null;
    final UnregisterFlappingSingletonOutput output = new UnregisterFlappingSingletonOutputBuilder().setFlapCount(flapCount).build();
    return Futures.immediateFuture(RpcResultBuilder.success(output).build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) UnregisterFlappingSingletonOutputBuilder(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterFlappingSingletonOutputBuilder) UnregisterFlappingSingletonOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterFlappingSingletonOutput)

Example 33 with RpcError

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

the class MdsalLowLevelTestProvider method shutdownShardReplica.

@Override
public Future<RpcResult<Void>> shutdownShardReplica(final ShutdownShardReplicaInput input) {
    LOG.debug("Received shutdown-shard-replica rpc, input: {}", input);
    final String shardName = input.getShardName();
    if (Strings.isNullOrEmpty(shardName)) {
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "bad-element", "A valid shard name must be specified");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(rpcError).build());
    }
    return shutdownShardGracefully(shardName);
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 34 with RpcError

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

the class MdsalLowLevelTestProvider method unregisterBoundConstant.

@Override
public Future<RpcResult<Void>> unregisterBoundConstant(final UnregisterBoundConstantInput input) {
    LOG.debug("unregister-bound-constant, {}", input);
    final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration = routedRegistrations.remove(input.getContext());
    if (rpcRegistration == null) {
        LOG.debug("No get-contexted-constant registration for context: {}", input.getContext());
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No get-constant rpc registration present.");
        final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
    rpcRegistration.close();
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) RoutedGetConstantService(org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstantService)

Example 35 with RpcError

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

the class MdsalLowLevelTestProvider method unregisterConstant.

@Override
public Future<RpcResult<Void>> unregisterConstant() {
    if (globalGetConstantRegistration == null) {
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No get-constant rpc registration present.");
        final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
    globalGetConstantRegistration.close();
    globalGetConstantRegistration = null;
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().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