Search in sources :

Example 1 with YnlListener

use of org.opendaylight.controller.clustering.it.provider.impl.YnlListener in project controller by opendaylight.

the class MdsalLowLevelTestProvider method subscribeYnl.

@Override
public Future<RpcResult<Void>> subscribeYnl(final SubscribeYnlInput input) {
    LOG.debug("subscribe-ynl, input: {}", input);
    if (ynlRegistrations.containsKey(input.getId())) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already ynl listener registered for this id: " + input.getId());
        return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
    }
    ynlRegistrations.put(input.getId(), notificationService.registerNotificationListener(new YnlListener(input.getId())));
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) YnlListener(org.opendaylight.controller.clustering.it.provider.impl.YnlListener)

Example 2 with YnlListener

use of org.opendaylight.controller.clustering.it.provider.impl.YnlListener in project controller by opendaylight.

the class MdsalLowLevelTestProvider method unsubscribeYnl.

@Override
public Future<RpcResult<UnsubscribeYnlOutput>> unsubscribeYnl(final UnsubscribeYnlInput input) {
    LOG.debug("Received unsubscribe-ynl, input: {}", input);
    if (!ynlRegistrations.containsKey(input.getId())) {
        final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No ynl listener with this id registered.");
        final RpcResult<UnsubscribeYnlOutput> result = RpcResultBuilder.<UnsubscribeYnlOutput>failed().withRpcError(rpcError).build();
        return Futures.immediateFuture(result);
    }
    final ListenerRegistration<YnlListener> reg = ynlRegistrations.remove(input.getId());
    final UnsubscribeYnlOutput output = reg.getInstance().getOutput();
    reg.close();
    return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeYnlOutput>success().withResult(output).build());
}
Also used : RpcError(org.opendaylight.yangtools.yang.common.RpcError) YnlListener(org.opendaylight.controller.clustering.it.provider.impl.YnlListener) UnsubscribeYnlOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput)

Aggregations

YnlListener (org.opendaylight.controller.clustering.it.provider.impl.YnlListener)2 RpcError (org.opendaylight.yangtools.yang.common.RpcError)2 UnsubscribeYnlOutput (org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput)1