Example usage for io.netty.buffer PooledByteBufAllocator metric

List of usage examples for io.netty.buffer PooledByteBufAllocator metric

Introduction

In this page you can find the example usage for io.netty.buffer PooledByteBufAllocator metric.

Prototype

PooledByteBufAllocatorMetric metric

To view the source code for io.netty.buffer PooledByteBufAllocator metric.

Click Source Link

Usage

From source file:org.apache.spark.network.util.NettyMemoryMetrics.java

License:Apache License

private void registerMetrics(PooledByteBufAllocator allocator) {
    PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric();

    // Register general metrics.
    allMetrics.put(MetricRegistry.name(metricPrefix, "usedHeapMemory"),
            (Gauge<Long>) () -> pooledAllocatorMetric.usedHeapMemory());
    allMetrics.put(MetricRegistry.name(metricPrefix, "usedDirectMemory"),
            (Gauge<Long>) () -> pooledAllocatorMetric.usedDirectMemory());

    if (verboseMetricsEnabled) {
        int directArenaIndex = 0;
        for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) {
            registerArenaMetric(metric, "directArena" + directArenaIndex);
            directArenaIndex++;//  w w  w  .  j a  va 2 s  .  c o m
        }

        int heapArenaIndex = 0;
        for (PoolArenaMetric metric : pooledAllocatorMetric.heapArenas()) {
            registerArenaMetric(metric, "heapArena" + heapArenaIndex);
            heapArenaIndex++;
        }
    }
}