X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fregistry%2Fmbeans%2FRemoteRpcRegistryMXBeanImpl.java;h=c0bdbb8d21d262178459d56522ae719701fbf803;hb=9ddc65e1ddae50f691566cd9382707679436c055;hp=684bb158ab231c09159a7347ffe18afbb3fcd1b6;hpb=ca72e02478f78e4cd0346ee04d5a656da3d20b37;p=controller.git 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 684bb158ab..c0bdbb8d21 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,6 +9,10 @@ package org.opendaylight.controller.remote.rpc.registry.mbeans; import akka.actor.Address; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +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.RpcRegistry; @@ -17,23 +21,18 @@ import org.opendaylight.controller.sal.connector.api.RpcRouter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements RemoteRpcRegistryMXBean { protected final Logger log = LoggerFactory.getLogger(getClass()); - private final String NULL_CONSTANT = "null"; + private static final String NULL_CONSTANT = "null"; - private final String LOCAL_CONSTANT = "local"; + private static final String LOCAL_CONSTANT = "local"; - private final String ROUTE_CONSTANT = "route:"; + private static final String ROUTE_CONSTANT = "route:"; - private final String NAME_CONSTANT = " | name:"; + private static final String NAME_CONSTANT = " | name:"; private final RpcRegistry rpcRegistry; @@ -47,14 +46,13 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot public Set getGlobalRpc() { RoutingTable table = rpcRegistry.getLocalBucket().getData(); Set globalRpc = new HashSet<>(table.getRoutes().size()); - for(RpcRouter.RouteIdentifier route : table.getRoutes()){ - if(route.getRoute() == null) { + for (RpcRouter.RouteIdentifier route : table.getRoutes()) { + if (route.getRoute() == null) { globalRpc.add(route.getType() != null ? route.getType().toString() : NULL_CONSTANT); } } - if(log.isDebugEnabled()) { - log.debug("Locally registered global RPCs {}", globalRpc); - } + + log.debug("Locally registered global RPCs {}", globalRpc); return globalRpc; } @@ -62,17 +60,16 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot public Set getLocalRegisteredRoutedRpc() { RoutingTable table = rpcRegistry.getLocalBucket().getData(); Set routedRpc = new HashSet<>(table.getRoutes().size()); - for(RpcRouter.RouteIdentifier route : table.getRoutes()){ - if(route.getRoute() != null) { + for (RpcRouter.RouteIdentifier route : table.getRoutes()) { + if (route.getRoute() != null) { StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(route.getRoute().toString()).append(NAME_CONSTANT).append(route.getType() != null ? - route.getType().toString() : NULL_CONSTANT); + builder.append(route.getRoute().toString()).append(NAME_CONSTANT).append(route.getType() != null + ? route.getType().toString() : NULL_CONSTANT); routedRpc.add(builder.toString()); } } - if(log.isDebugEnabled()) { - log.debug("Locally registered routed RPCs {}", routedRpc); - } + + log.debug("Locally registered routed RPCs {}", routedRpc); return routedRpc; } @@ -84,13 +81,12 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot // Get all RPCs from remote bucket Map> buckets = rpcRegistry.getRemoteBuckets(); - for(Address address : buckets.keySet()) { + for (Address address : buckets.keySet()) { RoutingTable table = buckets.get(address).getData(); rpcMap.putAll(getRpcMemberMapByName(table, name, address.toString())); } - if(log.isDebugEnabled()) { - log.debug("list of RPCs {} searched by name {}", rpcMap, name); - } + + log.debug("list of RPCs {} searched by name {}", rpcMap, name); return rpcMap; } @@ -100,32 +96,30 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot Map rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT)); Map> buckets = rpcRegistry.getRemoteBuckets(); - for(Address address : buckets.keySet()) { + for (Address address : buckets.keySet()) { RoutingTable table = buckets.get(address).getData(); rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, address.toString())); } - if(log.isDebugEnabled()) { - log.debug("list of RPCs {} searched by route {}", rpcMap, routeId); - } + + log.debug("list of RPCs {} searched by route {}", rpcMap, routeId); return rpcMap; } /** - * Search if the routing table route String contains routeName + * Search if the routing table route String contains routeName. */ - private Map getRpcMemberMapByRoute(final RoutingTable table, final String routeName, final String address) { Set> routes = table.getRoutes(); Map rpcMap = new HashMap<>(routes.size()); - for(RpcRouter.RouteIdentifier route : table.getRoutes()){ - if(route.getRoute() != null) { + for (RpcRouter.RouteIdentifier route : table.getRoutes()) { + if (route.getRoute() != null) { String routeString = route.getRoute().toString(); - if(routeString.contains(routeName)) { + if (routeString.contains(routeName)) { StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(routeString).append(NAME_CONSTANT).append(route.getType() != null ? - route.getType().toString() : NULL_CONSTANT); + builder.append(routeString).append(NAME_CONSTANT).append(route.getType() != null + ? route.getType().toString() : NULL_CONSTANT); rpcMap.put(builder.toString(), address); } } @@ -134,18 +128,18 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot } /** - * Search if the routing table route type contains name + * Search if the routing table route type contains name. */ private Map getRpcMemberMapByName(final RoutingTable table, final String name, final String address) { Set> routes = table.getRoutes(); Map rpcMap = new HashMap<>(routes.size()); - for(RpcRouter.RouteIdentifier route : routes){ - if(route.getType() != null) { + for (RpcRouter.RouteIdentifier route : routes) { + if (route.getType() != null) { String type = route.getType().toString(); - if(type.contains(name)) { + if (type.contains(name)) { StringBuilder builder = new StringBuilder(ROUTE_CONSTANT); - builder.append(route.getRoute() != null ? route.getRoute().toString(): NULL_CONSTANT) + builder.append(route.getRoute() != null ? route.getRoute().toString() : NULL_CONSTANT) .append(NAME_CONSTANT).append(type); rpcMap.put(builder.toString(), address); } @@ -154,11 +148,8 @@ public class RemoteRpcRegistryMXBeanImpl extends AbstractMXBean implements Remot return rpcMap; } - - @Override public String getBucketVersions() { return rpcRegistry.getVersions().toString(); } - -} \ No newline at end of file +}