...
Expand |
---|
title | Custom metrics within a computation |
---|
|
/** */ | private static final class TestCustomMetricsComputeTask extends ComputeTaskAdapter<Void, Long> { |
/** */ private static final class TestComputeJob extends ComputeJobAdapter { /** Ignite instance. */ @IgniteInstanceResource private Ignite ignite; /** {@inheritDoc} */ @Override public Long execute() throws IgniteException { long val = 0; // Some job limit. long limit = 300 +
private static final class TestComputeJob extends ComputeJobAdapter {
@IgniteInstanceResource
private Ignite ignite;
@Override public Long execute() throws IgniteException {
long val = 0;
// Some job limit.
long limit = 300 + ThreadLocalRandom.current().nextLong(700); |
// Registers metric "custom.task.test.current" |
LongValueMetric metricCur = ignite.metrics().customRegistry("task.test").longMetric("current", null); | // Registers metric "custom.task.test.total.sum" |
LongSumMetric metricTotal = ignite.metrics().customRegistry("task.test").longAdderMetric("total.sum", null); | // Registers metric "custom.task.test.ticks" |
LongSumMetric metricTicks = ignite.metrics().customRegistry("task.test").longAdderMetric("ticks", null); |
while (!isCancelled() && val < limit) { |
U.sleep(ThreadLocalRandom.current().nextInt(50)); |
catch (IgniteInterruptedCheckedException ignored) { |
long increment = ThreadLocalRandom.current().nextLong(100); |
return isCancelled() ? 0 : val; |
|
Further Steps
We already have implementations of more complex and useful metrics. We could also store custom metrics. Thus, the development stages might be:
...