use of com.hazelcast.internal.metrics.managementcenter.ReadMetricsOperation in project hazelcast by hazelcast.
the class ReadMetricsOperationTest method testMetricsPresent_map.
@Test
public void testMetricsPresent_map() {
Config config = new Config();
HazelcastInstance hzInstance = createHazelcastInstance(config);
IMap<Object, Object> map = hzInstance.getMap("map");
map.put("key", "value");
NodeEngineImpl nodeEngine = getNode(hzInstance).getNodeEngine();
OperationServiceImpl operationService = nodeEngine.getOperationService();
AtomicLong nextSequence = new AtomicLong();
assertTrueEventually(() -> {
long sequence = nextSequence.get();
ReadMetricsOperation readMetricsOperation = new ReadMetricsOperation(sequence);
InternalCompletableFuture<RingbufferSlice<Map.Entry<Long, byte[]>>> future = operationService.invokeOnTarget(MetricsService.SERVICE_NAME, readMetricsOperation, nodeEngine.getThisAddress());
RingbufferSlice<Map.Entry<Long, byte[]>> ringbufferSlice = future.get();
MetricsResultSet metricsResultSet = new MetricsResultSet(ringbufferSlice.nextSequence(), ringbufferSlice.elements());
nextSequence.set(metricsResultSet.nextSequence());
boolean mapMetric = false;
List<Map.Entry<Long, byte[]>> collections = metricsResultSet.collections();
MetricKeyConsumer metricConsumer = new MetricKeyConsumer();
for (Map.Entry<Long, byte[]> entry : collections) {
MetricsCompressor.extractMetrics(entry.getValue(), metricConsumer);
}
assertTrue(metricConsumer.mapMetric);
});
}
Aggregations