Search in sources :

Example 1 with RoutedGetConstantService

use of org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstantService 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)

Example 2 with RoutedGetConstantService

use of org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstantService 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)

Aggregations

RoutedGetConstantService (org.opendaylight.controller.clustering.it.provider.impl.RoutedGetConstantService)2 RpcError (org.opendaylight.yangtools.yang.common.RpcError)2