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));
}
Aggregations