Search in sources :

Example 21 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricCommandTest method testRegistryMetrics.

/**
 */
@Test
public void testRegistryMetrics() {
    String mregName = "test-metric-registry";
    MetricRegistry mreg = ignite0.context().metric().registry(mregName);
    mreg.booleanMetric("boolean-metric", "");
    mreg.longMetric("long-metric", "").increment();
    mreg.intMetric("int-metric", "").increment();
    mreg.doubleMetric("double-metric", "");
    mreg.hitRateMetric("hitrate-metric", "", getTestTimeout(), 2);
    mreg.histogram("histogram", new long[] { 50, 100 }, null).value(10);
    mreg.hitRateMetric("hitrate-metric", "", getTestTimeout(), 2);
    mreg.objectMetric("object-metric", Object.class, "").value(new Object() {

        @Override
        public String toString() {
            return "test-object";
        }
    });
    Map<String, String> metrics = metrics(ignite0, mregName);
    assertEquals("0.0", metrics.get(metricName(mregName, "double-metric")));
    assertEquals("false", metrics.get(metricName(mregName, "boolean-metric")));
    assertEquals("1", metrics.get(metricName(mregName, "long-metric")));
    assertEquals("1", metrics.get(metricName(mregName, "int-metric")));
    assertEquals("test-object", metrics.get(metricName(mregName, "object-metric")));
    assertEquals("[1, 0, 0]", metrics.get(metricName(mregName, "histogram")));
    assertEquals("0", metric(ignite0, metricName(mregName, "hitrate-metric")));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Test(org.junit.Test)

Example 22 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricCommandTest method testHistogramMetrics.

/**
 */
@Test
public void testHistogramMetrics() {
    String mregName = "histogram-registry";
    MetricRegistry mreg = ignite0.context().metric().registry(mregName);
    long[] bounds = new long[] { 50, 500 };
    HistogramMetricImpl histogram = mreg.histogram("histogram", bounds, null);
    histogram.value(10);
    histogram.value(51);
    histogram.value(60);
    histogram.value(600);
    histogram.value(600);
    histogram.value(600);
    histogram = mreg.histogram("histogram_with_underscore", bounds, null);
    histogram.value(10);
    histogram.value(51);
    histogram.value(60);
    histogram.value(600);
    histogram.value(600);
    histogram.value(600);
    assertEquals("1", metric(ignite0, metricName(mregName, "histogram_0_50")));
    assertEquals("2", metric(ignite0, metricName(mregName, "histogram_50_500")));
    assertEquals("3", metric(ignite0, metricName(mregName, "histogram_500_inf")));
    assertEquals("[1, 2, 3]", metric(ignite0, metricName(mregName, "histogram")));
    assertEquals("1", metric(ignite0, metricName(mregName, "histogram_with_underscore_0_50")));
    assertEquals("2", metric(ignite0, metricName(mregName, "histogram_with_underscore_50_500")));
    assertEquals("3", metric(ignite0, metricName(mregName, "histogram_with_underscore_500_inf")));
    assertEquals("[1, 2, 3]", metric(ignite0, metricName(mregName, "histogram_with_underscore")));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) Test(org.junit.Test)

Example 23 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricCommandTest method testNodeIdArgument.

/**
 */
@Test
public void testNodeIdArgument() {
    String mregName = "boolean-metric-registry";
    MetricRegistry mreg = ignite0.context().metric().registry(mregName);
    mreg.booleanMetric("boolean-metric", "");
    mreg = ignite(1).context().metric().registry(mregName);
    mreg.booleanMetric("boolean-metric", "").value(true);
    assertEquals("false", metric(ignite0, metricName(mregName, "boolean-metric")));
    assertEquals("true", metric(ignite(1), metricName(mregName, "boolean-metric")));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Test(org.junit.Test)

Example 24 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class MetricCommandTest method testHitrateMetrics.

/**
 */
@Test
public void testHitrateMetrics() {
    String mregName = "hitrate-registry";
    MetricRegistry mreg = ignite0.context().metric().registry(mregName);
    mreg.hitRateMetric("hitrate-metric", "", getTestTimeout(), 2).add(Integer.MAX_VALUE);
    assertEquals(Integer.toString(Integer.MAX_VALUE), metric(ignite0, metricName(mregName, "hitrate-metric")));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Test(org.junit.Test)

Example 25 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.

the class GridCacheVersionManager method start0.

/**
 * {@inheritDoc}
 */
@Override
public void start0() throws IgniteCheckedException {
    MetricRegistry sysreg = cctx.kernalContext().metric().registry(CACHE_METRICS);
    lastDataVer = sysreg.longMetric(LAST_DATA_VER, "The latest data version on the node.");
    sysreg.register(DATA_VER_CLUSTER_ID, () -> dataCenterId, "Data version cluster id.");
    startVer = new GridCacheVersion(0, 0, 0, dataCenterId);
    cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_METRICS_UPDATED);
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry)

Aggregations

MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)86 Test (org.junit.Test)52 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)29 IgniteEx (org.apache.ignite.internal.IgniteEx)26 LongMetric (org.apache.ignite.spi.metric.LongMetric)26 List (java.util.List)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 UUID (java.util.UUID)10 Map (java.util.Map)8 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 ArrayList (java.util.ArrayList)7 IgniteException (org.apache.ignite.IgniteException)7 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)7 IntMetric (org.apache.ignite.spi.metric.IntMetric)7 IgniteCache (org.apache.ignite.IgniteCache)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5