From e0c87aea0ff45e15a2f39934a93f2b1bca32c2fa Mon Sep 17 00:00:00 2001 From: Giovanni Meo Date: Thu, 19 Sep 2013 17:58:01 +0200 Subject: [PATCH] Few debug enhancements to debug hashing issues Change-Id: I4a173c0a423d740ef75249f777aa35e5d2772d9c Signed-off-by: Giovanni Meo --- .../internal/Activator.java | 2 +- .../internal/ClusterManagerCLI.java | 69 +++++++++++++++++++ opendaylight/clustering/test/pom.xml | 3 + .../test/internal/SimpleClient.java | 8 ++- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCLI.java diff --git a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java index 5a39e9ec4f..17df387d3e 100644 --- a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java +++ b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java @@ -55,7 +55,7 @@ public class Activator extends ComponentActivatorAbstractBase { */ @Override public Object[] getGlobalImplementations() { - Object[] res = { ClusterManager.class, ClusterGlobalManager.class }; + Object[] res = { ClusterManager.class, ClusterGlobalManager.class, ClusterManagerCLI.class }; return res; } diff --git a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCLI.java b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCLI.java new file mode 100644 index 0000000000..e7927dba98 --- /dev/null +++ b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCLI.java @@ -0,0 +1,69 @@ +package org.opendaylight.controller.clustering.services_implementation.internal; + +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.concurrent.ConcurrentMap; + +import org.apache.felix.service.command.Descriptor; +import org.infinispan.AdvancedCache; +import org.infinispan.distribution.DistributionManager; +import org.opendaylight.controller.clustering.services.IClusterContainerServices; +import org.opendaylight.controller.sal.utils.ServiceHelper; +import org.osgi.framework.ServiceRegistration; + +public class ClusterManagerCLI { + @SuppressWarnings("rawtypes") + private ServiceRegistration sr = null; + + public void init() { + } + + public void destroy() { + } + + public void start() { + final Dictionary props = new Hashtable(); + props.put("osgi.command.scope", "odpcontroller"); + props.put("osgi.command.function", new String[] { "getContainerAdvancedCacheInfo" }); + this.sr = ServiceHelper.registerGlobalServiceWReg(ClusterManagerCLI.class, this, props); + } + + public void stop() { + if (this.sr != null) { + this.sr.unregister(); + this.sr = null; + } + } + + @Descriptor("Get advanced cache infos") + public void getContainerAdvancedCacheInfo(@Descriptor("Container for the cache to be fetched") String container, + @Descriptor("cache to get information about") String cacheName) { + IClusterContainerServices s = + (IClusterContainerServices) ServiceHelper.getInstance(IClusterContainerServices.class, container, this); + if (s == null) { + System.out.println("Could not get an handle to the container cluster service:" + container); + return; + } + if (!s.existCache(cacheName)) { + System.out.println("Could not get cache named:" + cacheName); + } + ConcurrentMap aC = s.getCache(cacheName); + if (aC == null) { + System.out.println("Could not get cache named:" + cacheName); + return; + } + if (aC instanceof AdvancedCache) { + @SuppressWarnings("rawtypes") + AdvancedCache advCache = (AdvancedCache) aC; + System.out.println("AdvancedCache retrieved!"); + DistributionManager dMgr = advCache.getDistributionManager(); + if (dMgr == null) { + return; + } + System.out.println("Routing Table for the Hash:" + dMgr.getConsistentHash() + .getRoutingTableAsString()); + System.out.println("Get Members:" + dMgr.getConsistentHash() + .getMembers()); + } + } +} diff --git a/opendaylight/clustering/test/pom.xml b/opendaylight/clustering/test/pom.xml index 9952069f01..0b09f41de5 100644 --- a/opendaylight/clustering/test/pom.xml +++ b/opendaylight/clustering/test/pom.xml @@ -35,6 +35,9 @@ org.opendaylight.controller.sal.core, org.apache.felix.dm + + org.opendaylight.controller.clustering.test.internal + org.opendaylight.controller.clustering.test.internal.Activator diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java index 60be87b86d..52cc56e377 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java @@ -344,7 +344,13 @@ public class SimpleClient implements CommandProvider { containerName, cacheName); if (c != null) { ci.println("\nAdd mapping " + key + " = " + sValue); - c.put(key, new StringContainer(sValue)); + try { + c.put(key, new StringContainer(sValue)); + } catch (Exception e) { + ci.println("Exception raised:" + e); + ci.println("\tStacktrace:"); + e.printStackTrace(); + } } else { ci.println("Cache " + cacheName + " on container " + containerName + " not existant!"); -- 2.36.6