use of com.hazelcast.internal.metrics.impl.CapturingCollector in project hazelcast by hazelcast.
the class TcpServerConnectionManagerMetricsTest method testUnifiedEndpointManagerMetricsCollectedOnce.
@Test
public void testUnifiedEndpointManagerMetricsCollectedOnce() {
CapturingCollector collector = new CapturingCollector();
HazelcastInstance instance = createHazelcastInstance();
getNodeEngineImpl(instance).getMetricsRegistry().collect(collector);
// defined by ServerEndpointManager
verifyCollectedOnce(collector, metricDescriptor(TCP_PREFIX_CONNECTION, "count"));
// defined by ServerUnifiedEndpointManager
verifyCollectedOnce(collector, metricDescriptor(TCP_PREFIX_CONNECTION, "clientCount"));
verifyCollectedOnce(collector, metricDescriptor(TCP_PREFIX_CONNECTION, "textCount"));
}
use of com.hazelcast.internal.metrics.impl.CapturingCollector in project hazelcast by hazelcast.
the class TcpMetricValuesTest method test.
private void test(String... members) {
int timeoutSecs = 10;
// start 3 member cluster
final HazelcastInstance hz1 = Hazelcast.newHazelcastInstance(getConfig(members));
final HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(getConfig(members));
final HazelcastInstance hz3 = Hazelcast.newHazelcastInstance(getConfig(members));
assertClusterSize(3, hz1, hz2, hz3);
assertTrueEventually(() -> {
CapturingCollector collector = new CapturingCollector();
getNodeEngineImpl(hz1).getMetricsRegistry().collect(collector);
verifyMetricValue(collector, metricDescriptor(TCP_METRIC_ENDPOINT_MANAGER_COUNT), 2);
verifyMetricValue(collector, metricDescriptor(TCP_METRIC_ENDPOINT_MANAGER_ACTIVE_COUNT), 2);
verifyNoOfCollectedMetrics(collector, TCP_DISCRIMINATOR_ENDPOINT, 2);
verifyNoOfCollectedMetrics(collector, TCP_DISCRIMINATOR_BINDADDRESS, 2);
}, timeoutSecs);
}
use of com.hazelcast.internal.metrics.impl.CapturingCollector in project hazelcast by hazelcast.
the class ClientMetricsTest method assertClientMetricsObservedEventually.
private void assertClientMetricsObservedEventually(HazelcastInstance memberInstance, MetricsRegistry metricsRegistry, String prefix, String metric, ProbeUnit unit) {
assertTrueEventually(() -> {
CapturingCollector collector = new CapturingCollector();
metricsRegistry.collect(collector);
ClientEngine clientEngine = getNode(memberInstance).getClientEngine();
Collection<Client> clients = clientEngine.getClients();
assertEquals(2, clients.size());
for (Client client : clients) {
UUID clientUuid = client.getUuid();
ClientStatistics clientStatistics = clientEngine.getClientStatistics().get(clientUuid);
assertNotNull(clientStatistics);
long timestamp = clientStatistics.timestamp();
MetricDescriptor expectedDescriptor = DEFAULT_DESCRIPTOR_SUPPLIER.get().withPrefix(prefix).withMetric(metric).withUnit(unit).withTag("client", clientUuid.toString()).withTag("clientname", client.getName()).withTag("timestamp", Long.toString(timestamp)).withExcludedTargets(asList(MetricTarget.values())).withIncludedTarget(MANAGEMENT_CENTER);
assertContains(collector.captures().keySet(), expectedDescriptor);
}
});
}
Aggregations