use of io.netty.buffer.PooledByteBufAllocatorMetric in project jocean-http by isdom.
the class PooledAllocatorStats method getMetrics.
public Map<String, Object> getMetrics() {
final PooledByteBufAllocatorMetric allocatorMetric = PooledByteBufAllocator.DEFAULT.metric();
final Map<String, Object> metrics = new HashMap<>();
{
int idx = 0;
for (PoolArenaMetric poolArenaMetric : allocatorMetric.directArenas()) {
metrics.put("1_DirectArena[" + idx++ + "]", metricsOfPoolArena(poolArenaMetric));
}
}
{
int idx = 0;
for (PoolArenaMetric poolArenaMetric : allocatorMetric.heapArenas()) {
metrics.put("2_HeapArena[" + idx++ + "]", metricsOfPoolArena(poolArenaMetric));
}
}
return metrics;
}
use of io.netty.buffer.PooledByteBufAllocatorMetric in project ambry by linkedin.
the class NettyByteBufLeakHelper method beforeTest.
/**
* Method to call at any method that is tagged {@link org.junit.Before} to collect some allocation stats.
*/
public void beforeTest() {
if (cachedEnabled) {
return;
}
PooledByteBufAllocatorMetric metric = PooledByteBufAllocator.DEFAULT.metric();
List<PoolArenaMetric> heaps = metric.heapArenas();
activeHeapAllocations = heaps.stream().mapToLong(PoolArenaMetric::numActiveAllocations).sum();
heapAllocations = heaps.stream().mapToLong(PoolArenaMetric::numAllocations).sum();
heapDeallocations = heaps.stream().mapToLong(PoolArenaMetric::numDeallocations).sum();
List<PoolArenaMetric> directs = metric.directArenas();
activeDirectAllocations = directs.stream().mapToLong(PoolArenaMetric::numActiveAllocations).sum();
directAllocations = directs.stream().mapToLong(PoolArenaMetric::numAllocations).sum();
directDeallocations = directs.stream().mapToLong(PoolArenaMetric::numDeallocations).sum();
}
Aggregations