当前位置: 首页>>代码示例>>Java>>正文


Java GarbageCollectorMXBean.getName方法代码示例

本文整理汇总了Java中java.lang.management.GarbageCollectorMXBean.getName方法的典型用法代码示例。如果您正苦于以下问题:Java GarbageCollectorMXBean.getName方法的具体用法?Java GarbageCollectorMXBean.getName怎么用?Java GarbageCollectorMXBean.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.GarbageCollectorMXBean的用法示例。


在下文中一共展示了GarbageCollectorMXBean.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readGCUsage

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public static Map<String, Long> readGCUsage(List<GarbageCollectorMXBean> gcmbList) {

        Map<String, Long> m = new LinkedHashMap<String, Long>();

        for (GarbageCollectorMXBean gcmb : gcmbList) {

            String name = gcmb.getName();
            String gcName = null;
            if (minorGC.contains(name)) {
                gcName = "mgc";

            }
            else if (fullGC.contains(name)) {
                gcName = "fgc";
            }

            if (gcName == null) {
                continue;
            }

            m.put(gcName + "_count", gcmb.getCollectionCount());
            m.put(gcName + "_time", gcmb.getCollectionTime());
        }

        return m;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:27,代码来源:JVMToolHelper.java

示例2: readGCUsage

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private void readGCUsage(MonitorElementInstance instance) {

        List<GarbageCollectorMXBean> gcmbList = ManagementFactory.getGarbageCollectorMXBeans();

        for (GarbageCollectorMXBean gcmb : gcmbList) {

            String name = gcmb.getName();
            String gcName = null;
            if (minorGC.contains(name)) {
                gcName = "mgc";

            }
            else if (fullGC.contains(name)) {
                gcName = "fgc";
            }

            if (gcName == null) {
                continue;
            }

            instance.setValue(gcName + "_count", gcmb.getCollectionCount());
            instance.setValue(gcName + "_time", gcmb.getCollectionTime());
        }
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:JVMStateCapHandler.java

示例3: checkMbeans

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private void checkMbeans(Collection<GarbageCollectorMXBean> garbageCollectorMXBeans) {
    if (garbageCollectorMXBeans == null) {
        throw new IllegalArgumentException("garbageCollectorMXBeans should not be null");
    }
    if (garbageCollectorMXBeans.isEmpty()) {
        throw new IllegalArgumentException("garbageCollectorMXBeans should not be empty");
    }
    Set<String> names = new HashSet<>();
    for (GarbageCollectorMXBean bean : garbageCollectorMXBeans) {
        if (bean == null) {
            throw new IllegalArgumentException("garbageCollectorMXBeans should not contain null elements");
        }
        String name = bean.getName();
        if (names.contains(name)) {
            throw new IllegalArgumentException("garbageCollectorMXBeans contains two collectors with name [" + name + "]");
        }
        names.add(name);
    }
}
 
开发者ID:vladimir-bukhtoyarov,项目名称:gc-monitor,代码行数:20,代码来源:GcMonitorBuilder.java

示例4: JVMGC

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public JVMGC() {
    for (GarbageCollectorMXBean item : ManagementFactory.getGarbageCollectorMXBeans()) {
        String name = item.getName();
        if (youngGcName.contains(name)) {
            yongGc = item;
        } else if (fullGcName.contains(name)) {
            fullGc = item;
        }
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:11,代码来源:JVMGC.java

示例5: getGarbageCollectorInfo

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public static void getGarbageCollectorInfo() {
    List<GarbageCollectorMXBean> gcBean = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean collector : gcBean) {
        String collectorName = collector.getName();
        long collectionTime = collector.getCollectionTime();
        long collectionCount = collector.getCollectionCount();
    }
}
 
开发者ID:games647,项目名称:Java-Snippets,代码行数:9,代码来源:VmCommand.java

示例6: get

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
@Override
public Stats get() {
    List<GarbageCollectorMXBean> beans = ManagementFactory.getGarbageCollectorMXBeans();
    int minorGcCount = 0; int fullGcCount = 0; int otherGcCount = 0;
    long minorGcTime = 0L; long fullGcTime = 0L; long otherGcTime = 0L;
    for (GarbageCollectorMXBean b : beans) {
        String name = b.getName();
        if (this.young.contains(name)) {
            minorGcCount = (int)(minorGcCount + b.getCollectionCount());
            minorGcTime += b.getCollectionTime();
        } else if (this.old.contains(name)) {
            fullGcCount = (int)(fullGcCount + b.getCollectionCount());
            fullGcTime += b.getCollectionTime();
        } else {
            otherGcCount = (int)(otherGcCount + b.getCollectionCount());
            otherGcTime += b.getCollectionTime();
        }
    }

    GCStats s = new GCStats();
    s.setMinorGcCount(minorGcCount - this.previous.getMinorGcCount());
    s.setMinorGcTime(minorGcTime - this.previous.getMinorGcTime());
    s.setFullGcCount(fullGcCount - this.previous.getFullGcCount());
    s.setFullGcTime(fullGcTime - this.previous.getFullGcTime());
    s.setOtherGcCount(otherGcCount - this.previous.getOtherGcCount());
    s.setOtherGcTime(otherGcTime - this.previous.getOtherGcTime());

    this.previous.setMinorGcCount(minorGcCount);
    this.previous.setMinorGcTime(minorGcTime);
    this.previous.setFullGcCount(fullGcCount);
    this.previous.setFullGcTime(fullGcTime);
    this.previous.setOtherGcCount(otherGcCount);
    this.previous.setOtherGcCount(otherGcTime);

    return s;
}
 
开发者ID:adohe,项目名称:jsm,代码行数:37,代码来源:GCStatsGetter.java

示例7: process

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
@Override
public Object process(Object arg, Set<DistributedMember> members,
    GfxdConfigMessage<?> msg) {
  TreeMap<Object, Object> map = new TreeMap<Object, Object>();
  // GC information
  for (GarbageCollectorMXBean gcBean : ManagementFactory
      .getGarbageCollectorMXBeans()) {
    final String gcPrefix = "gc-" + gcBean.getName();
    map.put(gcPrefix + "-collection-count", gcBean.getCollectionCount());
    map.put(gcPrefix + "-collection-time", gcBean.getCollectionTime());
    map.put(gcPrefix + "-memory-pools",
        GemFireXDUtils.toCSV(gcBean.getMemoryPoolNames()));
  }
  // some thread information
  ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
  map.put("thread-count", threadBean.getThreadCount());
  map.put("thread-total-count", threadBean.getTotalStartedThreadCount());
  map.put("thread-peak-count", threadBean.getPeakThreadCount());
  // some memory information
  MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
  MemoryUsage heapUsage = memBean.getHeapMemoryUsage();
  MemoryUsage nonHeapUsage = memBean.getNonHeapMemoryUsage();
  map.put("memory-heap-max", heapUsage.getMax());
  map.put("memory-heap-committed", heapUsage.getCommitted());
  map.put("memory-heap-used", heapUsage.getUsed());
  map.put("memory-nonheap-max", nonHeapUsage.getMax());
  map.put("memory-nonheap-committed", nonHeapUsage.getCommitted());
  map.put("memory-nonheap-used", nonHeapUsage.getUsed());
  // some more runtime memory information
  Runtime rt = Runtime.getRuntime();
  map.put("memory-free", rt.freeMemory());
  map.put("memory-max", rt.maxMemory());
  map.put("memory-total", rt.totalMemory());
  map.put("available-processors", rt.availableProcessors());
  return map;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:GfxdConfigMessage.java

示例8: getGCName

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public static String[] getGCName() {
	
	List<GarbageCollectorMXBean> gcmbeans = ManagementFactory.getGarbageCollectorMXBeans();
	String[] rtnName = new String[gcmbeans.size()];
	int index = 0;
	for (GarbageCollectorMXBean gc : gcmbeans) {
		rtnName[index] = gc.getName();
		index++;
	}
	return rtnName;
}
 
开发者ID:blusechen,项目名称:venus,代码行数:12,代码来源:VMMonitor.java

示例9: VMInfo

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
private VMInfo() {
    //初始化静态信息
    osMXBean = java.lang.management.ManagementFactory.getOperatingSystemMXBean();
    runtimeMXBean = java.lang.management.ManagementFactory.getRuntimeMXBean();
    garbageCollectorMXBeanList = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
    memoryPoolMXBeanList = java.lang.management.ManagementFactory.getMemoryPoolMXBeans();

    osInfo = runtimeMXBean.getVmVendor() + " " + runtimeMXBean.getSpecVersion() + " " + runtimeMXBean.getVmVersion();
    jvmInfo = osMXBean.getName() + " " + osMXBean.getArch() + " " + osMXBean.getVersion();
    totalProcessorCount = osMXBean.getAvailableProcessors();

    //构建startPhyOSStatus
    startPhyOSStatus = new PhyOSStatus();
    LOG.info("VMInfo# operatingSystem class => " + osMXBean.getClass().getName());
    if (VMInfo.isSunOsMBean(osMXBean)) {
        {
            startPhyOSStatus.totalPhysicalMemory = VMInfo.getLongFromOperatingSystem(osMXBean, "getTotalPhysicalMemorySize");
            startPhyOSStatus.freePhysicalMemory = VMInfo.getLongFromOperatingSystem(osMXBean, "getFreePhysicalMemorySize");
            startPhyOSStatus.maxFileDescriptorCount = VMInfo.getLongFromOperatingSystem(osMXBean, "getMaxFileDescriptorCount");
            startPhyOSStatus.currentOpenFileDescriptorCount = VMInfo.getLongFromOperatingSystem(osMXBean, "getOpenFileDescriptorCount");
        }
    }

    //初始化processGCStatus;
    for (GarbageCollectorMXBean garbage : garbageCollectorMXBeanList) {
        GCStatus gcStatus = new GCStatus();
        gcStatus.name = garbage.getName();
        processGCStatus.gcStatusMap.put(garbage.getName(), gcStatus);
    }

    //初始化processMemoryStatus
    if (memoryPoolMXBeanList != null && !memoryPoolMXBeanList.isEmpty()) {
        for (MemoryPoolMXBean pool : memoryPoolMXBeanList) {
            MemoryStatus memoryStatus = new MemoryStatus();
            memoryStatus.name = pool.getName();
            memoryStatus.initSize = pool.getUsage().getInit();
            memoryStatus.maxSize = pool.getUsage().getMax();
            processMomoryStatus.memoryStatusMap.put(pool.getName(), memoryStatus);
        }
    }
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:42,代码来源:VMInfo.java

示例10: getDelta

import java.lang.management.GarbageCollectorMXBean; //导入方法依赖的package包/类
public synchronized void getDelta(boolean print) {

        try {
            if (VMInfo.isSunOsMBean(osMXBean)) {
                long curUptime = runtimeMXBean.getUptime();
                long curProcessTime = getLongFromOperatingSystem(osMXBean, "getProcessCpuTime");
                //百分比, uptime是ms,processTime是nano
                if ((curUptime > lastUpTime) && (curProcessTime >= lastProcessCpuTime)) {
                    float curDeltaCpu = (float) (curProcessTime - lastProcessCpuTime) / ((curUptime - lastUpTime) * totalProcessorCount * 10000);
                    processCpuStatus.setMaxMinCpu(curDeltaCpu);
                    processCpuStatus.averageCpu = (float) curProcessTime / (curUptime * totalProcessorCount * 10000);

                    lastUpTime = curUptime;
                    lastProcessCpuTime = curProcessTime;
                }
            }

            for (GarbageCollectorMXBean garbage : garbageCollectorMXBeanList) {

                GCStatus gcStatus = processGCStatus.gcStatusMap.get(garbage.getName());
                if (gcStatus == null) {
                    gcStatus = new GCStatus();
                    gcStatus.name = garbage.getName();
                    processGCStatus.gcStatusMap.put(garbage.getName(), gcStatus);
                }

                long curTotalGcCount = garbage.getCollectionCount();
                gcStatus.setCurTotalGcCount(curTotalGcCount);

                long curtotalGcTime = garbage.getCollectionTime();
                gcStatus.setCurTotalGcTime(curtotalGcTime);
            }

            if (memoryPoolMXBeanList != null && !memoryPoolMXBeanList.isEmpty()) {
                for (MemoryPoolMXBean pool : memoryPoolMXBeanList) {

                    MemoryStatus memoryStatus = processMomoryStatus.memoryStatusMap.get(pool.getName());
                    if (memoryStatus == null) {
                        memoryStatus = new MemoryStatus();
                        memoryStatus.name = pool.getName();
                        processMomoryStatus.memoryStatusMap.put(pool.getName(), memoryStatus);
                    }
                    memoryStatus.commitedSize = pool.getUsage().getCommitted();
                    memoryStatus.setMaxMinUsedSize(pool.getUsage().getUsed());
                    long maxMemory = memoryStatus.commitedSize > 0 ? memoryStatus.commitedSize : memoryStatus.maxSize;
                    memoryStatus.setMaxMinPercent(maxMemory > 0 ? (float) 100 * memoryStatus.usedSize / maxMemory : -1);
                }
            }

            if (print) {
                LOG.info(processCpuStatus.getDeltaString() + processMomoryStatus.getDeltaString() + processGCStatus.getDeltaString());
            }

        } catch (Exception e) {
            LOG.warn("no need care, the fail is ignored : vmInfo getDelta failed " + e.getMessage(), e);
        }
    }
 
开发者ID:yaogdu,项目名称:datax,代码行数:58,代码来源:VMInfo.java


注:本文中的java.lang.management.GarbageCollectorMXBean.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。