Search in sources :

Example 6 with Metrics

use of com.yahoo.pulsar.broker.stats.Metrics in project pulsar by yahoo.

the class JvmMetrics method generate.

@SuppressWarnings("restriction")
@Override
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);
}
Also used : PoolArenaMetric(io.netty.buffer.PoolArenaMetric) Metrics(com.yahoo.pulsar.broker.stats.Metrics) PoolChunkListMetric(io.netty.buffer.PoolChunkListMetric) PoolChunkMetric(io.netty.buffer.PoolChunkMetric)

Example 7 with Metrics

use of com.yahoo.pulsar.broker.stats.Metrics in project pulsar by yahoo.

the class ManagedLedgerCacheMetrics method generate.

@Override
public synchronized List<Metrics> generate() {
    // get the ML cache stats bean
    ManagedLedgerFactoryMXBean mlCacheStats = getManagedLedgerCacheStats();
    Metrics m = createMetrics();
    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;
}
Also used : PoolArenaMetric(io.netty.buffer.PoolArenaMetric) ManagedLedgerFactoryMXBean(org.apache.bookkeeper.mledger.ManagedLedgerFactoryMXBean) Metrics(com.yahoo.pulsar.broker.stats.Metrics) PoolChunkListMetric(io.netty.buffer.PoolChunkListMetric) PoolChunkMetric(io.netty.buffer.PoolChunkMetric) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Example 8 with Metrics

use of com.yahoo.pulsar.broker.stats.Metrics in project pulsar by yahoo.

the class AdminTest method brokerStats.

@Test
void brokerStats() throws Exception {
    doReturn("client-id").when(brokerStats).clientAppId();
    Collection<Metrics> metrics = brokerStats.getMetrics();
    assertNotNull(metrics);
    LoadReport loadReport = brokerStats.getLoadReport();
    assertNotNull(loadReport);
    assertEquals(loadReport.isOverLoaded(), false);
    Collection<Metrics> mBeans = brokerStats.getMBeans();
    assertTrue(!mBeans.isEmpty());
    AllocatorStats allocatorStats = brokerStats.getAllocatorStats("default");
    assertNotNull(allocatorStats);
    Map<String, Map<String, PendingBookieOpsStats>> bookieOpsStats = brokerStats.getPendingBookieOpsStats();
    assertTrue(bookieOpsStats.isEmpty());
    StreamingOutput destination = brokerStats.getDestinations2();
    assertNotNull(destination);
    Map<Long, Collection<ResourceUnit>> resource = brokerStats.getBrokerResourceAvailability("prop", "use", "ns2");
    // size should be 1 with default resourceUnit
    assertTrue(resource.size() == 1);
}
Also used : Metrics(com.yahoo.pulsar.broker.stats.Metrics) LoadReport(com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport) AllocatorStats(com.yahoo.pulsar.common.stats.AllocatorStats) Collection(java.util.Collection) StreamingOutput(javax.ws.rs.core.StreamingOutput) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Aggregations

Metrics (com.yahoo.pulsar.broker.stats.Metrics)8 PoolArenaMetric (io.netty.buffer.PoolArenaMetric)2 PoolChunkListMetric (io.netty.buffer.PoolChunkListMetric)2 PoolChunkMetric (io.netty.buffer.PoolChunkMetric)2 HashMap (java.util.HashMap)2 ManagedLedgerImpl (org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl)2 Test (org.testng.annotations.Test)2 MockedPulsarServiceBaseTest (com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)1 BrokerOperabilityMetrics (com.yahoo.pulsar.broker.stats.BrokerOperabilityMetrics)1 ClusterReplicationMetrics (com.yahoo.pulsar.broker.stats.ClusterReplicationMetrics)1 Producer (com.yahoo.pulsar.client.api.Producer)1 ProducerConfiguration (com.yahoo.pulsar.client.api.ProducerConfiguration)1 LoadReport (com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport)1 NamespaceBundleStats (com.yahoo.pulsar.common.policies.data.loadbalancer.NamespaceBundleStats)1 AllocatorStats (com.yahoo.pulsar.common.stats.AllocatorStats)1 StatsOutputStream (com.yahoo.pulsar.utils.StatsOutputStream)1 ByteBuf (io.netty.buffer.ByteBuf)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 Field (java.lang.reflect.Field)1 Collection (java.util.Collection)1