X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fregistry%2FRpcRegistry.java;h=5ba97a306f7b68625253eaff0f258660139a4a27;hb=91cbd66f53b89d89e419bf23e6969da1f8df137e;hp=805e47a0dd05e7b52082f705f523b8870cd5bb02;hpb=5b66dd8f5e3467a07e77b20fe696b29993ce5565;p=controller.git 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 805e47a0dd..5ba97a306f 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 @@ -10,6 +10,7 @@ package org.opendaylight.controller.remote.rpc.registry; import akka.actor.ActorRef; import akka.actor.Address; import akka.actor.Props; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -21,13 +22,15 @@ 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.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. @@ -38,10 +41,13 @@ import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreActor; */ public class RpcRegistry extends BucketStoreActor { private final ActorRef rpcRegistrar; + private final RemoteRpcRegistryMXBeanImpl mxBean; public RpcRegistry(final RemoteRpcProviderConfig 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(new BucketStoreAccess(self(), getContext().dispatcher(), + config.getAskDuration()), config.getAskDuration()); } /** @@ -57,6 +63,12 @@ public class RpcRegistry extends BucketStoreActor { return Props.create(RpcRegistry.class, config, rpcInvoker, rpcRegistrar); } + @Override + public void postStop() { + super.postStop(); + this.mxBean.unregister(); + } + @Override protected void handleCommand(final Object message) throws Exception { if (message instanceof AddOrUpdateRoutes) { @@ -109,7 +121,8 @@ public class RpcRegistry extends BucketStoreActor { private final Set rpcs; private final ActorRef router; - RemoteRpcEndpoint(final ActorRef router, final Collection rpcs) { + @VisibleForTesting + public RemoteRpcEndpoint(final ActorRef router, final Collection rpcs) { this.router = Preconditions.checkNotNull(router); this.rpcs = ImmutableSet.copyOf(rpcs); } @@ -161,7 +174,8 @@ public class RpcRegistry extends BucketStoreActor { public static final class UpdateRemoteEndpoints { private final Map> endpoints; - UpdateRemoteEndpoints(final Map> endpoints) { + @VisibleForTesting + public UpdateRemoteEndpoints(final Map> endpoints) { this.endpoints = ImmutableMap.copyOf(endpoints); }