use of org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration in project controller by opendaylight.
the class RpcRegistrar method updateRemoteEndpoints.
private void updateRemoteEndpoints(final Map<Address, Optional<RemoteRpcEndpoint>> endpoints) {
/*
* Updating RPC providers is a two-step process. We first add the newly-discovered RPCs and then close
* the old registration. This minimizes churn observed by listeners, as they will not observe RPC
* unavailability which would occur if we were to do it the other way around.
*
* Note that when an RPC moves from one remote node to another, we also do not want to expose the gap,
* hence we register all new implementations before closing all registrations.
*/
final Collection<DOMRpcImplementationRegistration<?>> prevRegs = new ArrayList<>(endpoints.size());
for (Entry<Address, Optional<RemoteRpcEndpoint>> e : endpoints.entrySet()) {
LOG.debug("Updating RPC registrations for {}", e.getKey());
final DOMRpcImplementationRegistration<?> prevReg;
final Optional<RemoteRpcEndpoint> maybeEndpoint = e.getValue();
if (maybeEndpoint.isPresent()) {
final RemoteRpcEndpoint endpoint = maybeEndpoint.get();
final RemoteRpcImplementation impl = new RemoteRpcImplementation(endpoint.getRouter(), config);
prevReg = regs.put(e.getKey(), rpcProviderService.registerRpcImplementation(impl, endpoint.getRpcs()));
} else {
prevReg = regs.remove(e.getKey());
}
if (prevReg != null) {
prevRegs.add(prevReg);
}
}
for (DOMRpcImplementationRegistration<?> r : prevRegs) {
r.close();
}
}
Aggregations