Search in sources :

Example 1 with AllocatorStats

use of org.apache.pulsar.common.stats.AllocatorStats in project incubator-pulsar by apache.

the class AdminTest method brokerStats.

@Test
void brokerStats() throws Exception {
    doReturn("client-id").when(brokerStats).clientAppId();
    Collection<Metrics> metrics = brokerStats.getMetrics();
    assertNotNull(metrics);
    LocalBrokerData loadReport = (LocalBrokerData) brokerStats.getLoadReport();
    assertNotNull(loadReport);
    assertNotNull(loadReport.getCpu());
    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 topic = brokerStats.getTopics2();
    assertNotNull(topic);
    try {
        brokerStats.getBrokerResourceAvailability("prop", "use", "ns2");
        fail("should have failed as ModularLoadManager doesn't support it");
    } catch (RestException re) {
    // Ok
    }
}
Also used : Metrics(org.apache.pulsar.common.stats.Metrics) LocalBrokerData(org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData) AllocatorStats(org.apache.pulsar.common.stats.AllocatorStats) RestException(org.apache.pulsar.broker.web.RestException) StreamingOutput(javax.ws.rs.core.StreamingOutput) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 2 with AllocatorStats

use of org.apache.pulsar.common.stats.AllocatorStats in project incubator-pulsar by apache.

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.metric().directArenas().stream().map(AllocatorStatsGenerator::newPoolArenaStats).collect(Collectors.toList());
    stats.heapArenas = allocator.metric().heapArenas().stream().map(AllocatorStatsGenerator::newPoolArenaStats).collect(Collectors.toList());
    stats.numDirectArenas = allocator.metric().numDirectArenas();
    stats.numHeapArenas = allocator.metric().numHeapArenas();
    stats.numThreadLocalCaches = allocator.metric().numThreadLocalCaches();
    stats.normalCacheSize = allocator.metric().normalCacheSize();
    stats.smallCacheSize = allocator.metric().smallCacheSize();
    stats.tinyCacheSize = allocator.metric().tinyCacheSize();
    return stats;
}
Also used : AllocatorStats(org.apache.pulsar.common.stats.AllocatorStats) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator)

Aggregations

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