private void createRuntimeProps(MemberStateImpl memberState) {
    Runtime runtime = Runtime.getRuntime();
    ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    ClassLoadingMXBean clMxBean = ManagementFactory.getClassLoadingMXBean();
    MemoryMXBean memoryMxBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage heapMemory = memoryMxBean.getHeapMemoryUsage();
    MemoryUsage nonHeapMemory = memoryMxBean.getNonHeapMemoryUsage();

    Map<String, Long> map = new HashMap<String, Long>();
    map.put(
        "runtime.availableProcessors", Integer.valueOf(runtime.availableProcessors()).longValue());
    map.put("date.startTime", runtimeMxBean.getStartTime());
    map.put("seconds.upTime", runtimeMxBean.getUptime());

    map.put("memory.maxMemory", runtime.maxMemory());
    map.put("memory.freeMemory", runtime.freeMemory());
    map.put("memory.totalMemory", runtime.totalMemory());
    map.put("memory.heapMemoryMax", heapMemory.getMax());
    map.put("memory.heapMemoryUsed", heapMemory.getUsed());
    map.put("memory.nonHeapMemoryMax", nonHeapMemory.getMax());
    map.put("memory.nonHeapMemoryUsed", nonHeapMemory.getUsed());
    map.put("runtime.totalLoadedClassCount", clMxBean.getTotalLoadedClassCount());
    map.put(
        "runtime.loadedClassCount", Integer.valueOf(clMxBean.getLoadedClassCount()).longValue());
    map.put("runtime.unloadedClassCount", clMxBean.getUnloadedClassCount());
    map.put("runtime.totalStartedThreadCount", threadMxBean.getTotalStartedThreadCount());
    map.put("runtime.threadCount", Integer.valueOf(threadMxBean.getThreadCount()).longValue());
    map.put(
        "runtime.peakThreadCount", Integer.valueOf(threadMxBean.getPeakThreadCount()).longValue());
    map.put(
        "runtime.daemonThreadCount",
        Integer.valueOf(threadMxBean.getDaemonThreadCount()).longValue());
    memberState.setRuntimeProps(map);
  }
 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 createMemberState(MemberStateImpl memberState) {
   final Node node = factory.node;
   memberState.setAddress(node.getThisAddress());
   memberState.getMemberHealthStats().setOutOfMemory(node.isOutOfMemory());
   memberState.getMemberHealthStats().setActive(node.isActive());
   memberState
       .getMemberHealthStats()
       .setServiceThreadStats(node.getCpuUtilization().serviceThread);
   memberState.getMemberHealthStats().setOutThreadStats(node.getCpuUtilization().outThread);
   memberState.getMemberHealthStats().setInThreadStats(node.getCpuUtilization().inThread);
   PartitionService partitionService = factory.getPartitionService();
   Set<Partition> partitions = partitionService.getPartitions();
   memberState.clearPartitions();
   for (Partition partition : partitions) {
     if (partition.getOwner() != null && partition.getOwner().localMember()) {
       memberState.addPartition(partition.getPartitionId());
     }
   }
   Collection<HazelcastInstanceAwareInstance> proxyObjects =
       new ArrayList<HazelcastInstanceAwareInstance>(factory.getProxies());
   createMemState(memberState, proxyObjects.iterator(), InstanceType.MAP);
   createMemState(memberState, proxyObjects.iterator(), InstanceType.QUEUE);
   createMemState(memberState, proxyObjects.iterator(), InstanceType.TOPIC);
   createRuntimeProps(memberState);
   // uncomment when client changes are made
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.ATOMIC_LONG);
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.COUNT_DOWN_LATCH);
   // createMemState(memberState, proxyObjects.iterator(), InstanceType.SEMAPHORE);
 }