Search in sources :

Example 6 with RpcError

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

the class MdsalLowLevelTestProvider method unregisterSingletonConstant.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<Void>> unregisterSingletonConstant() {
    LOG.debug("unregister-singleton-constant");
    if (getSingletonConstantRegistration == null) {
        LOG.debug("No get-singleton-constant registration present.");
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No get-singleton-constant rpc registration present.");
        final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
    try {
        getSingletonConstantRegistration.close();
        getSingletonConstantRegistration = null;
        return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
    } catch (Exception e) {
        LOG.debug("There was a problem closing the singleton constant service", e);
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "error-closing", "There was a problem closing get-singleton-constant");
        final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DOMDataTreeLoopException(org.opendaylight.mdsal.dom.api.DOMDataTreeLoopException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with RpcError

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

the class MdsalLowLevelTestProvider method registerSingletonConstant.

@Override
public Future<RpcResult<Void>> registerSingletonConstant(final RegisterSingletonConstantInput input) {
    LOG.debug("Received register-singleton-constant rpc, input: {}", input);
    if (input.getConstant() == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    getSingletonConstantRegistration = SingletonGetConstantService.registerNew(singletonService, domRpcService, input.getConstant());
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 8 with RpcError

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

the class MdsalLowLevelTestProvider method subscribeDtcl.

@Override
public Future<RpcResult<Void>> subscribeDtcl() {
    if (dtclReg != null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already dataTreeChangeListener registered on id-ints list.");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    idIntsListener = new IdIntsListener();
    dtclReg = domDataTreeChangeService.registerDataTreeChangeListener(new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID), idIntsListener);
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : IdIntsListener(org.opendaylight.controller.clustering.it.provider.impl.IdIntsListener) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 9 with RpcError

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

the class MdsalLowLevelTestProvider method registerConstant.

@Override
public Future<RpcResult<Void>> registerConstant(final RegisterConstantInput input) {
    LOG.debug("Received register-constant rpc, input: {}", input);
    if (input.getConstant() == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    if (globalGetConstantRegistration != null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already a get-constant rpc registered.");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    globalGetConstantRegistration = GetConstantService.registerNew(domRpcService, input.getConstant());
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 10 with RpcError

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

the class MdsalLowLevelTestProvider method registerBoundConstant.

@Override
public Future<RpcResult<Void>> registerBoundConstant(final RegisterBoundConstantInput input) {
    LOG.debug("register-bound-constant: {}", input);
    if (input.getContext() == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Context value is null");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    if (input.getConstant() == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    if (routedRegistrations.containsKey(input.getContext())) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already a rpc registered for context: " + input.getContext());
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration = RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService, input.getConstant(), input.getContext());
    routedRegistrations.put(input.getContext(), rpcRegistration);
    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)

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