use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class IoStatisticsCacheSelfTest method logicalReads.
/**
* @param mmgr Metric manager.
* @param type Staticstics type.
* @param id Metric registry id.
* @return Logical reads count.
*/
public static long logicalReads(GridMetricManager mmgr, IoStatisticsType type, String id) {
MetricRegistry mreg = mmgr.registry(metricName(type.metricGroupName(), id));
if (type == CACHE_GROUP)
return mreg.<LongMetric>findMetric(LOGICAL_READS).value();
else {
long leaf = mreg.<LongMetric>findMetric(LOGICAL_READS_LEAF).value();
long inner = mreg.<LongMetric>findMetric(LOGICAL_READS_INNER).value();
return leaf + inner;
}
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class MetricsSelfTest method testLongMetric.
/**
*/
@Test
public void testLongMetric() throws Exception {
final long[] v = new long[] { 42 };
mreg.register("lmtest", () -> v[0], "test");
LongMetric m = mreg.findMetric("lmtest");
assertEquals(v[0], m.value());
v[0] = 1;
assertEquals(v[0], m.value());
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class GridCommandHandlerTest method doClusterSnapshotCreate.
/**
* @param syncMode Execute operation synchrnously.
* @throws Exception If failed.
*/
private void doClusterSnapshotCreate(boolean syncMode) throws Exception {
int keysCnt = 100;
String snpName = "snapshot_02052020";
IgniteEx ig = startGrid(0);
ig.cluster().state(ACTIVE);
createCacheAndPreload(ig, keysCnt);
injectTestSystemOut();
CommandHandler h = new CommandHandler();
// Invalid command syntax check.
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute(h, "--snapshot", "create", snpName, "blah"));
assertContains(log, testOut.toString(), "Invalid argument: blah. Possible options: --sync.");
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute(h, "--snapshot", "create", snpName, "--sync", "blah"));
assertContains(log, testOut.toString(), "Invalid argument: blah.");
List<String> args = new ArrayList<>(F.asList("--snapshot", "create", snpName));
if (syncMode)
args.add("--sync");
assertEquals(EXIT_CODE_OK, execute(h, args));
LongMetric opEndTimeMetric = ig.context().metric().registry(SNAPSHOT_METRICS).findMetric("LastSnapshotEndTime");
BooleanSupplier endTimeMetricPredicate = () -> opEndTimeMetric.value() > 0;
if (syncMode)
assertTrue(endTimeMetricPredicate.getAsBoolean());
else {
assertTrue("Waiting for snapshot operation end failed.", waitForCondition(endTimeMetricPredicate::getAsBoolean, getTestTimeout()));
}
assertContains(log, (String) h.getLastOperationResult(), snpName);
stopAllGrids();
IgniteConfiguration cfg = optimize(getConfiguration(getTestIgniteInstanceName(0)));
cfg.setWorkDirectory(Paths.get(resolveSnapshotWorkDirectory(cfg).getAbsolutePath(), snpName).toString());
Ignite snpIg = startGrid(cfg);
snpIg.cluster().state(ACTIVE);
List<Integer> range = IntStream.range(0, keysCnt).boxed().collect(Collectors.toList());
snpIg.cache(DEFAULT_CACHE_NAME).forEach(e -> range.remove((Integer) e.getKey()));
assertTrue("Snapshot must contains cache data [left=" + range + ']', range.isEmpty());
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testCommunication.
/**
* Tests SSL communication metrics produced by node connection.
*/
@Test
public void testCommunication() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), COMMUNICATION_METRICS_GROUP_NAME);
assertEquals(0, reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value());
assertEquals(0, reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value());
checkSslCommunicationMetrics(reg, 0, 0, 0);
try (IgniteEx cliNode = startGrid(nodeConfiguration(1, true, "client", "trustone", CIPHER_SUITE, "TLSv1.2"));
IgniteEx srvNode = startGrid(nodeConfiguration(2, false, "node01", "trustone", CIPHER_SUITE, "TLSv1.2"))) {
checkSslCommunicationMetrics(reg, 2, 2, 0);
MetricRegistry cliNodeReg = mreg(cliNode, COMMUNICATION_METRICS_GROUP_NAME);
checkSslCommunicationMetrics(cliNodeReg, 0, 1, 0);
assertTrue(cliNodeReg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(cliNodeReg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
MetricRegistry srvNodeReg = mreg(srvNode, COMMUNICATION_METRICS_GROUP_NAME);
checkSslCommunicationMetrics(srvNodeReg, 0, 1, 0);
assertTrue(srvNodeReg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(srvNodeReg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
}
assertTrue(reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
checkSslCommunicationMetrics(reg, 2, 0, 0);
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class CacheGroupReencryptionTest method validateMetrics.
/**
* @param node Grid.
* @param finished Expected reencryption status.
*/
private void validateMetrics(IgniteEx node, boolean finished) throws IgniteInterruptedCheckedException {
MetricRegistry registry = node.context().metric().registry(metricName(CacheGroupMetricsImpl.CACHE_GROUP_METRICS_PREFIX, cacheName()));
LongMetric bytesLeft = registry.findMetric("ReencryptionBytesLeft");
if (finished)
assertEquals(0, bytesLeft.value());
else
assertTrue(waitForCondition(() -> bytesLeft.value() > 0, MAX_AWAIT_MILLIS));
BooleanMetric reencryptionFinished = registry.findMetric("ReencryptionFinished");
assertEquals(finished, reencryptionFinished.value());
}
Aggregations