Search in sources :

Example 61 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project Payara by payara.

the class MemoryReporter method init.

private void init() throws RuntimeException {
    try {
        this.rmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
        this.mmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
        ObjectName poolName = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*");
        ;
        ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
        Set mbeans = mbsc.queryNames(poolName, null);
        if (mbeans != null) {
            pools = new ArrayList<MemoryPoolMXBean>();
            Iterator iterator = mbeans.iterator();
            MemoryPoolMXBean p = null;
            while (iterator.hasNext()) {
                ObjectName objName = (ObjectName) iterator.next();
                p = ManagementFactory.newPlatformMXBeanProxy(mbsc, objName.getCanonicalName(), MemoryPoolMXBean.class);
                pools.add(p);
            }
        }
        mbeans = mbsc.queryNames(gcName, null);
        if (mbeans != null) {
            gcmbeans = new ArrayList<GarbageCollectorMXBean>();
            Iterator iterator = mbeans.iterator();
            GarbageCollectorMXBean gc = null;
            while (iterator.hasNext()) {
                ObjectName objName = (ObjectName) iterator.next();
                gc = ManagementFactory.newPlatformMXBeanProxy(mbsc, objName.getCanonicalName(), GarbageCollectorMXBean.class);
                gcmbeans.add(gc);
            }
        }
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) Set(java.util.Set) Iterator(java.util.Iterator) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) MemoryPoolMXBean(java.lang.management.MemoryPoolMXBean) ObjectName(javax.management.ObjectName)

Example 62 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project Payara by payara.

the class JVMGCStatsProvider method getCollectionCount.

@ManagedAttribute(id = "collectioncount-count")
@Description("total number of collections that have occurred")
public CountStatistic getCollectionCount() {
    long counts = -1;
    for (GarbageCollectorMXBean gcBean : gcBeanList) {
        if (gcBean.getName().equals(gcName)) {
            counts = gcBean.getCollectionCount();
        }
    }
    collectionCount.setCount(counts);
    return collectionCount;
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) Description(org.glassfish.gmbal.Description) ManagedAttribute(org.glassfish.gmbal.ManagedAttribute)

Aggregations

GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)62 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)10 RuntimeMXBean (java.lang.management.RuntimeMXBean)10 MemoryMXBean (java.lang.management.MemoryMXBean)8 HashMap (java.util.HashMap)8 MemoryUsage (java.lang.management.MemoryUsage)6 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)5 ThreadMXBean (java.lang.management.ThreadMXBean)4 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)3 ObjectName (javax.management.ObjectName)3 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 NotificationEmitter (javax.management.NotificationEmitter)2 MetricGroup (org.apache.flink.metrics.MetricGroup)2 MetricsInfo (org.apache.hadoop.metrics2.MetricsInfo)2 Metric (com.codahale.metrics.Metric)1 Checkpoint (com.datatorrent.stram.api.Checkpoint)1 ContainerStatsEvent (com.datatorrent.stram.api.ContainerEvent.ContainerStatsEvent)1