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=68fead4407781f534b0f9b4aee3ae7e2b012f908;hp=fe43a691d2d685ee0c9fa16f0251c3e925d1c5be;hb=927bce5688e4b9d33d3e5e9b769d8a0dba5ccdd4;hpb=105587c7c4068aa8a0721669cff6aae7f28f6492 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 fe43a691d2..68fead4407 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 @@ -22,14 +22,14 @@ import java.util.Map; import java.util.Map.Entry; 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.RemoteOpsProviderConfig; 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.BucketStoreAccess; import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreActor; import org.opendaylight.controller.remote.rpc.registry.mbeans.RemoteRpcRegistryMXBeanImpl; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; /** * Registry to look up cluster nodes that have registered for a given RPC. @@ -42,10 +42,11 @@ public class RpcRegistry extends BucketStoreActor { private final ActorRef rpcRegistrar; private final RemoteRpcRegistryMXBeanImpl mxBean; - public RpcRegistry(final RemoteRpcProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) { + public RpcRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) { super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of())); this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar); - this.mxBean = new RemoteRpcRegistryMXBeanImpl(this); + this.mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(), + config.getAskDuration()), config.getAskDuration()); } /** @@ -56,8 +57,8 @@ public class RpcRegistry extends BucketStoreActor { * @param rpcInvoker Actor handling RPC invocation requests from remote nodes * @return A new {@link Props} instance */ - public static Props props(final RemoteRpcProviderConfig config, final ActorRef rpcInvoker, - final ActorRef rpcRegistrar) { + public static Props props(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, + final ActorRef rpcRegistrar) { return Props.create(RpcRegistry.class, config, rpcInvoker, rpcRegistrar); } @@ -95,7 +96,8 @@ public class RpcRegistry extends BucketStoreActor { @Override protected void onBucketRemoved(final Address address, final Bucket bucket) { - rpcRegistrar.tell(new UpdateRemoteEndpoints(ImmutableMap.of(address, Optional.empty())), ActorRef.noSender()); + rpcRegistrar.tell(new Messages.UpdateRemoteEndpoints(ImmutableMap.of(address, Optional.empty())), + ActorRef.noSender()); } @Override @@ -105,13 +107,13 @@ public class RpcRegistry extends BucketStoreActor { for (Entry> e : buckets.entrySet()) { final RoutingTable table = e.getValue().getData(); - final Collection rpcs = table.getRoutes(); + final Collection rpcs = table.getItems(); endpoints.put(e.getKey(), rpcs.isEmpty() ? Optional.empty() - : Optional.of(new RemoteRpcEndpoint(table.getRpcInvoker(), rpcs))); + : Optional.of(new RemoteRpcEndpoint(table.getInvoker(), rpcs))); } if (!endpoints.isEmpty()) { - rpcRegistrar.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender()); + rpcRegistrar.tell(new Messages.UpdateRemoteEndpoints(endpoints), ActorRef.noSender()); } } @@ -139,46 +141,48 @@ public class RpcRegistry extends BucketStoreActor { */ public static class Messages { abstract static class AbstractRouteMessage { - final List routeIdentifiers; + final List rpcRouteIdentifiers; - AbstractRouteMessage(final Collection routeIdentifiers) { - Preconditions.checkArgument(routeIdentifiers != null && !routeIdentifiers.isEmpty(), + AbstractRouteMessage(final Collection rpcRouteIdentifiers) { + Preconditions.checkArgument(rpcRouteIdentifiers != null && !rpcRouteIdentifiers.isEmpty(), "Route Identifiers must be supplied"); - this.routeIdentifiers = ImmutableList.copyOf(routeIdentifiers); + this.rpcRouteIdentifiers = ImmutableList.copyOf(rpcRouteIdentifiers); } List getRouteIdentifiers() { - return this.routeIdentifiers; + return this.rpcRouteIdentifiers; } @Override public String toString() { - return "ContainsRoute{" + "routeIdentifiers=" + routeIdentifiers + '}'; + return "ContainsRoute{" + "routeIdentifiers=" + rpcRouteIdentifiers + '}'; } } - public static final class AddOrUpdateRoutes extends AbstractRouteMessage { - public AddOrUpdateRoutes(final Collection routeIdentifiers) { - super(routeIdentifiers); + public static final class AddOrUpdateRoutes extends Messages.AbstractRouteMessage { + public AddOrUpdateRoutes(final Collection rpcRouteIdentifiers) { + super(rpcRouteIdentifiers); } + } public static final class RemoveRoutes extends AbstractRouteMessage { - public RemoveRoutes(final Collection routeIdentifiers) { - super(routeIdentifiers); + public RemoveRoutes(final Collection rpcRouteIdentifiers) { + super(rpcRouteIdentifiers); } } public static final class UpdateRemoteEndpoints { - private final Map> endpoints; + private final Map> rpcEndpoints; + @VisibleForTesting - public UpdateRemoteEndpoints(final Map> endpoints) { - this.endpoints = ImmutableMap.copyOf(endpoints); + public UpdateRemoteEndpoints(final Map> rpcEndpoints) { + this.rpcEndpoints = ImmutableMap.copyOf(rpcEndpoints); } - public Map> getEndpoints() { - return endpoints; + public Map> getRpcEndpoints() { + return rpcEndpoints; } } }