use of org.apache.ignite.spi.metric.ReadOnlyMetricRegistry in project ignite by apache.
the class IoStatisticsCacheSelfTest method deriveStatisticNames.
/**
* Extract all tracked names for given statistics type.
*
* @param statType Type of statistics which tracked names need to extract.
* @return Set of present names for given statType
*/
public Set<String> deriveStatisticNames(IoStatisticsType statType) {
assert statType != null;
GridMetricManager mmgr = ignite.context().metric();
Stream<ReadOnlyMetricRegistry> grpsStream = StreamSupport.stream(mmgr.spliterator(), false).filter(grp -> grp.name().startsWith(statType.metricGroupName()));
return grpsStream.flatMap(grp -> StreamSupport.stream(grp.spliterator(), false)).filter(m -> m.name().endsWith("name")).map(Metric::getAsString).collect(Collectors.toSet());
}
use of org.apache.ignite.spi.metric.ReadOnlyMetricRegistry in project ignite by apache.
the class TcpCommunicationMetricsListener method collectMessagesCountByNodeId.
/**
* Collect messages count by nodeId
*/
protected Map<UUID, Long> collectMessagesCountByNodeId(String metricName) {
Map<UUID, Long> res = new HashMap<>();
Map<String, UUID> nodesMapping = ignite.cluster().nodes().stream().collect(toMap(node -> node.consistentId().toString(), ClusterNode::id));
String mregPrefix = COMMUNICATION_METRICS_GROUP_NAME + SEPARATOR;
for (ReadOnlyMetricRegistry mreg : spiCtx.metricRegistries()) {
if (mreg.name().startsWith(mregPrefix)) {
String nodeConsIdStr = mreg.name().substring(mregPrefix.length());
UUID nodeId = nodesMapping.get(nodeConsIdStr);
if (nodeId == null)
continue;
res.put(nodeId, mreg.<LongMetric>findMetric(metricName).value());
}
}
return res;
}
use of org.apache.ignite.spi.metric.ReadOnlyMetricRegistry in project ignite by apache.
the class IoStatisticsMetricsLocalMXBeanImplSelfTest method resetAllIoMetrics.
/**
* Resets all io statistics.
*
* @param ignite Ignite.
*/
public static void resetAllIoMetrics(IgniteEx ignite) throws MalformedObjectNameException {
GridMetricManager mmgr = ignite.context().metric();
StreamSupport.stream(mmgr.spliterator(), false).map(ReadOnlyMetricRegistry::name).filter(name -> {
for (IoStatisticsType type : IoStatisticsType.values()) {
if (name.startsWith(type.metricGroupName()))
return true;
}
return false;
}).forEach(grpName -> resetMetric(ignite, grpName));
}
Aggregations