1 package org.opendaylight.controller.clustering.services_implementation.internal;
3 import java.util.Dictionary;
4 import java.util.Hashtable;
5 import java.util.concurrent.ConcurrentMap;
7 import org.apache.felix.service.command.Descriptor;
8 import org.infinispan.AdvancedCache;
9 import org.infinispan.distribution.DistributionManager;
10 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
11 import org.opendaylight.controller.sal.utils.ServiceHelper;
12 import org.osgi.framework.ServiceRegistration;
14 public class ClusterManagerCLI {
15 @SuppressWarnings("rawtypes")
16 private ServiceRegistration sr = null;
21 public void destroy() {
25 final Dictionary<String, Object> props = new Hashtable<String, Object>();
26 props.put("osgi.command.scope", "odpcontroller");
27 props.put("osgi.command.function", new String[] { "getContainerAdvancedCacheInfo" });
28 this.sr = ServiceHelper.registerGlobalServiceWReg(ClusterManagerCLI.class, this, props);
32 if (this.sr != null) {
38 @Descriptor("Get advanced cache infos")
39 public void getContainerAdvancedCacheInfo(@Descriptor("Container for the cache to be fetched") String container,
40 @Descriptor("cache to get information about") String cacheName) {
41 IClusterContainerServices s =
42 (IClusterContainerServices) ServiceHelper.getInstance(IClusterContainerServices.class, container, this);
44 System.out.println("Could not get an handle to the container cluster service:" + container);
47 if (!s.existCache(cacheName)) {
48 System.out.println("Could not get cache named:" + cacheName);
50 ConcurrentMap<?, ?> aC = s.getCache(cacheName);
52 System.out.println("Could not get cache named:" + cacheName);
55 if (aC instanceof AdvancedCache) {
56 @SuppressWarnings("rawtypes")
57 AdvancedCache advCache = (AdvancedCache) aC;
58 System.out.println("AdvancedCache retrieved!");
59 DistributionManager dMgr = advCache.getDistributionManager();
63 System.out.println("Routing Table for the Hash:" + dMgr.getConsistentHash()
64 .getRoutingTableAsString());
65 System.out.println("Get Members:" + dMgr.getConsistentHash()