Search in sources :

Example 1 with DOMRpcImplementationRegistration

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();
    }
}
Also used : Address(akka.actor.Address) Optional(java.util.Optional) DOMRpcImplementationRegistration(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration) ArrayList(java.util.ArrayList) RemoteRpcEndpoint(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)

Aggregations

Address (akka.actor.Address)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 DOMRpcImplementationRegistration (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration)1 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)1