Search in sources :

Example 1 with TObjectLongMap

use of gnu.trove.map.TObjectLongMap in project spf4j by zolyfarkas.

the class GCUsageSampler method start.

@JmxExport
public static synchronized void start(@JmxExport("sampleTimeMillis") final int sampleTime) {
    if (samplingFuture == null) {
        final MeasurementRecorder gcUsage = RecorderFactory.createDirectRecorder("gc-time", "ms", sampleTime);
        samplingFuture = DefaultScheduler.INSTANCE.scheduleWithFixedDelay(new AbstractRunnable() {

            private final TObjectLongMap lastValues = new TObjectLongHashMap();

            @Override
            public void doRun() {
                synchronized (lastValues) {
                    gcUsage.record(getGCTimeDiff(MBEANS, lastValues));
                }
            }
        }, sampleTime, sampleTime, TimeUnit.MILLISECONDS);
    } else {
        throw new IllegalStateException("GC usage sampling already started " + samplingFuture);
    }
}
Also used : AbstractRunnable(org.spf4j.base.AbstractRunnable) TObjectLongHashMap(gnu.trove.map.hash.TObjectLongHashMap) MeasurementRecorder(org.spf4j.perf.MeasurementRecorder) TObjectLongMap(gnu.trove.map.TObjectLongMap) JmxExport(org.spf4j.jmx.JmxExport)

Aggregations

TObjectLongMap (gnu.trove.map.TObjectLongMap)1 TObjectLongHashMap (gnu.trove.map.hash.TObjectLongHashMap)1 AbstractRunnable (org.spf4j.base.AbstractRunnable)1 JmxExport (org.spf4j.jmx.JmxExport)1 MeasurementRecorder (org.spf4j.perf.MeasurementRecorder)1