Search in sources :

Example 1 with DataStorageMetrics

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();
    }
}
Also used : DataStorageMetrics(org.apache.ignite.DataStorageMetrics) PAX(org.apache.ignite.internal.util.typedef.PAX) IgniteEx(org.apache.ignite.internal.IgniteEx) DataRegionMetrics(org.apache.ignite.DataRegionMetrics)

Aggregations

DataRegionMetrics (org.apache.ignite.DataRegionMetrics)1 DataStorageMetrics (org.apache.ignite.DataStorageMetrics)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 PAX (org.apache.ignite.internal.util.typedef.PAX)1