Search in sources :

Example 1 with LongMetric

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;
    }
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) ReadOnlyMetricRegistry(org.apache.ignite.spi.metric.ReadOnlyMetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric)

Example 2 with LongMetric

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());
}
Also used : AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) LongMetric(org.apache.ignite.spi.metric.LongMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with LongMetric

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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) ArrayList(java.util.ArrayList) Ignite(org.apache.ignite.Ignite) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) LongMetric(org.apache.ignite.spi.metric.LongMetric) BooleanSupplier(java.util.function.BooleanSupplier)

Example 4 with LongMetric

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);
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) IgniteEx(org.apache.ignite.internal.IgniteEx) LongMetric(org.apache.ignite.spi.metric.LongMetric) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with LongMetric

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());
}
Also used : BooleanMetric(org.apache.ignite.spi.metric.BooleanMetric) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric)

Aggregations

LongMetric (org.apache.ignite.spi.metric.LongMetric)34 MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)27 Test (org.junit.Test)24 IgniteEx (org.apache.ignite.internal.IgniteEx)15 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)15 Ignite (org.apache.ignite.Ignite)7 List (java.util.List)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 ArrayList (java.util.ArrayList)5 IntMetric (org.apache.ignite.spi.metric.IntMetric)5 UUID (java.util.UUID)4 Metric (org.apache.ignite.spi.metric.Metric)4 File (java.io.File)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Function (java.util.function.Function)3 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)3 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3