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());
}
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());
}
Aggregations