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=eabb170db244ce260a65dcb8e2dde86eb304be21;hb=927bce5688e4b9d33d3e5e9b769d8a0dba5ccdd4;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..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 @@ -5,47 +5,31 @@ * 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 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements RemoteRpcRegistryMXBean { - - 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 RpcRegistry rpcRegistry; +import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; - public RemoteRpcRegistryMXBeanImpl(final RpcRegistry rpcRegistry) { - super("RemoteRpcRegistry", "RemoteRpcBroker", null); - this.rpcRegistry = rpcRegistry; - registerMBean(); +public class RemoteRpcRegistryMXBeanImpl extends AbstractRegistryMXBean + implements RemoteRpcRegistryMXBean { + public RemoteRpcRegistryMXBeanImpl(final BucketStoreAccess rpcRegistryAccess, final Timeout timeout) { + super("RemoteRpcRegistry", "RemoteRpcBroker", rpcRegistryAccess, timeout); } @Override public Set getGlobalRpc() { - RoutingTable table = rpcRegistry.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()); } @@ -57,13 +41,11 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Set getLocalRegisteredRoutedRpc() { - RoutingTable table = rpcRegistry.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()) { - StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(route.getContextReference().toString()).append(NAME_CONSTANT).append(route.getType()); - routedRpc.add(builder.toString()); + routedRpc.add(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + route.getType()); } } @@ -73,12 +55,12 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Map findRpcByName(final String name) { - RoutingTable localTable = rpcRegistry.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 = rpcRegistry.getRemoteBuckets(); + Map> buckets = remoteBuckets(); for (Entry> entry : buckets.entrySet()) { RoutingTable table = entry.getValue().getData(); rpcMap.putAll(getRpcMemberMapByName(table, name, entry.getKey().toString())); @@ -90,10 +72,10 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public Map findRpcByRoute(final String routeId) { - RoutingTable localTable = rpcRegistry.getLocalData(); + RoutingTable localTable = localData(); Map rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT)); - Map> buckets = rpcRegistry.getRemoteBuckets(); + Map> buckets = remoteBuckets(); for (Entry> entry : buckets.entrySet()) { RoutingTable table = entry.getValue().getData(); rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, entry.getKey().toString())); @@ -107,16 +89,14 @@ 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()) { String routeString = route.getContextReference().toString(); if (routeString.contains(routeName)) { - StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(routeString).append(NAME_CONSTANT).append(route.getType()); - rpcMap.put(builder.toString(), address); + rpcMap.put(ROUTE_CONSTANT + routeString + NAME_CONSTANT + route.getType(), address); } } } @@ -126,17 +106,15 @@ 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()) { String type = route.getType().toString(); if (type.contains(name)) { - StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(route.getContextReference()).append(NAME_CONSTANT).append(type); - rpcMap.put(builder.toString(), address); + rpcMap.put(ROUTE_CONSTANT + route.getContextReference() + NAME_CONSTANT + type, address); } } } @@ -145,6 +123,6 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot @Override public String getBucketVersions() { - return rpcRegistry.getVersions().toString(); + return bucketVersions(); } }