Example usage for io.netty.buffer PoolArenaMetric chunkLists

List of usage examples for io.netty.buffer PoolArenaMetric chunkLists

Introduction

In this page you can find the example usage for io.netty.buffer PoolArenaMetric chunkLists.

Prototype

List<PoolChunkListMetric> chunkLists();

Source Link

Document

Returns an unmodifiable List which holds PoolChunkListMetric s.

Usage

From source file:com.heliosapm.utils.buffer.BufferArenaMonitor.java

License:Apache License

/**
 * <p>Refreshes the arena stats</p>
 * {@inheritDoc}//from   w ww.j a v a2 s  . c o m
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    final long start = System.currentTimeMillis();
    final List<PoolArenaMetric> arenaMetrics = direct ? pooledAllocator.directArenas()
            : pooledAllocator.heapArenas();

    totalChunkSize = 0;
    chunkFreeBytes = 0;
    chunkUsedBytes = 0;
    chunkUsage = 0;

    chunkLists = 0;
    smallSubPages = 0;
    tinySubPages = 0;
    allocations = 0;
    tinyAllocations = 0;
    smallAllocations = 0;
    normalAllocations = 0;
    hugeAllocations = 0;
    deallocations = 0;
    tinyDeallocations = 0;
    smallDeallocations = 0;
    normalDeallocations = 0;
    hugeDeallocations = 0;
    activeAllocations = 0;
    activeTinyAllocations = 0;
    activeSmallAllocations = 0;
    activeNormalAllocations = 0;
    activeHugeAllocations = 0;
    for (PoolArenaMetric poolArenaMetric : arenaMetrics) {
        for (PoolChunkListMetric pclm : poolArenaMetric.chunkLists()) {
            for (Iterator<PoolChunkMetric> iter = pclm.iterator(); iter.hasNext();) {
                PoolChunkMetric pcm = iter.next();
                totalChunkSize += pcm.chunkSize();
                chunkFreeBytes += pcm.freeBytes();
            }
        }
        chunkLists += poolArenaMetric.chunkLists().size();
        smallSubPages += poolArenaMetric.smallSubpages().size();
        tinySubPages += poolArenaMetric.tinySubpages().size();
        allocations += poolArenaMetric.numAllocations();
        tinyAllocations += poolArenaMetric.numTinyAllocations();
        smallAllocations += poolArenaMetric.numSmallAllocations();
        normalAllocations += poolArenaMetric.numNormalAllocations();
        hugeAllocations += poolArenaMetric.numHugeAllocations();
        deallocations += poolArenaMetric.numDeallocations();
        tinyDeallocations += poolArenaMetric.numTinyDeallocations();
        smallDeallocations += poolArenaMetric.numSmallDeallocations();
        normalDeallocations += poolArenaMetric.numNormalDeallocations();
        hugeDeallocations += poolArenaMetric.numHugeDeallocations();
        activeAllocations += poolArenaMetric.numActiveAllocations();
        activeTinyAllocations += poolArenaMetric.numActiveTinyAllocations();
        activeSmallAllocations += poolArenaMetric.numActiveSmallAllocations();
        activeNormalAllocations += poolArenaMetric.numActiveNormalAllocations();
        activeHugeAllocations += poolArenaMetric.numActiveHugeAllocations();
    }
    chunkUsedBytes = totalChunkSize - chunkFreeBytes;
    chunkUsage = perc(totalChunkSize, chunkUsedBytes);

    lastElapsed = System.currentTimeMillis() - start;
    //log.debug("Collected [{}] allocator stats from [{}] arena metrics in {} ms.", type, arenaMetrics.size(), lastElapsed);
}

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

License:Apache License

private static PoolArenaStats newPoolArenaStats(PoolArenaMetric m) {
    PoolArenaStats stats = new PoolArenaStats();
    stats.numTinySubpages = m.numTinySubpages();
    stats.numSmallSubpages = m.numSmallSubpages();
    stats.numChunkLists = m.numChunkLists();

    stats.tinySubpages = m.tinySubpages().stream().map(x -> newPoolSubpageStats(x))
            .collect(Collectors.toList());
    stats.smallSubpages = m.smallSubpages().stream().map(x -> newPoolSubpageStats(x))
            .collect(Collectors.toList());
    stats.chunkLists = m.chunkLists().stream().map(x -> newPoolChunkListStats(x)).collect(Collectors.toList());

    stats.numAllocations = m.numAllocations();
    stats.numTinyAllocations = m.numTinyAllocations();
    stats.numSmallAllocations = m.numSmallAllocations();
    stats.numNormalAllocations = m.numNormalAllocations();
    stats.numHugeAllocations = m.numHugeAllocations();
    stats.numDeallocations = m.numDeallocations();
    stats.numTinyDeallocations = m.numTinyDeallocations();
    stats.numSmallDeallocations = m.numSmallDeallocations();
    stats.numNormalDeallocations = m.numNormalDeallocations();
    stats.numHugeDeallocations = m.numHugeDeallocations();
    stats.numActiveAllocations = m.numActiveAllocations();
    stats.numActiveTinyAllocations = m.numActiveTinyAllocations();
    stats.numActiveSmallAllocations = m.numActiveSmallAllocations();
    stats.numActiveNormalAllocations = m.numActiveNormalAllocations();
    stats.numActiveHugeAllocations = m.numActiveHugeAllocations();
    return stats;
}

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

License:Apache License

@SuppressWarnings("restriction")
@Override/*from w ww  . j  ava 2  s .  c  o m*/
public List<Metrics> generate() {

    Metrics m = createMetrics();

    Runtime r = Runtime.getRuntime();

    m.put("jvm_heap_used", r.totalMemory() - r.freeMemory());
    m.put("jvm_max_memory", r.maxMemory());
    m.put("jvm_total_memory", r.totalMemory());

    m.put("jvm_direct_memory_used",
            sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPool().getMemoryUsed());
    m.put("jvm_max_direct_memory", sun.misc.VM.maxDirectMemory());
    m.put("jvm_thread_cnt", getThreadCount());

    m.put("jvm_gc_young_pause", currentYoungGcTime);
    m.put("jvm_gc_young_count", currentYoungGcCount);
    m.put("jvm_gc_old_pause", currentOldGcTime);
    m.put("jvm_gc_old_count", currentOldGcCount);

    long totalAllocated = 0;
    long totalUsed = 0;

    for (PoolArenaMetric arena : PooledByteBufAllocator.DEFAULT.directArenas()) {
        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_default_pool_allocated", totalAllocated);
    m.put("brk_default_pool_used", totalUsed);

    return Lists.newArrayList(m);
}

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  .  j a  va  2 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:com.yahoo.pulsar.websocket.stats.JvmMetrics.java

License:Apache License

@SuppressWarnings("restriction")
public Metrics generate() {

    Map<String, String> dimensionMap = Maps.newHashMap();
    dimensionMap.put("system", "jvm");
    Metrics m = create(dimensionMap);/*from   ww w .  ja v a  2  s.  c om*/

    Runtime r = Runtime.getRuntime();

    m.put("jvm_heap_used", r.totalMemory() - r.freeMemory());
    m.put("jvm_max_memory", r.maxMemory());
    m.put("jvm_total_memory", r.totalMemory());

    m.put("jvm_max_direct_memory", sun.misc.VM.maxDirectMemory());
    m.put("jvm_thread_cnt", getThreadCount());

    m.put("jvm_gc_young_pause", currentYoungGcTime);
    m.put("jvm_gc_young_count", currentYoungGcCount);
    m.put("jvm_gc_old_pause", currentOldGcTime);
    m.put("jvm_gc_old_count", currentOldGcCount);

    long totalAllocated = 0;
    long totalUsed = 0;

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

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

    m.put("proxy_default_pool_allocated", totalAllocated);
    m.put("proxy_default_pool_used", totalUsed);

    return m;
}

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

License:Apache License

@SuppressWarnings("restriction")
@Override//from ww w.  j a v  a 2s .c  o m
public List<Metrics> generate() {

    Metrics m = createMetrics();

    Runtime r = Runtime.getRuntime();

    m.put("jvm_heap_used", r.totalMemory() - r.freeMemory());
    m.put("jvm_max_memory", r.maxMemory());
    m.put("jvm_total_memory", r.totalMemory());

    m.put("jvm_direct_memory_used", getJvmDirectMemoryUsed());
    m.put("jvm_max_direct_memory", sun.misc.VM.maxDirectMemory());
    m.put("jvm_thread_cnt", getThreadCount());

    m.put("jvm_gc_young_pause", currentYoungGcTime);
    m.put("jvm_gc_young_count", currentYoungGcCount);
    m.put("jvm_gc_old_pause", currentOldGcTime);
    m.put("jvm_gc_old_count", currentOldGcCount);

    long totalAllocated = 0;
    long totalUsed = 0;

    for (PoolArenaMetric arena : PooledByteBufAllocator.DEFAULT.directArenas()) {
        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_default_pool_allocated", totalAllocated);
    m.put("brk_default_pool_used", totalUsed);

    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();//from w w w  .ja  v a  2 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);

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

}

From source file:org.apache.pulsar.common.stats.JvmMetrics.java

License:Apache License

public List<Metrics> generate() {

    Metrics m = createMetrics();// w  w w  .  j  a  v  a 2  s. c om

    Runtime r = Runtime.getRuntime();

    m.put("jvm_heap_used", r.totalMemory() - r.freeMemory());
    m.put("jvm_max_memory", r.maxMemory());
    m.put("jvm_total_memory", r.totalMemory());

    m.put("jvm_direct_memory_used", getJvmDirectMemoryUsed());
    m.put("jvm_max_direct_memory", PlatformDependent.maxDirectMemory());
    m.put("jvm_thread_cnt", getThreadCount());

    this.gcLogger.logMetrics(m);

    long totalAllocated = 0;
    long totalUsed = 0;

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

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

    m.put(this.componentName + "_default_pool_allocated", totalAllocated);
    m.put(this.componentName + "_default_pool_used", totalUsed);

    return Lists.newArrayList(m);
}

From source file:ratpack.dropwizard.metrics.internal.PooledByteBufAllocatorMetricSet.java

License:Apache License

private void initPoolArenaMetrics(final Iterator<PoolArenaMetric> poolArenasIterator) {
    int counter = 0;
    while (poolArenasIterator.hasNext()) {
        final PoolArenaMetric poolArenaMetric = poolArenasIterator.next();
        final String prefix = format("poolArena.%s", counter);

        metrics.put(format("%s.activeAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numActiveAllocations());
        metrics.put(format("%s.numActiveBytes", prefix), (Gauge<Long>) () -> poolArenaMetric.numActiveBytes());
        metrics.put(format("%s.numActiveHugeAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numActiveHugeAllocations());
        metrics.put(format("%s.numActiveNormalAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numActiveNormalAllocations());
        metrics.put(format("%s.numActiveSmallAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numActiveSmallAllocations());
        metrics.put(format("%s.numActiveTinyAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numActiveTinyAllocations());
        metrics.put(format("%s.numAllocations", prefix), (Gauge<Long>) () -> poolArenaMetric.numAllocations());
        metrics.put(format("%s.numDeallocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numDeallocations());
        metrics.put(format("%s.numHugeAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numHugeAllocations());
        metrics.put(format("%s.numHugeDeallocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numHugeDeallocations());
        metrics.put(format("%s.numNormalAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numNormalAllocations());
        metrics.put(format("%s.numNormalDeallocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numNormalDeallocations());
        metrics.put(format("%s.numSmallAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numSmallAllocations());
        metrics.put(format("%s.numSmallDeallocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numSmallDeallocations());
        metrics.put(format("%s.numTinyAllocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numTinyAllocations());
        metrics.put(format("%s.numTinyDeallocations", prefix),
                (Gauge<Long>) () -> poolArenaMetric.numTinyDeallocations());
        metrics.put(format("%s.numSmallSubpages", prefix),
                (Gauge<Integer>) () -> poolArenaMetric.numSmallSubpages());
        metrics.put(format("%s.numTinySubpages", prefix),
                (Gauge<Integer>) () -> poolArenaMetric.numTinySubpages());

        final Iterator<PoolChunkListMetric> chunksIterator = poolArenaMetric.chunkLists().iterator();
        initPoolChunkListMetrics(prefix, chunksIterator);

        final Iterator<PoolSubpageMetric> smallSubpagesIterator = poolArenaMetric.smallSubpages().iterator();
        initSubpageMetrics(prefix, "smallSubpage", smallSubpagesIterator);

        final Iterator<PoolSubpageMetric> tinySubpagesIterator = poolArenaMetric.tinySubpages().iterator();
        initSubpageMetrics(prefix, "tinySubpage", tinySubpagesIterator);

        counter++;/*from  w  w  w  . j  a va 2  s  .  c o  m*/
    }
}