Search in sources :

Example 1 with IgniteSnapshot

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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteSnapshot(org.apache.ignite.IgniteSnapshot) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteSnapshot (org.apache.ignite.IgniteSnapshot)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 Test (org.junit.Test)1