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=d5c72fcea395f0009602ea56c9923e9f053e7d8e;hp=87adef3d9cedf30f62ce9de22653ea2a643cde3b;hb=927bce5688e4b9d33d3e5e9b769d8a0dba5ccdd4;hpb=a2b838f96589b502578fa4e15cef2769f886a378 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 87adef3d9c..d5c72fcea3 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 @@ -9,67 +9,27 @@ 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.remote.rpc.registry.RoutingTable; 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"; - - private static final String ROUTE_CONSTANT = "route:"; - - private static final String NAME_CONSTANT = " | name:"; - - private final BucketStoreAccess rpcRegistryAccess; - private final Timeout timeout; +public class RemoteRpcRegistryMXBeanImpl extends AbstractRegistryMXBean + implements RemoteRpcRegistryMXBean { public RemoteRpcRegistryMXBeanImpl(final BucketStoreAccess rpcRegistryAccess, final Timeout timeout) { - super("RemoteRpcRegistry", "RemoteRpcBroker", null); - 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); - } + super("RemoteRpcRegistry", "RemoteRpcBroker", rpcRegistryAccess, timeout); } @Override public Set getGlobalRpc() { - RoutingTable table = getLocalData(); - Set globalRpc = new HashSet<>(table.getRoutes().size()); - for (DOMRpcIdentifier route : table.getRoutes()) { + RoutingTable table = localData(); + Set globalRpc = new HashSet<>(table.getItems().size()); + for (DOMRpcIdentifier route : table.getItems()) { if (route.getContextReference().isEmpty()) { globalRpc.add(route.getType().toString()); } @@ -81,9 +41,9 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Set getLocalRegisteredRoutedRpc() { - RoutingTable table = getLocalData(); - Set routedRpc = new HashSet<>(table.getRoutes().size()); - for (DOMRpcIdentifier route : table.getRoutes()) { + RoutingTable table = localData(); + Set routedRpc = new HashSet<>(table.getItems().size()); + for (DOMRpcIdentifier route : table.getItems()) { if (!route.getContextReference().isEmpty()) { routedRpc.add(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + route.getType()); } @@ -95,12 +55,12 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Map findRpcByName(final String name) { - RoutingTable localTable = getLocalData(); + RoutingTable localTable = localData(); // Get all RPCs from local bucket Map rpcMap = new HashMap<>(getRpcMemberMapByName(localTable, name, LOCAL_CONSTANT)); // Get all RPCs from remote bucket - Map> buckets = getRemoteBuckets(); + Map> buckets = remoteBuckets(); for (Entry> entry : buckets.entrySet()) { RoutingTable table = entry.getValue().getData(); rpcMap.putAll(getRpcMemberMapByName(table, name, entry.getKey().toString())); @@ -112,10 +72,10 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Map findRpcByRoute(final String routeId) { - RoutingTable localTable = getLocalData(); + RoutingTable localTable = localData(); Map rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT)); - Map> buckets = getRemoteBuckets(); + Map> buckets = remoteBuckets(); for (Entry> entry : buckets.entrySet()) { RoutingTable table = entry.getValue().getData(); rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, entry.getKey().toString())); @@ -129,8 +89,8 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot * Search if the routing table route String contains routeName. */ private static Map getRpcMemberMapByRoute(final RoutingTable table, final String routeName, - final String address) { - Set routes = table.getRoutes(); + final String address) { + Set routes = table.getItems(); Map rpcMap = new HashMap<>(routes.size()); for (DOMRpcIdentifier route : routes) { if (!route.getContextReference().isEmpty()) { @@ -146,9 +106,9 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot /** * Search if the routing table route type contains name. */ - private static Map getRpcMemberMapByName(final RoutingTable table, final String name, - final String address) { - Set routes = table.getRoutes(); + private static Map getRpcMemberMapByName(final RoutingTable table, final String name, + final String address) { + Set routes = table.getItems(); Map rpcMap = new HashMap<>(routes.size()); for (DOMRpcIdentifier route : routes) { if (!route.getContextReference().isEmpty()) { @@ -162,12 +122,7 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot } @Override - @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"}) public String getBucketVersions() { - try { - return Await.result((Future)rpcRegistryAccess.getBucketVersions(), timeout.duration()).toString(); - } catch (Exception e) { - throw new RuntimeException("getVersions failed", e); - } + return bucketVersions(); } }