Example usage for io.netty.buffer PooledByteBufAllocator directArenas

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

Introduction

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

Prototype

PoolArena directArenas

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

Click Source Link

Usage

From source file:com.yahoo.pulsar.broker.stats.AllocatorStatsGenerator.java

License:Apache License

public static AllocatorStats generate(String allocatorName) {
    PooledByteBufAllocator allocator = null;
    if ("default".equals(allocatorName)) {
        allocator = PooledByteBufAllocator.DEFAULT;
    } else if ("ml-cache".equals(allocatorName)) {
        allocator = EntryCacheImpl.allocator;
    } else {/*from w ww . ja  v a 2  s .co m*/
        throw new IllegalArgumentException("Invalid allocator name : " + allocatorName);
    }

    AllocatorStats stats = new AllocatorStats();
    stats.directArenas = allocator.directArenas().stream().map(x -> newPoolArenaStats(x))
            .collect(Collectors.toList());
    stats.heapArenas = allocator.heapArenas().stream().map(x -> newPoolArenaStats(x))
            .collect(Collectors.toList());

    stats.numDirectArenas = allocator.numDirectArenas();
    stats.numHeapArenas = allocator.numHeapArenas();
    stats.numThreadLocalCaches = allocator.numThreadLocalCaches();
    stats.normalCacheSize = allocator.normalCacheSize();
    stats.smallCacheSize = allocator.smallCacheSize();
    stats.tinyCacheSize = allocator.tinyCacheSize();
    return stats;
}

From source file:com.yahoo.pulsar.broker.stats.metrics.ManagedLedgerCacheMetrics.java

License:Apache License

@Override
public List<Metrics> generate() {

    // get the ML cache stats bean

    ManagedLedgerFactoryMXBean mlCacheStats = getManagedLedgerCacheStats();

    Metrics m = createMetrics();//from   w w w.  java2  s.  c  o  m

    m.put("brk_ml_count", mlCacheStats.getNumberOfManagedLedgers());
    m.put("brk_ml_cache_used_size", mlCacheStats.getCacheUsedSize());
    m.put("brk_ml_cache_evictions", mlCacheStats.getNumberOfCacheEvictions());
    m.put("brk_ml_cache_hits_rate", mlCacheStats.getCacheHitsRate());
    m.put("brk_ml_cache_misses_rate", mlCacheStats.getCacheMissesRate());
    m.put("brk_ml_cache_hits_throughput", mlCacheStats.getCacheHitsThroughput());
    m.put("brk_ml_cache_misses_throughput", mlCacheStats.getCacheMissesThroughput());

    PooledByteBufAllocator allocator = EntryCacheImpl.allocator;
    long activeAllocations = 0;
    long activeAllocationsTiny = 0;
    long activeAllocationsSmall = 0;
    long activeAllocationsNormal = 0;
    long activeAllocationsHuge = 0;
    long totalAllocated = 0;
    long totalUsed = 0;

    for (PoolArenaMetric arena : allocator.directArenas()) {
        activeAllocations += arena.numActiveAllocations();
        activeAllocationsTiny += arena.numActiveTinyAllocations();
        activeAllocationsSmall += arena.numActiveSmallAllocations();
        activeAllocationsNormal += arena.numActiveNormalAllocations();
        activeAllocationsHuge += arena.numActiveHugeAllocations();

        for (PoolChunkListMetric list : arena.chunkLists()) {
            for (PoolChunkMetric chunk : list) {
                int size = chunk.chunkSize();
                int used = size - chunk.freeBytes();

                totalAllocated += size;
                totalUsed += used;
            }
        }
    }

    m.put("brk_ml_cache_pool_allocated", totalAllocated);
    m.put("brk_ml_cache_pool_used", totalUsed);
    m.put("brk_ml_cache_pool_active_allocations", activeAllocations);
    m.put("brk_ml_cache_pool_active_allocations_tiny", activeAllocationsTiny);
    m.put("brk_ml_cache_pool_active_allocations_small", activeAllocationsSmall);
    m.put("brk_ml_cache_pool_active_allocations_normal", activeAllocationsNormal);
    m.put("brk_ml_cache_pool_active_allocations_huge", activeAllocationsHuge);

    return Lists.newArrayList(m);

}

From source file:org.apache.pulsar.broker.stats.metrics.ManagedLedgerCacheMetrics.java

License:Apache License

@Override
public synchronized List<Metrics> generate() {

    // get the ML cache stats bean

    ManagedLedgerFactoryMXBean mlCacheStats = getManagedLedgerCacheStats();

    Metrics m = createMetrics();/*w  w w. ja v  a2  s . c om*/

    m.put("brk_ml_count", mlCacheStats.getNumberOfManagedLedgers());
    m.put("brk_ml_cache_used_size", mlCacheStats.getCacheUsedSize());
    m.put("brk_ml_cache_evictions", mlCacheStats.getNumberOfCacheEvictions());
    m.put("brk_ml_cache_hits_rate", mlCacheStats.getCacheHitsRate());
    m.put("brk_ml_cache_misses_rate", mlCacheStats.getCacheMissesRate());
    m.put("brk_ml_cache_hits_throughput", mlCacheStats.getCacheHitsThroughput());
    m.put("brk_ml_cache_misses_throughput", mlCacheStats.getCacheMissesThroughput());

    PooledByteBufAllocator allocator = EntryCacheImpl.allocator;
    long activeAllocations = 0;
    long activeAllocationsTiny = 0;
    long activeAllocationsSmall = 0;
    long activeAllocationsNormal = 0;
    long activeAllocationsHuge = 0;
    long totalAllocated = 0;
    long totalUsed = 0;

    for (PoolArenaMetric arena : allocator.directArenas()) {
        activeAllocations += arena.numActiveAllocations();
        activeAllocationsTiny += arena.numActiveTinyAllocations();
        activeAllocationsSmall += arena.numActiveSmallAllocations();
        activeAllocationsNormal += arena.numActiveNormalAllocations();
        activeAllocationsHuge += arena.numActiveHugeAllocations();

        for (PoolChunkListMetric list : arena.chunkLists()) {
            for (PoolChunkMetric chunk : list) {
                int size = chunk.chunkSize();
                int used = size - chunk.freeBytes();

                totalAllocated += size;
                totalUsed += used;
            }
        }
    }

    m.put("brk_ml_cache_pool_allocated", totalAllocated);
    m.put("brk_ml_cache_pool_used", totalUsed);
    m.put("brk_ml_cache_pool_active_allocations", activeAllocations);
    m.put("brk_ml_cache_pool_active_allocations_tiny", activeAllocationsTiny);
    m.put("brk_ml_cache_pool_active_allocations_small", activeAllocationsSmall);
    m.put("brk_ml_cache_pool_active_allocations_normal", activeAllocationsNormal);
    m.put("brk_ml_cache_pool_active_allocations_huge", activeAllocationsHuge);

    metrics.clear();
    metrics.add(m);
    return metrics;

}