Search in sources :

Example 36 with Address

use of akka.actor.Address 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)36 Test (org.junit.Test)15 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)9 UniqueAddress (akka.cluster.UniqueAddress)7 HashMap (java.util.HashMap)6 DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)6 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)6 TestKit (akka.testkit.javadsl.TestKit)5 Optional (java.util.Optional)5 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)4 ActorRef (akka.actor.ActorRef)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ActorSelection (akka.actor.ActorSelection)2 ActorSystem (akka.actor.ActorSystem)2 Props (akka.actor.Props)2 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 LeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService)2 WebMonitor (org.apache.flink.runtime.webmonitor.WebMonitor)2