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