use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl 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")));
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class MetricRegistry method histogram.
/**
* Creates and registre named histogram gauge.
*
* @param name Name
* @param bounds Bounds of measurements.
* @param desc Description.
* @return {@link HistogramMetricImpl}
*/
public HistogramMetricImpl histogram(String name, long[] bounds, @Nullable String desc) {
String fullName = metricName(regName, name);
HistogramMetricImpl metric = addMetric(name, new HistogramMetricImpl(fullName, desc, bounds));
long[] cfgBounds = histogramCfgProvider.apply(fullName);
if (cfgBounds != null)
metric.reset(cfgBounds);
return metric;
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class GridCacheAbstractMetricsSelfTest method testRemoveTime.
/**
*/
@Test
public void testRemoveTime() throws Exception {
IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);
HistogramMetricImpl removeTime = metric("RemoveTime");
HistogramMetricImpl removeAllTime = metric("RemoveAllTime");
assertTrue(stream(removeTime.value()).allMatch(v -> v == 0));
assertTrue(stream(removeAllTime.value()).allMatch(v -> v == 0));
cache.put(1, 1);
cache.put(2, 2);
assertEquals(0, stream(removeTime.value()).sum());
assertEquals(0, stream(removeAllTime.value()).sum());
cache.remove(1);
cache.removeAsync(2).get();
assertTrue(waitForCondition(() -> stream(removeTime.value()).sum() == 2, getTestTimeout()));
assertEquals(0, stream(removeAllTime.value()).sum());
cache.removeAll(singleton(3));
cache.removeAllAsync(singleton(4)).get();
assertTrue(waitForCondition(() -> stream(removeAllTime.value()).sum() == 2, getTestTimeout()));
assertEquals(2, stream(removeTime.value()).sum());
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class GridCacheTransactionalAbstractMetricsSelfTest method testCommitTime.
/**
*/
@Test
public void testCommitTime() {
IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);
HistogramMetricImpl m = metric("CommitTime");
assertTrue(Arrays.stream(m.value()).allMatch(v -> v == 0));
try (Transaction tx = grid(0).transactions().txStart()) {
cache.put(1, 1);
tx.commit();
}
assertEquals(1, Arrays.stream(m.value()).filter(v -> v == 1).count());
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class ClusterMetricsSelfTest method checkPmeMetricsOnNodeJoin.
/**
* @param client Client flag.
* @throws Exception If failed.
*/
private void checkPmeMetricsOnNodeJoin(boolean client) throws Exception {
IgniteEx ignite = startGrid(0);
MetricRegistry reg = ignite.context().metric().registry(PME_METRICS);
LongMetric currentPMEDuration = reg.findMetric(PME_DURATION);
LongMetric currentBlockingPMEDuration = reg.findMetric(PME_OPS_BLOCKED_DURATION);
HistogramMetricImpl durationHistogram = reg.findMetric(PME_DURATION_HISTOGRAM);
HistogramMetricImpl blockindDurationHistogram = reg.findMetric(PME_OPS_BLOCKED_DURATION_HISTOGRAM);
IgniteCache<Object, Object> cache = ignite.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setAtomicityMode(TRANSACTIONAL));
cache.put(1, 1);
awaitPartitionMapExchange();
int timeout = 5000;
assertTrue(GridTestUtils.waitForCondition(() -> currentPMEDuration.value() == 0, timeout));
assertEquals(0, currentBlockingPMEDuration.value());
// There was two blocking exchange: server node start and cache start.
assertEquals(2, Arrays.stream(durationHistogram.value()).sum());
assertEquals(2, Arrays.stream(blockindDurationHistogram.value()).sum());
Lock lock = cache.lock(1);
lock.lock();
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(ignite);
spi.blockMessages((node, message) -> message instanceof GridDhtPartitionsFullMessage);
GridTestUtils.runAsync(() -> client ? startClientGrid("client") : startGrid(1));
assertTrue(waitForCondition(() -> ignite.context().cache().context().exchange().lastTopologyFuture().initialVersion().topologyVersion() == 2, timeout));
if (client)
assertEquals(0, currentBlockingPMEDuration.value());
else
assertTrue(currentBlockingPMEDuration.value() > 0);
lock.unlock();
spi.waitForBlocked();
spi.stopBlock();
awaitPartitionMapExchange();
assertTrue(GridTestUtils.waitForCondition(() -> currentPMEDuration.value() == 0, timeout));
assertEquals(0, currentBlockingPMEDuration.value());
if (client) {
// There was non-blocking exchange: client node start.
assertEquals(3, Arrays.stream(durationHistogram.value()).sum());
assertEquals(2, Arrays.stream(blockindDurationHistogram.value()).sum());
} else {
// There was two blocking exchange: server node start and rebalance completing.
assertEquals(4, Arrays.stream(durationHistogram.value()).sum());
assertEquals(4, Arrays.stream(blockindDurationHistogram.value()).sum());
}
}
Aggregations