Search in sources :

Example 1 with SnapshotView

use of org.apache.ignite.spi.systemview.view.SnapshotView in project ignite by apache.

the class SystemViewSelfTest method testSnapshot.

/**
 */
@Test
public void testSnapshot() throws Exception {
    cleanPersistenceDir();
    String dfltCacheGrp = "testGroup";
    String testSnap0 = "testSnap0";
    String testSnap1 = "testSnap1";
    try (IgniteEx ignite = startGrid(getConfiguration().setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setGroupName(dfltCacheGrp)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setName("pds").setPersistenceEnabled(true))))) {
        ignite.cluster().state(ClusterState.ACTIVE);
        ignite.cache(DEFAULT_CACHE_NAME).put(1, 1);
        ignite.snapshot().createSnapshot(testSnap0).get();
        SystemView<SnapshotView> views = ignite.context().systemView().view(SNAPSHOT_SYS_VIEW);
        assertEquals(1, views.size());
        SnapshotView view = F.first(views);
        assertEquals(testSnap0, view.name());
        assertEquals(ignite.localNode().consistentId().toString(), view.consistentId());
        Collection<?> constIds = F.nodeConsistentIds(ignite.cluster().nodes());
        assertEquals(F.concat(constIds, ","), view.baselineNodes());
        assertEquals(F.concat(Arrays.asList(dfltCacheGrp, METASTORAGE_CACHE_NAME), ","), view.cacheGroups());
        ignite.createCache("testCache");
        ignite.snapshot().createSnapshot(testSnap1).get();
        views = ignite.context().systemView().view(SNAPSHOT_SYS_VIEW);
        assertEquals(2, views.size());
        List<String> exp = Lists.newArrayList(testSnap0, testSnap1);
        views.forEach(v -> assertTrue(exp.remove(v.name())));
        assertTrue(exp.isEmpty());
    }
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 SnapshotView (org.apache.ignite.spi.systemview.view.SnapshotView)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1