use of org.apache.ignite.IgniteSnapshot in project ignite by apache.
the class IgniteClusterSnapshotRestoreSelfTest method testRestoreSharedCacheGroup.
/**
* @throws Exception If failed.
*/
@Test
public void testRestoreSharedCacheGroup() throws Exception {
CacheConfiguration<Integer, Object> cacheCfg1 = txCacheConfig(new CacheConfiguration<Integer, Object>(CACHE1)).setGroupName(SHARED_GRP);
CacheConfiguration<Integer, Object> cacheCfg2 = txCacheConfig(new CacheConfiguration<Integer, Object>(CACHE2)).setGroupName(SHARED_GRP);
IgniteEx ignite = startGridsWithCache(2, CACHE_KEYS_RANGE, valueBuilder(), cacheCfg1, cacheCfg2);
ignite.cluster().state(ClusterState.ACTIVE);
ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
ignite.cache(CACHE1).destroy();
awaitPartitionMapExchange();
locEvts.clear();
IgniteSnapshot snp = ignite.snapshot();
GridTestUtils.assertThrowsAnyCause(log, () -> snp.restoreSnapshot(SNAPSHOT_NAME, Arrays.asList(CACHE1, CACHE2)).get(TIMEOUT), IllegalArgumentException.class, "Cache group(s) was not found in the snapshot");
waitForEvents(EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED, EVT_CLUSTER_SNAPSHOT_RESTORE_FAILED);
assertEquals(2, locEvts.size());
locEvts.clear();
ignite.cache(CACHE2).destroy();
awaitPartitionMapExchange();
snp.restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(SHARED_GRP)).get(TIMEOUT);
assertCacheKeys(ignite.cache(CACHE1), CACHE_KEYS_RANGE);
assertCacheKeys(ignite.cache(CACHE2), CACHE_KEYS_RANGE);
waitForEvents(EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED, EVT_CLUSTER_SNAPSHOT_RESTORE_FINISHED);
assertEquals(2, locEvts.size());
}
Aggregations