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%2Fmbeans%2FRemoteRpcRegistryMXBeanImpl.java;h=87adef3d9cedf30f62ce9de22653ea2a643cde3b;hp=eabb170db244ce260a65dcb8e2dde86eb304be21;hb=634dfac8eead60f443bf75e749c70d1f2bb29198;hpb=5b66dd8f5e3467a07e77b20fe696b29993ce5565 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java index eabb170db2..87adef3d9c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImpl.java @@ -5,26 +5,29 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.remote.rpc.registry.mbeans; import akka.actor.Address; +import akka.util.Timeout; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.remote.rpc.registry.RoutingTable; -import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket; +import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import scala.concurrent.Await; +import scala.concurrent.Future; public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements RemoteRpcRegistryMXBean { + @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE") protected final Logger log = LoggerFactory.getLogger(getClass()); private static final String LOCAL_CONSTANT = "local"; @@ -33,17 +36,38 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot private static final String NAME_CONSTANT = " | name:"; - private final RpcRegistry rpcRegistry; + private final BucketStoreAccess rpcRegistryAccess; + private final Timeout timeout; - public RemoteRpcRegistryMXBeanImpl(final RpcRegistry rpcRegistry) { + public RemoteRpcRegistryMXBeanImpl(final BucketStoreAccess rpcRegistryAccess, final Timeout timeout) { super("RemoteRpcRegistry", "RemoteRpcBroker", null); - this.rpcRegistry = rpcRegistry; + this.rpcRegistryAccess = rpcRegistryAccess; + this.timeout = timeout; registerMBean(); } + @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"}) + private RoutingTable getLocalData() { + try { + return (RoutingTable) Await.result((Future) rpcRegistryAccess.getLocalData(), timeout.duration()); + } catch (Exception e) { + throw new RuntimeException("getLocalData failed", e); + } + } + + @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"}) + private Map
> getRemoteBuckets() { + try { + return (Map>) Await.result((Future)rpcRegistryAccess.getRemoteBuckets(), + timeout.duration()); + } catch (Exception e) { + throw new RuntimeException("getRemoteBuckets failed", e); + } + } + @Override public Set