use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.
the class ClientEngineImpl method getClientStatistics.
@Override
public Map<UUID, ClientStatistics> getClientStatistics() {
Collection<ClientEndpoint> clientEndpoints = endpointManager.getEndpoints();
Map<UUID, ClientStatistics> statsMap = createHashMap(clientEndpoints.size());
for (ClientEndpoint e : clientEndpoints) {
ClientStatistics statistics = e.getClientStatistics();
if (null != statistics) {
statsMap.put(e.getUuid(), statistics);
}
}
return statsMap;
}
use of com.hazelcast.client.impl.statistics.ClientStatistics 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);
}
});
}
use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.
the class ClientEndpointImpl method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
ClientStatistics clientStatistics = statsRef.get();
if (clientStatistics != null && clientStatistics.metricsBlob() != null) {
byte[] metricsBlob = clientStatistics.metricsBlob();
if (metricsBlob.length == 0) {
// zero length means that the client does not support the new format
return;
}
long timestamp = clientStatistics.timestamp();
MetricConsumer consumer = new MetricConsumer() {
@Override
public void consumeLong(MetricDescriptor descriptor, long value) {
context.collect(enhanceDescriptor(descriptor, timestamp), value);
}
@Override
public void consumeDouble(MetricDescriptor descriptor, double value) {
context.collect(enhanceDescriptor(descriptor, timestamp), value);
}
private MetricDescriptor enhanceDescriptor(MetricDescriptor descriptor, long timestamp) {
return descriptor.withExcludedTargets(MetricTarget.ALL_TARGETS).withIncludedTarget(MANAGEMENT_CENTER).withTag(METRICS_TAG_CLIENT, getUuid().toString()).withTag(METRICS_TAG_CLIENTNAME, clientName).withTag(METRICS_TAG_TIMESTAMP, Long.toString(timestamp));
}
};
MetricsCompressor.extractMetrics(metricsBlob, consumer);
}
}
use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.
the class ClientStatisticsMessageTask method call.
@Override
protected Object call() throws Exception {
ClientStatistics clientStatistics = new ClientStatistics(parameters.timestamp, parameters.clientAttributes, parameters.metricsBlob);
endpoint.setClientStatistics(clientStatistics);
return null;
}
use of com.hazelcast.client.impl.statistics.ClientStatistics in project hazelcast by hazelcast.
the class TimedMemberStateFactory method getClientAttributes.
private Map<UUID, String> getClientAttributes(Map<UUID, ClientStatistics> allClientStatistics) {
Map<UUID, String> statsMap = createHashMap(allClientStatistics.size());
for (Map.Entry<UUID, ClientStatistics> entry : allClientStatistics.entrySet()) {
UUID uuid = entry.getKey();
ClientStatistics statistics = entry.getValue();
if (statistics != null) {
statsMap.put(uuid, statistics.clientAttributes());
}
}
return statsMap;
}
Aggregations