use of org.apache.ignite.DataStorageMetrics in project ignite by apache.
the class IgniteDataStorageMetricsSelfTest method testPersistenceMetrics.
/**
* @throws Exception if failed.
*/
public void testPersistenceMetrics() throws Exception {
final IgniteEx ig = startGrid(0);
ig.active(true);
try {
IgniteCache<Object, Object> cache = ig.cache("cache");
for (int i = 0; i < 10; i++) cache.put(i, new Person("first-" + i, "last-" + i));
IgniteCache<Object, Object> cacheNp = ig.cache("cache-np");
for (int i = 0; i < 10; i++) cacheNp.put(i, new Person("first-" + i, "last-" + i));
DataRegionMetrics memMetrics = ig.dataRegionMetrics("dflt-plc");
assertNotNull(memMetrics);
assertTrue(memMetrics.getDirtyPages() > 0);
assertTrue(memMetrics.getPagesFillFactor() > 0);
memMetrics = ig.dataRegionMetrics("no-persistence");
assertNotNull(memMetrics);
assertTrue(memMetrics.getTotalAllocatedPages() > 0);
assertTrue(memMetrics.getPagesFillFactor() > 0);
ig.context().cache().context().database().waitForCheckpoint("test");
assertTrue(GridTestUtils.waitForCondition(new PAX() {
@Override
public boolean applyx() {
DataStorageMetrics pMetrics = ig.dataStorageMetrics();
assertNotNull(pMetrics);
return pMetrics.getLastCheckpointTotalPagesNumber() != 0 && pMetrics.getLastCheckpointDataPagesNumber() != 0;
}
}, 10_000));
} finally {
stopAllGrids();
}
}
Aggregations