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