use of com.hazelcast.internal.metrics.managementcenter.ConcurrentArrayRingbuffer.RingbufferSlice 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);
});
}
use of com.hazelcast.internal.metrics.managementcenter.ConcurrentArrayRingbuffer.RingbufferSlice in project hazelcast by hazelcast.
the class ReadMetricsOperation method run.
@Override
public void run() {
ILogger logger = getNodeEngine().getLogger(getClass());
MetricsService service = getService();
CompletableFuture<RingbufferSlice<Entry<Long, byte[]>>> future = service.readMetrics(offset);
future.whenCompleteAsync(withTryCatch(logger, (slice, error) -> doSendResponse(error != null ? peel(error) : slice)), CALLER_RUNS);
}
use of com.hazelcast.internal.metrics.managementcenter.ConcurrentArrayRingbuffer.RingbufferSlice in project hazelcast by hazelcast.
the class MetricsServiceTest method readMetrics.
private void readMetrics(MetricsService metricsService, long sequence, MetricConsumer metricConsumer) throws InterruptedException, java.util.concurrent.ExecutionException {
CompletableFuture<RingbufferSlice<Map.Entry<Long, byte[]>>> future = metricsService.readMetrics(sequence);
RingbufferSlice<Map.Entry<Long, byte[]>> ringbufferSlice = future.get();
MetricsResultSet metricsResultSet = new MetricsResultSet(ringbufferSlice.nextSequence(), ringbufferSlice.elements());
metricsResultSet.collections().forEach(entry -> extractMetrics(entry.getValue(), metricConsumer));
}
Aggregations