Search in sources :

Example 6 with ReadOnlyMetricRegistry

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());
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) HASH_PK_IDX_NAME(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.HASH_PK_IDX_NAME) Metric(org.apache.ignite.spi.metric.Metric) IgniteEx(org.apache.ignite.internal.IgniteEx) LOGICAL_READS(org.apache.ignite.internal.metric.IoStatisticsHolderCache.LOGICAL_READS) CACHE_GROUP(org.apache.ignite.internal.metric.IoStatisticsType.CACHE_GROUP) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) StreamSupport(java.util.stream.StreamSupport) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) LOGICAL_READS_LEAF(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.LOGICAL_READS_LEAF) Set(java.util.Set) Test(org.junit.Test) HASH_INDEX(org.apache.ignite.internal.metric.IoStatisticsType.HASH_INDEX) LOGICAL_READS_INNER(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.LOGICAL_READS_INNER) Collectors(java.util.stream.Collectors) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Sets(com.google.common.collect.Sets) IgniteCache(org.apache.ignite.IgniteCache) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) IoStatisticsMetricsLocalMXBeanImplSelfTest.resetAllIoMetrics(org.apache.ignite.internal.metric.IoStatisticsMetricsLocalMXBeanImplSelfTest.resetAllIoMetrics) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) LongMetric(org.apache.ignite.spi.metric.LongMetric) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager)

Example 7 with ReadOnlyMetricRegistry

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;
}
Also used : IgniteSpiContext(org.apache.ignite.spi.IgniteSpiContext) Metric(org.apache.ignite.spi.metric.Metric) RECEIVED_MESSAGES_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_METRIC_DESC) IntMap(org.apache.ignite.internal.util.collection.IntMap) RECEIVED_MESSAGES_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_METRIC_NAME) HashMap(java.util.HashMap) Function(java.util.function.Function) RECEIVED_MESSAGES_BY_TYPE_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_BY_TYPE_METRIC_DESC) ClusterNode(org.apache.ignite.cluster.ClusterNode) Collectors.toMap(java.util.stream.Collectors.toMap) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) SENT_BYTES_METRIC_DESC(org.apache.ignite.internal.util.nio.GridNioServer.SENT_BYTES_METRIC_DESC) Map(java.util.Map) IgniteMessageFactoryImpl(org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) SENT_MESSAGES_BY_TYPE_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_BY_TYPE_METRIC_NAME) RECEIVED_MESSAGES_BY_TYPE_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_BY_TYPE_METRIC_NAME) SEPARATOR(org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RECEIVED_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_DESC) SENT_MESSAGES_BY_TYPE_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_BY_TYPE_METRIC_DESC) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) SENT_BYTES_METRIC_NAME(org.apache.ignite.internal.util.nio.GridNioServer.SENT_BYTES_METRIC_NAME) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) COMMUNICATION_METRICS_GROUP_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.COMMUNICATION_METRICS_GROUP_NAME) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) RECEIVED_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.RECEIVED_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_NAME) RECEIVED_BYTES_METRIC_NAME(org.apache.ignite.internal.util.nio.GridNioServer.RECEIVED_BYTES_METRIC_NAME) SENT_MESSAGES_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_METRIC_NAME) RECEIVED_BYTES_METRIC_DESC(org.apache.ignite.internal.util.nio.GridNioServer.RECEIVED_BYTES_METRIC_DESC) SENT_MESSAGES_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_METRIC_DESC) IgniteMessageFactory(org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory) Message(org.apache.ignite.plugin.extensions.communication.Message) SENT_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_DESC(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_DESC) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) LongMetric(org.apache.ignite.spi.metric.LongMetric) Collections(java.util.Collections) SENT_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_NAME(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.SENT_MESSAGES_BY_NODE_CONSISTENT_ID_METRIC_NAME) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) UUID(java.util.UUID)

Example 8 with ReadOnlyMetricRegistry

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));
}
Also used : GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) HASH_PK_IDX_NAME(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.HASH_PK_IDX_NAME) LOGICAL_READS_LEAF(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.LOGICAL_READS_LEAF) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) HASH_INDEX(org.apache.ignite.internal.metric.IoStatisticsType.HASH_INDEX) LOGICAL_READS_INNER(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.LOGICAL_READS_INNER) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) PHYSICAL_READS_INNER(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.PHYSICAL_READS_INNER) MalformedObjectNameException(javax.management.MalformedObjectNameException) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) PHYSICAL_READS(org.apache.ignite.internal.metric.IoStatisticsHolderQuery.PHYSICAL_READS) CACHE_GROUP(org.apache.ignite.internal.metric.IoStatisticsType.CACHE_GROUP) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) LOGICAL_READS(org.apache.ignite.internal.metric.IoStatisticsHolderQuery.LOGICAL_READS) MetricsConfigurationTest.metricsBean(org.apache.ignite.internal.metric.MetricsConfigurationTest.metricsBean) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) StreamSupport(java.util.stream.StreamSupport) LongMetric(org.apache.ignite.spi.metric.LongMetric) PHYSICAL_READS_LEAF(org.apache.ignite.internal.metric.IoStatisticsHolderIndex.PHYSICAL_READS_LEAF) MetricUtils.metricName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager)

Aggregations

ReadOnlyMetricRegistry (org.apache.ignite.spi.metric.ReadOnlyMetricRegistry)8 Metric (org.apache.ignite.spi.metric.Metric)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 GridMetricManager (org.apache.ignite.internal.processors.metric.GridMetricManager)3 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)3 MetricUtils.metricName (org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName)3 LongMetric (org.apache.ignite.spi.metric.LongMetric)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Set (java.util.Set)2 UUID (java.util.UUID)2 Collectors (java.util.stream.Collectors)2 StreamSupport (java.util.stream.StreamSupport)2 IgniteCache (org.apache.ignite.IgniteCache)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 HASH_PK_IDX_NAME (org.apache.ignite.internal.metric.IoStatisticsHolderIndex.HASH_PK_IDX_NAME)2