Search in sources :

Example 31 with LongMetric

use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.

the class ZookeeperDiscoveryMiscTest method testMbean.

/**
 * @throws Exception if failed.
 */
@Test
public void testMbean() throws Exception {
    int cnt = 3;
    startGrids(cnt);
    UUID crdNodeId = grid(0).localNode().id();
    try {
        for (int i = 0; i < cnt; i++) {
            IgniteEx grid = grid(i);
            ZookeeperDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs", ZookeeperDiscoverySpi.class, ZookeeperDiscoverySpiMBean.class);
            MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
            assertNotNull(bean);
            assertEquals(String.valueOf(grid.cluster().node(crdNodeId)), bean.getCoordinatorNodeFormatted());
            assertEquals(String.valueOf(grid.cluster().localNode()), bean.getLocalNodeFormatted());
            assertEquals(zkCluster.getConnectString(), bean.getZkConnectionString());
            assertEquals((long) grid.configuration().getFailureDetectionTimeout(), bean.getZkSessionTimeout());
            assertEquals(grid.cluster().topologyVersion(), discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
            assertEquals(grid.cluster().node(crdNodeId).id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
            assertEquals(cnt - i - 1, bean.getNodesJoined());
            assertEquals(cnt - i - 1, discoReg.<LongMetric>findMetric("JoinedNodes").value());
            Arrays.asList("LeftNodes", "FailedNodes", "CommunicationErrors").forEach(name -> {
                assertEquals(0, discoReg.<LongMetric>findMetric(name).value());
            });
            assertEquals(0, bean.getNodesLeft());
            assertEquals(0, bean.getNodesFailed());
            assertEquals(0, bean.getCommErrorProcNum());
        }
    } finally {
        stopAllGrids();
    }
}
Also used : ZookeeperDiscoverySpiMBean(org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpiMBean) ObjectMetric(org.apache.ignite.spi.metric.ObjectMetric) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) LongMetric(org.apache.ignite.spi.metric.LongMetric) UUID(java.util.UUID) Test(org.junit.Test)

Example 32 with LongMetric

use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.

the class CacheGroupMetricsWithIndexTest method testIndexCreateCountPartitionsLeftInCluster.

/**
 * Test number of partitions need to finished create indexes.
 * <p>Case:
 * <ul>
 *     <li>Start cluster, load data with indexes</li>
 *     <li>Kill single node, create new index, start node.</li>
 *     <li>Make sure that index rebuild count is in range of total new index size and 0 and decreasing</li>
 *     <li>Wait until rebuild finished, assert that no index errors</li>
 * </ul>
 * </p>
 */
@Test
public void testIndexCreateCountPartitionsLeftInCluster() throws Exception {
    pds = true;
    Ignite ignite = startGrid(0);
    startGrid(1);
    ignite.cluster().active(true);
    IgniteCache<Object, Object> cache1 = ignite.cache(CACHE_NAME);
    String addColSql = "ALTER TABLE " + TABLE + " ADD COLUMN " + COLUMN3_NAME + " BIGINT";
    cache1.query(new SqlFieldsQuery(addColSql)).getAll();
    for (int i = 0; i < 100_000; i++) {
        Long id = (long) i;
        BinaryObjectBuilder o = ignite.binary().builder(OBJECT_NAME).setField(KEY_NAME, id).setField(COLUMN1_NAME, i / 2).setField(COLUMN2_NAME, "str" + Integer.toHexString(i)).setField(COLUMN3_NAME, id * 10);
        cache1.put(id, o.build());
    }
    stopGrid(1);
    MetricRegistry metrics = cacheGroupMetrics(0, GROUP_NAME).get2();
    GridTestUtils.runAsync(() -> {
        String createIdxSql = "CREATE INDEX " + INDEX_NAME + " ON " + TABLE + "(" + COLUMN3_NAME + ")";
        cache1.query(new SqlFieldsQuery(createIdxSql)).getAll();
        String selectIdxSql = "select * from information_schema.indexes where index_name='" + INDEX_NAME + "'";
        List<List<?>> all = cache1.query(new SqlFieldsQuery(selectIdxSql)).getAll();
        assertEquals("Index not found", 1, all.size());
    });
    final LongMetric idxBuildCntPartitionsLeft0 = metrics.findMetric("IndexBuildCountPartitionsLeft");
    assertTrue("Timeout wait start build index", waitForCondition(() -> idxBuildCntPartitionsLeft0.value() > 0, 30_000));
    assertTrue("Timeout wait finished build index", waitForCondition(() -> idxBuildCntPartitionsLeft0.value() == 0, 30_000));
    startGrid(1);
    metrics = cacheGroupMetrics(1, GROUP_NAME).get2();
    final LongMetric idxBuildCntPartitionsLeft1 = metrics.findMetric("IndexBuildCountPartitionsLeft");
    assertTrue("Timeout wait start build index", waitForCondition(() -> idxBuildCntPartitionsLeft1.value() > 0, 30_000));
    assertTrue("Timeout wait finished build index", waitForCondition(() -> idxBuildCntPartitionsLeft1.value() == 0, 30_000));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Ignite(org.apache.ignite.Ignite) ArrayList(java.util.ArrayList) List(java.util.List) LongMetric(org.apache.ignite.spi.metric.LongMetric) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Test(org.junit.Test)

Example 33 with LongMetric

use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.

the class CacheGroupMetricsWithIndexTest method testIndexRebuildCountPartitionsLeftInCluster.

/**
 * Test number of partitions need to finished indexes rebuilding.
 * <p>Case:
 * <ul>
 *     <li>Start cluster, load data with indexes</li>
 *     <li>Kill single node, delete index.bin, start node.</li>
 *     <li>Make sure that index rebuild count is in range of total new index size and 0 and decreasing</li>
 *     <li>Wait until rebuild finished, assert that no index errors</li>
 * </ul>
 * </p>
 */
@Test
public void testIndexRebuildCountPartitionsLeftInCluster() throws Exception {
    pds = true;
    Ignite ignite = startGrid(0);
    startGrid(1);
    ignite.cluster().active(true);
    IgniteCache<Object, Object> cache1 = ignite.cache(CACHE_NAME);
    for (int i = 0; i < 100_000; i++) {
        Long id = (long) i;
        BinaryObjectBuilder o = ignite.binary().builder(OBJECT_NAME).setField(KEY_NAME, id).setField(COLUMN1_NAME, i / 2).setField(COLUMN2_NAME, "str" + Integer.toHexString(i));
        cache1.put(id, o.build());
    }
    String consistentId = ignite.cluster().localNode().consistentId().toString();
    stopGrid(0);
    File dir = U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false);
    IOFileFilter filter = FileFilterUtils.nameFileFilter("index.bin");
    Collection<File> idxBinFiles = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
    for (File indexBin : idxBinFiles) if (indexBin.getAbsolutePath().contains(consistentId))
        U.delete(indexBin);
    startGrid(0);
    MetricRegistry metrics = cacheGroupMetrics(0, GROUP_NAME).get2();
    LongMetric idxBuildCntPartitionsLeft = metrics.findMetric("IndexBuildCountPartitionsLeft");
    assertTrue("Timeout wait start rebuild index", waitForCondition(() -> idxBuildCntPartitionsLeft.value() > 0, 30_000));
    assertTrue("Timeout wait finished rebuild index", GridTestUtils.waitForCondition(() -> idxBuildCntPartitionsLeft.value() == 0, 30_000));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) Ignite(org.apache.ignite.Ignite) LongMetric(org.apache.ignite.spi.metric.LongMetric) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) File(java.io.File) Test(org.junit.Test)

Example 34 with LongMetric

use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.

the class CacheGroupMetricsWithIndexTest method testIndexCreateCountPartitionsLeft.

/**
 * Test number of partitions need to finished create indexes.
 */
@Test
public void testIndexCreateCountPartitionsLeft() throws Exception {
    pds = true;
    Ignite ignite = startGrid(0);
    ignite.cluster().active(true);
    IgniteCache<Object, Object> cache1 = ignite.cache(CACHE_NAME);
    String addColSql = "ALTER TABLE " + TABLE + " ADD COLUMN " + COLUMN3_NAME + " BIGINT";
    cache1.query(new SqlFieldsQuery(addColSql)).getAll();
    for (int i = 0; i < 100_000; i++) {
        Long id = (long) i;
        BinaryObjectBuilder o = ignite.binary().builder(OBJECT_NAME).setField(KEY_NAME, id).setField(COLUMN1_NAME, i / 2).setField(COLUMN2_NAME, "str" + Integer.toHexString(i)).setField(COLUMN3_NAME, id * 10);
        cache1.put(id, o.build());
    }
    MetricRegistry metrics = cacheGroupMetrics(0, GROUP_NAME).get2();
    GridTestUtils.runAsync(() -> {
        String createIdxSql = "CREATE INDEX " + INDEX_NAME + " ON " + TABLE + "(" + COLUMN3_NAME + ")";
        cache1.query(new SqlFieldsQuery(createIdxSql)).getAll();
        String selectIdxSql = "select * from information_schema.indexes where index_name='" + INDEX_NAME + "'";
        List<List<?>> all = cache1.query(new SqlFieldsQuery(selectIdxSql)).getAll();
        assertEquals("Index not found", 1, all.size());
    });
    LongMetric idxBuildCntPartitionsLeft = metrics.findMetric("IndexBuildCountPartitionsLeft");
    assertTrue("Timeout wait start build index", waitForCondition(() -> idxBuildCntPartitionsLeft.value() > 0, 30_000));
    assertTrue("Timeout wait finished build index", waitForCondition(() -> idxBuildCntPartitionsLeft.value() == 0, 30_000));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) Ignite(org.apache.ignite.Ignite) ArrayList(java.util.ArrayList) List(java.util.List) LongMetric(org.apache.ignite.spi.metric.LongMetric) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Test(org.junit.Test)

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