Few debug enhancements to debug hashing issues 97/1297/2
authorGiovanni Meo <gmeo@cisco.com>
Thu, 19 Sep 2013 15:58:01 +0000 (17:58 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 19 Sep 2013 16:01:03 +0000 (16:01 +0000)
Change-Id: I4a173c0a423d740ef75249f777aa35e5d2772d9c
Signed-off-by: Giovanni Meo <gmeo@cisco.com>
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/Activator.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCLI.java [new file with mode: 0644]
opendaylight/clustering/test/pom.xml
opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java

index 5a39e9e..17df387 100644 (file)
@@ -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 (file)
index 0000000..e7927db
--- /dev/null
@@ -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<String, Object> props = new Hashtable<String, Object>();
+        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());
+        }
+    }
+}
index 9952069..0b09f41 100644 (file)
@@ -35,6 +35,9 @@
             org.opendaylight.controller.sal.core,
             org.apache.felix.dm
           </Import-Package>
+          <Export-Package>
+            org.opendaylight.controller.clustering.test.internal
+          </Export-Package>
           <Bundle-Activator>
             org.opendaylight.controller.clustering.test.internal.Activator
           </Bundle-Activator>
index 60be87b..52cc56e 100644 (file)
@@ -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!");