Search in sources :

Example 6 with BufferPoolMXBean

use of java.lang.management.BufferPoolMXBean in project drill by apache.

the class MemoryIterator method next.

@Override
public Object next() {
    if (!beforeFirst) {
        throw new IllegalStateException();
    }
    beforeFirst = false;
    final MemoryInfo memoryInfo = new MemoryInfo();
    final DrillbitEndpoint endpoint = context.getIdentity();
    memoryInfo.hostname = endpoint.getAddress();
    memoryInfo.user_port = endpoint.getUserPort();
    final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    memoryInfo.heap_current = heapMemoryUsage.getUsed();
    memoryInfo.heap_max = heapMemoryUsage.getMax();
    BufferPoolMXBean directBean = getDirectBean();
    memoryInfo.jvm_direct_current = directBean.getMemoryUsed();
    memoryInfo.direct_current = context.getDrillbitContext().getAllocator().getAllocatedMemory();
    memoryInfo.direct_max = DrillConfig.getMaxDirectMemory();
    return memoryInfo;
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) BufferPoolMXBean(java.lang.management.BufferPoolMXBean) MemoryUsage(java.lang.management.MemoryUsage)

Example 7 with BufferPoolMXBean

use of java.lang.management.BufferPoolMXBean in project lucene-solr by apache.

the class AltBufferPoolMetricSet method getMetrics.

@Override
public Map<String, Metric> getMetrics() {
    final Map<String, Metric> metrics = new HashMap<>();
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (final BufferPoolMXBean pool : pools) {
        String name = pool.getName();
        metrics.put(name + ".Count", (Gauge<Long>) () -> pool.getCount());
        metrics.put(name + ".MemoryUsed", (Gauge<Long>) () -> pool.getMemoryUsed());
        metrics.put(name + ".TotalCapacity", (Gauge<Long>) () -> pool.getTotalCapacity());
    }
    return metrics;
}
Also used : BufferPoolMXBean(java.lang.management.BufferPoolMXBean) HashMap(java.util.HashMap) Metric(com.codahale.metrics.Metric)

Example 8 with BufferPoolMXBean

use of java.lang.management.BufferPoolMXBean in project hive by apache.

the class LlapDaemonJvmMetrics method getJvmMetrics.

private void getJvmMetrics(final MetricsRecordBuilder rb) {
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    long directBufferCount = 0;
    long directBufferTotalCapacity = 0;
    long directBufferMemoryUsed = 0;
    long mappedBufferCount = 0;
    long mappedBufferTotalCapacity = 0;
    long mappedBufferMemoryUsed = 0;
    for (BufferPoolMXBean pool : pools) {
        if (pool.getName().equals("direct")) {
            directBufferCount = pool.getCount();
            directBufferTotalCapacity = pool.getTotalCapacity();
            directBufferMemoryUsed = pool.getMemoryUsed();
        } else if (pool.getName().equals("mapped")) {
            mappedBufferCount = pool.getCount();
            mappedBufferTotalCapacity = pool.getTotalCapacity();
            mappedBufferMemoryUsed = pool.getMemoryUsed();
        }
    }
    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
    long openFileHandles = 0;
    long maxFileHandles = 0;
    if (os instanceof UnixOperatingSystemMXBean) {
        openFileHandles = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount();
        maxFileHandles = ((UnixOperatingSystemMXBean) os).getMaxFileDescriptorCount();
    }
    rb.addGauge(LlapDaemonDirectBufferCount, directBufferCount).addGauge(LlapDaemonDirectBufferTotalCapacity, directBufferTotalCapacity).addGauge(LlapDaemonDirectBufferMemoryUsed, directBufferMemoryUsed).addGauge(LlapDaemonMappedBufferCount, mappedBufferCount).addGauge(LlapDaemonMappedBufferTotalCapacity, mappedBufferTotalCapacity).addGauge(LlapDaemonMappedBufferMemoryUsed, mappedBufferMemoryUsed).addGauge(LlapDaemonOpenFileDescriptorCount, openFileHandles).addGauge(LlapDaemonMaxFileDescriptorCount, maxFileHandles);
}
Also used : UnixOperatingSystemMXBean(com.sun.management.UnixOperatingSystemMXBean) BufferPoolMXBean(java.lang.management.BufferPoolMXBean) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) UnixOperatingSystemMXBean(com.sun.management.UnixOperatingSystemMXBean)

Example 9 with BufferPoolMXBean

use of java.lang.management.BufferPoolMXBean in project druid by druid-io.

the class BufferUtils method totalMemoryUsedByDirectAndMappedBuffers.

public static long totalMemoryUsedByDirectAndMappedBuffers() {
    long totalMemoryUsed = 0L;
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (BufferPoolMXBean pool : pools) {
        totalMemoryUsed += pool.getMemoryUsed();
    }
    return totalMemoryUsed;
}
Also used : BufferPoolMXBean(java.lang.management.BufferPoolMXBean)

Example 10 with BufferPoolMXBean

use of java.lang.management.BufferPoolMXBean in project heron by twitter.

the class JVMMetrics method updateBufferPoolMetrics.

// Gather metrics related to both direct and mapped byte buffers in the jvm.
// These metrics can be useful for diagnosing native memory usage.
private void updateBufferPoolMetrics() {
    for (BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeanList) {
        String normalizedKeyName = bufferPoolMXBean.getName().replaceAll("[^\\w]", "-");
        final long memoryUsedMB = bufferPoolMXBean.getMemoryUsed() / Constants.MB_TO_BYTES;
        final long totalCapacityMB = bufferPoolMXBean.getTotalCapacity() / Constants.MB_TO_BYTES;
        final long countMB = bufferPoolMXBean.getCount() / Constants.MB_TO_BYTES;
        // The estimated memory the JVM is using for this buffer pool
        jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-memory-used").setValue(memoryUsedMB);
        // The estimated total capacity of the buffers in this pool
        jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-total-capacity").setValue(totalCapacityMB);
        // THe estimated number of buffers in this pool
        jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-count").setValue(countMB);
    }
}
Also used : BufferPoolMXBean(java.lang.management.BufferPoolMXBean)

Aggregations

BufferPoolMXBean (java.lang.management.BufferPoolMXBean)10 MemoryUsage (java.lang.management.MemoryUsage)2 Metric (com.codahale.metrics.Metric)1 UnixOperatingSystemMXBean (com.sun.management.UnixOperatingSystemMXBean)1 IOException (java.io.IOException)1 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)1 MemoryMXBean (java.lang.management.MemoryMXBean)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)1 MetricGroup (org.apache.flink.metrics.MetricGroup)1