Search in sources :

Example 86 with MetricRegistry

use of org.apache.ignite.internal.processors.metric.MetricRegistry 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

MetricRegistry (org.apache.ignite.internal.processors.metric.MetricRegistry)86 Test (org.junit.Test)52 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)29 IgniteEx (org.apache.ignite.internal.IgniteEx)26 LongMetric (org.apache.ignite.spi.metric.LongMetric)26 List (java.util.List)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 UUID (java.util.UUID)10 Map (java.util.Map)8 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 ArrayList (java.util.ArrayList)7 IgniteException (org.apache.ignite.IgniteException)7 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)7 IntMetric (org.apache.ignite.spi.metric.IntMetric)7 IgniteCache (org.apache.ignite.IgniteCache)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5