2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.clustering.services_implementation.internal;
10 import java.util.Dictionary;
11 import java.util.Hashtable;
12 import java.util.concurrent.ConcurrentMap;
14 import org.apache.felix.service.command.Descriptor;
15 import org.infinispan.AdvancedCache;
16 import org.infinispan.distribution.DistributionManager;
17 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
18 import org.opendaylight.controller.sal.utils.ServiceHelper;
19 import org.osgi.framework.ServiceRegistration;
21 public class ClusterManagerCLI {
22 @SuppressWarnings("rawtypes")
23 private ServiceRegistration sr = null;
28 public void destroy() {
32 final Dictionary<String, Object> props = new Hashtable<String, Object>();
33 props.put("osgi.command.scope", "odpcontroller");
34 props.put("osgi.command.function", new String[] { "getContainerAdvancedCacheInfo" });
35 this.sr = ServiceHelper.registerGlobalServiceWReg(ClusterManagerCLI.class, this, props);
39 if (this.sr != null) {
45 @Descriptor("Get advanced cache infos")
46 public void getContainerAdvancedCacheInfo(@Descriptor("Container for the cache to be fetched") String container,
47 @Descriptor("cache to get information about") String cacheName) {
48 IClusterContainerServices s =
49 (IClusterContainerServices) ServiceHelper.getInstance(IClusterContainerServices.class, container, this);
51 System.out.println("Could not get an handle to the container cluster service:" + container);
54 if (!s.existCache(cacheName)) {
55 System.out.println("Could not get cache named:" + cacheName);
57 ConcurrentMap<?, ?> aC = s.getCache(cacheName);
59 System.out.println("Could not get cache named:" + cacheName);
62 if (aC instanceof AdvancedCache) {
63 @SuppressWarnings("rawtypes")
64 AdvancedCache advCache = (AdvancedCache) aC;
65 System.out.println("AdvancedCache retrieved!");
66 DistributionManager dMgr = advCache.getDistributionManager();
70 System.out.println("Routing Table for the Hash:" + dMgr.getConsistentHash()
71 .getRoutingTableAsString());
72 System.out.println("Get Members:" + dMgr.getConsistentHash()