Search in sources :

Example 1 with AllocatorStats

use of com.yahoo.pulsar.common.stats.AllocatorStats in project pulsar by yahoo.

the class AllocatorStatsGenerator method generate.

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 {
        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;
}
Also used : AllocatorStats(com.yahoo.pulsar.common.stats.AllocatorStats) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Example 2 with AllocatorStats

use of com.yahoo.pulsar.common.stats.AllocatorStats 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

AllocatorStats (com.yahoo.pulsar.common.stats.AllocatorStats)2 MockedPulsarServiceBaseTest (com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest)1 Metrics (com.yahoo.pulsar.broker.stats.Metrics)1 LoadReport (com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 Test (org.testng.annotations.Test)1