X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fregistry%2FRpcRegistry.java;h=805e47a0dd05e7b52082f705f523b8870cd5bb02;hp=54f76132090bc58da3ade977d5e4344416dec0c0;hb=5b66dd8f5e3467a07e77b20fe696b29993ce5565;hpb=5fd4213b5bfaf2db21f1b37139f6b98535a872c0 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java index 54f7613209..805e47a0dd 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java @@ -11,9 +11,9 @@ import akka.actor.ActorRef; import akka.actor.Address; import akka.actor.Props; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -23,27 +23,24 @@ import java.util.Optional; import java.util.Set; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig; -import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints; import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket; -import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore; -import org.opendaylight.controller.sal.connector.api.RpcRouter.RouteIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreActor; /** * Registry to look up cluster nodes that have registered for a given RPC. * *

- * It uses {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} to maintain this + * It uses {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreActor} to maintain this * cluster wide information. */ -public class RpcRegistry extends BucketStore { +public class RpcRegistry extends BucketStoreActor { private final ActorRef rpcRegistrar; public RpcRegistry(final RemoteRpcProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) { - super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker)); + super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of())); this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar); } @@ -98,16 +95,7 @@ public class RpcRegistry extends BucketStore { for (Entry> e : buckets.entrySet()) { final RoutingTable table = e.getValue().getData(); - final List rpcs = new ArrayList<>(table.getRoutes().size()); - for (RouteIdentifier ri : table.getRoutes()) { - if (ri instanceof RouteIdentifierImpl) { - final RouteIdentifierImpl id = (RouteIdentifierImpl) ri; - rpcs.add(DOMRpcIdentifier.create(SchemaPath.create(true, id.getType()), id.getRoute())); - } else { - LOG.warn("Skipping unsupported route {} from {}", ri, e.getKey()); - } - } - + final Collection rpcs = table.getRoutes(); endpoints.put(e.getKey(), rpcs.isEmpty() ? Optional.empty() : Optional.of(new RemoteRpcEndpoint(table.getRpcInvoker(), rpcs))); } @@ -140,15 +128,15 @@ public class RpcRegistry extends BucketStore { */ public static class Messages { abstract static class AbstractRouteMessage { - final List> routeIdentifiers; + final List routeIdentifiers; - AbstractRouteMessage(final List> routeIdentifiers) { + AbstractRouteMessage(final Collection routeIdentifiers) { Preconditions.checkArgument(routeIdentifiers != null && !routeIdentifiers.isEmpty(), "Route Identifiers must be supplied"); - this.routeIdentifiers = routeIdentifiers; + this.routeIdentifiers = ImmutableList.copyOf(routeIdentifiers); } - List> getRouteIdentifiers() { + List getRouteIdentifiers() { return this.routeIdentifiers; } @@ -159,13 +147,13 @@ public class RpcRegistry extends BucketStore { } public static final class AddOrUpdateRoutes extends AbstractRouteMessage { - public AddOrUpdateRoutes(final List> routeIdentifiers) { + public AddOrUpdateRoutes(final Collection routeIdentifiers) { super(routeIdentifiers); } } public static final class RemoveRoutes extends AbstractRouteMessage { - public RemoveRoutes(final List> routeIdentifiers) { + public RemoveRoutes(final Collection routeIdentifiers) { super(routeIdentifiers); } }