Search in sources :

Example 6 with UpdateRemoteEndpoints

use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.

the class RpcRegistry method onBucketsUpdated.

@Override
protected void onBucketsUpdated(final Map<Address, Bucket<RoutingTable>> buckets) {
    final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = new HashMap<>(buckets.size());
    for (Entry<Address, Bucket<RoutingTable>> e : buckets.entrySet()) {
        final RoutingTable table = e.getValue().getData();
        final Collection<DOMRpcIdentifier> rpcs = table.getRoutes();
        endpoints.put(e.getKey(), rpcs.isEmpty() ? Optional.empty() : Optional.of(new RemoteRpcEndpoint(table.getRpcInvoker(), rpcs)));
    }
    if (!endpoints.isEmpty()) {
        rpcRegistrar.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
    }
}
Also used : Address(akka.actor.Address) Optional(java.util.Optional) HashMap(java.util.HashMap) Bucket(org.opendaylight.controller.remote.rpc.registry.gossip.Bucket) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier) UpdateRemoteEndpoints(org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)

Aggregations

UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)6 Test (org.junit.Test)5 Address (akka.actor.Address)4 Optional (java.util.Optional)3 DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)2 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)2 UniqueAddress (akka.cluster.UniqueAddress)1 TestKit (akka.testkit.javadsl.TestKit)1 HashMap (java.util.HashMap)1 InOrder (org.mockito.InOrder)1 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)1