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
}
}
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;
}
Aggregations