Search in sources :

Example 1 with CapturingCollector

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"));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CapturingCollector(com.hazelcast.internal.metrics.impl.CapturingCollector) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CapturingCollector

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CapturingCollector(com.hazelcast.internal.metrics.impl.CapturingCollector)

Example 3 with CapturingCollector

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);
        }
    });
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ClientEngine(com.hazelcast.client.impl.ClientEngine) ClientStatistics(com.hazelcast.client.impl.statistics.ClientStatistics) CapturingCollector(com.hazelcast.internal.metrics.impl.CapturingCollector) Client(com.hazelcast.client.Client) UUID(java.util.UUID)

Aggregations

CapturingCollector (com.hazelcast.internal.metrics.impl.CapturingCollector)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Client (com.hazelcast.client.Client)1 ClientEngine (com.hazelcast.client.impl.ClientEngine)1 ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)1 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 UUID (java.util.UUID)1 Test (org.junit.Test)1