Search in sources :

Example 16 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier in project controller by opendaylight.

the class RemoteRpcRegistryMXBeanImpl method getRpcMemberMapByName.

/**
 * Search if the routing table route type contains name.
 */
private static Map<String, String> getRpcMemberMapByName(final RoutingTable table, final String name, final String address) {
    Set<DOMRpcIdentifier> routes = table.getRoutes();
    Map<String, String> rpcMap = new HashMap<>(routes.size());
    for (DOMRpcIdentifier route : routes) {
        if (!route.getContextReference().isEmpty()) {
            String type = route.getType().toString();
            if (type.contains(name)) {
                rpcMap.put(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + type, address);
            }
        }
    }
    return rpcMap;
}
Also used : HashMap(java.util.HashMap) DOMRpcIdentifier(org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)

Example 17 with DOMRpcIdentifier

use of org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier 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

DOMRpcIdentifier (org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier)17 Address (akka.actor.Address)6 TestKit (akka.testkit.javadsl.TestKit)6 Bucket (org.opendaylight.controller.remote.rpc.registry.gossip.Bucket)5 UniqueAddress (akka.cluster.UniqueAddress)4 Test (org.junit.Test)4 AddOrUpdateRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes)4 HashMap (java.util.HashMap)3 Props (akka.actor.Props)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Before (org.junit.Before)2 RoutingTable (org.opendaylight.controller.remote.rpc.registry.RoutingTable)2 RemoveRoutes (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes)2 UpdateRemoteEndpoints (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints)2 RemoteRpcEndpoint (org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint)2 Timeout (akka.util.Timeout)1 Optional (java.util.Optional)1 RemoteRpcProviderConfig (org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig)1 BucketStoreAccess (org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess)1