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;
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations