public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans() throws IOException { // TODO: How to deal with changes to the list?? if (garbageCollectorMBeans == null) { ObjectName gcName = null; try { gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } Set<ObjectName> mbeans = server.queryNames(gcName, null); if (mbeans != null) { garbageCollectorMBeans = new ArrayList<GarbageCollectorMXBean>(); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { ObjectName on = (ObjectName) iterator.next(); String name = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + on.getKeyProperty("name"); GarbageCollectorMXBean mBean = newPlatformMXBeanProxy(server, name, GarbageCollectorMXBean.class); garbageCollectorMBeans.add(mBean); } } } return garbageCollectorMBeans; }
/** * Returns a map of MBeans with ObjectName as the key and MBeanInfo value of a given domain. If * domain is <tt>null</tt>, all MBeans are returned. If no MBean found, an empty map is returned. */ public Map<ObjectName, MBeanInfo> getMBeans(String domain) throws IOException { ObjectName name = null; if (domain != null) { try { name = new ObjectName(domain + ":*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } } Set<ObjectName> mbeans = server.queryNames(name, null); Map<ObjectName, MBeanInfo> result = new HashMap<ObjectName, MBeanInfo>(mbeans.size()); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { Object object = iterator.next(); if (object instanceof ObjectName) { ObjectName o = (ObjectName) object; try { MBeanInfo info = server.getMBeanInfo(o); result.put(o, info); } catch (IntrospectionException e) { // TODO: should log the error } catch (InstanceNotFoundException e) { // TODO: should log the error } catch (ReflectionException e) { // TODO: should log the error } } } return result; }
private void createMemState( MemberStateImpl memberState, Iterator<HazelcastInstanceAwareInstance> it, Instance.InstanceType type) { int count = 0; while (it.hasNext()) { HazelcastInstanceAwareInstance proxyObject = it.next(); if (proxyObject.getInstanceType() == type) { if (count < maxVisibleInstanceCount) { if (type.isMap()) { MProxy mapProxy = (MProxy) proxyObject; if (instanceFilterMap.visible(mapProxy.getName())) { memberState.putLocalMapStats( mapProxy.getName(), (LocalMapStatsImpl) mapProxy.getLocalMapStats()); count++; } } else if (type.isQueue()) { QProxy qProxy = (QProxy) proxyObject; if (instanceFilterQueue.visible(qProxy.getName())) { memberState.putLocalQueueStats( qProxy.getName(), (LocalQueueStatsImpl) qProxy.getLocalQueueStats()); count++; } } else if (type.isTopic()) { TopicProxy topicProxy = (TopicProxy) proxyObject; if (instanceFilterTopic.visible(topicProxy.getName())) { memberState.putLocalTopicStats( topicProxy.getName(), (LocalTopicStatsImpl) topicProxy.getLocalTopicStats()); count++; } } else if (type.isAtomicNumber()) { AtomicNumberProxy atomicLongProxy = (AtomicNumberProxy) proxyObject; if (instanceFilterAtomicNumber.visible(atomicLongProxy.getName())) { memberState.putLocalAtomicNumberStats( atomicLongProxy.getName(), (LocalAtomicNumberStatsImpl) atomicLongProxy.getLocalAtomicNumberStats()); count++; } } else if (type.isCountDownLatch()) { CountDownLatchProxy cdlProxy = (CountDownLatchProxy) proxyObject; if (instanceFilterCountDownLatch.visible(cdlProxy.getName())) { memberState.putLocalCountDownLatchStats( cdlProxy.getName(), (LocalCountDownLatchStatsImpl) cdlProxy.getLocalCountDownLatchStats()); count++; } } else if (type.isSemaphore()) { SemaphoreProxy semaphoreProxy = (SemaphoreProxy) proxyObject; if (instanceFilterSemaphore.visible(semaphoreProxy.getName())) { memberState.putLocalSemaphoreStats( semaphoreProxy.getName(), (LocalSemaphoreStatsImpl) semaphoreProxy.getLocalSemaphoreStats()); count++; } } } it.remove(); } } }
private void collectInstanceNames( Set<String> setLongInstanceNames, Iterator<HazelcastInstanceAwareInstance> it, Instance.InstanceType type) { int count = 0; while (it.hasNext()) { HazelcastInstanceAwareInstance proxyObject = it.next(); if (proxyObject.getInstanceType() == type) { if (count < maxVisibleInstanceCount) { if (type.isMap()) { MProxy mapProxy = (MProxy) proxyObject; if (instanceFilterMap.visible(mapProxy.getName())) { setLongInstanceNames.add(mapProxy.getLongName()); count++; } } else if (type.isQueue()) { QProxy qProxy = (QProxy) proxyObject; if (instanceFilterQueue.visible(qProxy.getName())) { setLongInstanceNames.add(qProxy.getLongName()); count++; } } else if (type.isTopic()) { TopicProxy topicProxy = (TopicProxy) proxyObject; if (instanceFilterTopic.visible(topicProxy.getName())) { setLongInstanceNames.add(topicProxy.getLongName()); count++; } } else if (type.isAtomicNumber()) { AtomicNumberProxy atomicLongProxy = (AtomicNumberProxy) proxyObject; if (instanceFilterAtomicNumber.visible(atomicLongProxy.getName())) { setLongInstanceNames.add(atomicLongProxy.getLongName()); count++; } } else if (type.isCountDownLatch()) { CountDownLatchProxy cdlProxy = (CountDownLatchProxy) proxyObject; if (instanceFilterCountDownLatch.visible(cdlProxy.getName())) { setLongInstanceNames.add(cdlProxy.getLongName()); count++; } } else if (type.isSemaphore()) { SemaphoreProxy semaphoreProxy = (SemaphoreProxy) proxyObject; if (instanceFilterSemaphore.visible(semaphoreProxy.getName())) { setLongInstanceNames.add(semaphoreProxy.getLongName()); count++; } } } it.remove(); } } }
public Collection<MemoryPoolProxy> getMemoryPoolProxies() throws IOException { // TODO: How to deal with changes to the list?? if (memoryPoolProxies == null) { ObjectName poolName = null; try { poolName = new ObjectName(MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*"); } catch (MalformedObjectNameException e) { // should not reach here assert (false); } Set<ObjectName> mbeans = server.queryNames(poolName, null); if (mbeans != null) { memoryPoolProxies = new ArrayList<MemoryPoolProxy>(); Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { ObjectName objName = (ObjectName) iterator.next(); MemoryPoolProxy p = new MemoryPoolProxy(this, objName); memoryPoolProxies.add(p); } } } return memoryPoolProxies; }