Search in sources :

Example 11 with HistogramMetricImpl

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

the class OpenCensusMetricExporterSpiTest method testHistogram.

/**
 */
@Test
public void testHistogram() throws Exception {
    String registryName = "test_registry";
    String histogramName = "test_histogram";
    String histogramDesc = "Test histogram description.";
    long[] bounds = new long[] { 10, 100 };
    long[] testValues = new long[] { 5, 50, 50, 500, 500, 500 };
    String[] expectedValuesPtrn = new String[] { "test_registry_test_histogram_0_10.* 1", "test_registry_test_histogram_10_100.* 2", "test_registry_test_histogram_100_inf.* 3" };
    HistogramMetricImpl histogramMetric = ignite.context().metric().registry(registryName).histogram(histogramName, bounds, histogramDesc);
    for (long value : testValues) histogramMetric.value(value);
    assertTrue("Histogram metrics should be exported via http", checkHttpMetrics(expectedValuesPtrn));
    bounds = new long[] { 50 };
    histogramMetric.reset(bounds);
    for (long value : testValues) histogramMetric.value(value);
    expectedValuesPtrn = new String[] { "test_registry_test_histogram_0_50.* 3", "test_registry_test_histogram_50_inf.* 3" };
    assertTrue("Updated histogram metrics should be exported via http", checkHttpMetrics(expectedValuesPtrn));
}
Also used : HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) Test(org.junit.Test) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest)

Example 12 with HistogramMetricImpl

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

the class GridMetricManager method onHistogramConfigChanged.

/**
 * Change {@link HistogramMetric} instance configuration.
 *
 * @param name Metric name.
 * @param bounds New bounds.
 */
private void onHistogramConfigChanged(String name, @Nullable long[] bounds) {
    if (bounds == null)
        return;
    HistogramMetricImpl m = find(name, HistogramMetricImpl.class);
    if (m == null)
        return;
    m.reset(bounds);
}
Also used : HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl)

Example 13 with HistogramMetricImpl

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

the class GridCacheTransactionalAbstractMetricsSelfTest method testRollbackTime.

/**
 */
@Test
public void testRollbackTime() {
    IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);
    HistogramMetricImpl m = metric("RollbackTime");
    assertTrue(Arrays.stream(m.value()).allMatch(v -> v == 0));
    try (Transaction tx = grid(0).transactions().txStart()) {
        cache.put(1, 1);
        tx.rollback();
    }
    assertEquals(1, Arrays.stream(m.value()).filter(v -> v == 1).count());
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) Arrays(java.util.Arrays) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) Transaction(org.apache.ignite.transactions.Transaction) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) U(org.apache.ignite.internal.util.typedef.internal.U) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) ROLLED_BACK(org.apache.ignite.transactions.TransactionState.ROLLED_BACK) Test(org.junit.Test) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) TransactionMetrics(org.apache.ignite.transactions.TransactionMetrics) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) CacheMetrics(org.apache.ignite.cache.CacheMetrics) IgniteTransactions(org.apache.ignite.IgniteTransactions) Transaction(org.apache.ignite.transactions.Transaction) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) Test(org.junit.Test)

Example 14 with HistogramMetricImpl

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

the class MetricsConfigurationTest method testConfigRemovedOnCacheGroupRemove.

/**
 * Tests metric configuration removed on registry remove.
 */
@Test
public void testConfigRemovedOnCacheGroupRemove() throws Exception {
    String cacheRegName = cacheMetricsRegistryName("test", false);
    String mname = metricName(cacheRegName, "GetTime");
    checkOnStartAndRestart((g0, g1) -> {
        CacheConfiguration<String, String> ccfg = new CacheConfiguration<>("test");
        ccfg.setGroupName("group");
        g0.createCache(ccfg);
        awaitPartitionMapExchange();
        HistogramMetricImpl getTime = g0.context().metric().registry(cacheRegName).findMetric("GetTime");
        assertNotEquals(BOUNDS.length, getTime.bounds().length);
        metricsBean(g0).configureHistogramMetric(mname, BOUNDS);
        assertArrayEquals(BOUNDS, g0.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
        assertArrayEquals(BOUNDS, g1.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
    }, (g0, g1) -> {
        assertArrayEquals(BOUNDS, g0.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
        assertArrayEquals(BOUNDS, g1.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
        g0.destroyCache("test");
        awaitPartitionMapExchange();
        assertNull(g0.context().distributedMetastorage().read(mname));
        assertNull(g1.context().distributedMetastorage().read(mname));
    });
}
Also used : HistogramMetric(org.apache.ignite.spi.metric.HistogramMetric) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 15 with HistogramMetricImpl

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

the class MetricsSelfTest method testHistogramNames.

/**
 */
@Test
public void testHistogramNames() throws Exception {
    HistogramMetricImpl h = new HistogramMetricImpl("test", null, new long[] { 10, 50, 500 });
    String[] names = histogramBucketNames(h);
    assertArrayEquals(new String[] { "test_0_10", "test_10_50", "test_50_500", "test_500_inf" }, names);
}
Also used : HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

HistogramMetricImpl (org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl)18 Test (org.junit.Test)13 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)7 IgniteCache (org.apache.ignite.IgniteCache)6 CacheMetrics (org.apache.ignite.cache.CacheMetrics)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 U (org.apache.ignite.internal.util.typedef.internal.U)6 Transaction (org.apache.ignite.transactions.Transaction)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 LongMetric (org.apache.ignite.spi.metric.LongMetric)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Arrays.stream (java.util.Arrays.stream)4 Collections.singleton (java.util.Collections.singleton)4 HashMap (java.util.HashMap)4 LinkedHashSet (java.util.LinkedHashSet)4 Map (java.util.Map)4 Set (java.util.Set)4 TreeSet (java.util.TreeSet)4 TimeUnit (java.util.concurrent.TimeUnit)4