Search in sources :

Example 6 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project gradle by gradle.

the class GarbageCollectionCheck method run.

@Override
public void run() {
    List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
    GarbageCollectorMXBean garbageCollectorMXBean = CollectionUtils.findFirst(garbageCollectorMXBeans, new Spec<GarbageCollectorMXBean>() {

        @Override
        public boolean isSatisfiedBy(GarbageCollectorMXBean mbean) {
            return mbean.getName().equals(garbageCollector);
        }
    });
    List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
        String pool = memoryPoolMXBean.getName();
        if (memoryPools.contains(pool)) {
            GarbageCollectionEvent event = new GarbageCollectionEvent(System.currentTimeMillis(), memoryPoolMXBean.getCollectionUsage(), garbageCollectorMXBean.getCollectionCount());
            events.get(pool).slideAndInsert(event);
        }
    }
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) MemoryPoolMXBean(java.lang.management.MemoryPoolMXBean)

Example 7 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project bazel by bazelbuild.

the class GCStatsRecorder method getCurrentGcStats.

public Iterable<GCStat> getCurrentGcStats() {
    List<GCStat> stats = new ArrayList<>();
    for (GarbageCollectorMXBean mxBean : mxBeans) {
        String name = mxBean.getName();
        GCStat initStat = Preconditions.checkNotNull(initialData.get(name));
        stats.add(new GCStat(name, mxBean.getCollectionCount() - initStat.getNumCollections(), mxBean.getCollectionTime() - initStat.getTotalTimeInMs()));
    }
    return stats;
}
Also used : ArrayList(java.util.ArrayList) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean)

Example 8 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project hadoop by apache.

the class JvmPauseMonitor method getGcTimes.

private Map<String, GcTimes> getGcTimes() {
    Map<String, GcTimes> map = Maps.newHashMap();
    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean gcBean : gcBeans) {
        map.put(gcBean.getName(), new GcTimes(gcBean));
    }
    return map;
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean)

Example 9 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project flink by apache.

the class TaskExecutorMetricsInitializer method instantiateGarbageCollectorMetrics.

private static void instantiateGarbageCollectorMetrics(MetricGroup metrics) {
    List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
    for (final GarbageCollectorMXBean garbageCollector : garbageCollectors) {
        MetricGroup gcGroup = metrics.addGroup(garbageCollector.getName());
        gcGroup.<Long, Gauge<Long>>gauge("Count", new Gauge<Long>() {

            @Override
            public Long getValue() {
                return garbageCollector.getCollectionCount();
            }
        });
        gcGroup.<Long, Gauge<Long>>gauge("Time", new Gauge<Long>() {

            @Override
            public Long getValue() {
                return garbageCollector.getCollectionTime();
            }
        });
    }
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) MetricGroup(org.apache.flink.metrics.MetricGroup) Gauge(org.apache.flink.metrics.Gauge)

Example 10 with GarbageCollectorMXBean

use of java.lang.management.GarbageCollectorMXBean in project flink by apache.

the class MemoryLogger method getGarbageCollectorStatsAsString.

/**
	 * Gets the garbage collection statistics from the JVM.
	 *
	 * @param gcMXBeans The collection of garbage collector beans.
	 * @return A string denoting the number of times and total elapsed time in garbage collection.
	 */
public static String getGarbageCollectorStatsAsString(List<GarbageCollectorMXBean> gcMXBeans) {
    StringBuilder bld = new StringBuilder("Garbage collector stats: ");
    for (GarbageCollectorMXBean bean : gcMXBeans) {
        bld.append('[').append(bean.getName()).append(", GC TIME (ms): ").append(bean.getCollectionTime());
        bld.append(", GC COUNT: ").append(bean.getCollectionCount()).append(']');
        bld.append(", ");
    }
    if (!gcMXBeans.isEmpty()) {
        bld.setLength(bld.length() - 2);
    }
    return bld.toString();
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean)

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