Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setReadFromBackup()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setReadFromBackup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyReplicated() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
    cfg.setCacheMode(CacheMode.REPLICATED);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}
 
Example 2
Source File: CacheStoreReadFromBackupTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfig(String cacheName) {
    CacheConfiguration ccfg = new CacheConfiguration<>(cacheName);

    ccfg.setCacheMode(cacheMode);
    ccfg.setBackups(backups);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 1));
    ccfg.setReadThrough(true);
    ccfg.setReadFromBackup(true);
    ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(TestStore.class));

    if (near)
        ccfg.setNearConfiguration(new NearCacheConfiguration());

    return ccfg;
}
 
Example 3
Source File: IgniteCacheWriteBehindNoUpdateSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<String, Long> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setReadFromBackup(true);
    ccfg.setCopyOnRead(false);
    ccfg.setName(THROTTLES_CACHE_NAME);

    Duration expiryDuration = new Duration(TimeUnit.MINUTES, 1);

    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration));
    ccfg.setReadThrough(false);
    ccfg.setWriteThrough(true);

    ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(new TestCacheStore()));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 4
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyReplicatedFullSync() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setCacheMode(CacheMode.REPLICATED);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}
 
Example 5
Source File: IgniteCacheLoadRebalanceEvictionSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    LruEvictionPolicy evictionPolicy = new LruEvictionPolicy<>();
    evictionPolicy.setMaxSize(LRU_MAX_SIZE);

    CacheConfiguration<String, byte[]> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setReadFromBackup(true);
    cacheCfg.setEvictionPolicy(evictionPolicy);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setStatisticsEnabled(true);

    cacheCfg.setWriteThrough(false);
    cacheCfg.setReadThrough(false);

    cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new Storage()));

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 6
Source File: IgnitePdsTransactionsHangTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates cache configuration.
 *
 * @return Cache configuration.
 * */
private CacheConfiguration getCacheConfiguration() {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(CACHE_NAME);
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4));
    ccfg.setReadFromBackup(true);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    return ccfg;
}
 
Example 7
Source File: IgniteCacheNodeJoinAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);

    cfg.setReadFromBackup(false); // Force remote 'get'.

    return cfg;
}
 
Example 8
Source File: IgniteCacheClusterReadOnlyModeAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configurations for node start.
 */
protected CacheConfiguration<?, ?>[] cacheConfigurations() {
    CacheConfiguration<?, ?>[] cfgs = ClusterReadOnlyModeTestUtils.cacheConfigurations();

    for (CacheConfiguration cfg : cfgs)
        cfg.setReadFromBackup(true);

    return cfgs;
}
 
Example 9
Source File: IgniteWalRecoverySeveralRestartsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(cacheName);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
    ccfg.setIndexedTypes(Integer.class, IndexedObject.class);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
    ccfg.setReadFromBackup(true);

    cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(500L * 1024 * 1024).setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY)
        .setPageSize(PAGE_SIZE);

    cfg.setDataStorageConfiguration(memCfg);

    cfg.setMarshaller(null);

    BinaryConfiguration binCfg = new BinaryConfiguration();

    binCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(binCfg);

    return cfg;
}
 
Example 10
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyPartitioned() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
    cfg.setCacheMode(CacheMode.PARTITIONED);
    cfg.setBackups(NODES - 1);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}
 
Example 11
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyPartitionedFullSync() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setCacheMode(CacheMode.PARTITIONED);
    cfg.setBackups(NODES - 1);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}
 
Example 12
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyReplicatedMvcc() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
    cfg.setCacheMode(CacheMode.REPLICATED);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
 
Example 13
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyReplicatedFullSyncMvcc() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setCacheMode(CacheMode.REPLICATED);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
 
Example 14
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyPartitionedMvcc() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
    cfg.setCacheMode(CacheMode.PARTITIONED);
    cfg.setBackups(NODES - 1);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
 
Example 15
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyPartitionedFullSyncMvcc() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setCacheMode(CacheMode.PARTITIONED);
    cfg.setBackups(NODES - 1);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
 
Example 16
Source File: GridCacheContinuousQueryConcurrentTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param atomicMode Atomicy mode.
 * @param backups Backups.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, String> cacheConfiguration(CacheMode cacheMode,
    CacheAtomicityMode atomicMode, int backups) {
    CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>("test-" + cacheMode + atomicMode + backups);

    cfg.setCacheMode(cacheMode);
    cfg.setAtomicityMode(atomicMode);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setBackups(backups);
    cfg.setReadFromBackup(false);

    return cfg;
}
 
Example 17
Source File: CacheGetsDistributionAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration.
 */
protected <K, V> CacheConfiguration<K, V> cacheConfiguration() {
    CacheConfiguration<K, V> ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(cacheMode());
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setReadFromBackup(true);
    ccfg.setStatisticsEnabled(true);

    if (cacheMode() == CacheMode.PARTITIONED)
        ccfg.setBackups(backupsCount());

    return ccfg;
}
 
Example 18
Source File: IgniteWalRecoverySeveralRestartsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception if failed.
 */
@Test
public void testWalRecoveryWithDynamicCacheLargeObjects() throws Exception {
    try {
        IgniteEx ignite = startGrid(1);

        ignite.active(true);

        CacheConfiguration<Integer, IndexedObject> dynCacheCfg = new CacheConfiguration<>();

        dynCacheCfg.setName("dyncache");
        dynCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        dynCacheCfg.setRebalanceMode(CacheRebalanceMode.NONE);
        dynCacheCfg.setIndexedTypes(Integer.class, IndexedObject.class);
        dynCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        dynCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
        dynCacheCfg.setReadFromBackup(true);

        ignite.getOrCreateCache(dynCacheCfg);

        try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer("dyncache")) {
            for (int i = 0; i < LARGE_KEYS_COUNT; ++i) {
                if (i % (LARGE_KEYS_COUNT / 100) == 0)
                    info("Loading " + i * 100 / LARGE_KEYS_COUNT + "%");

                IndexedObject obj = new IndexedObject(i);

                obj.payload = new byte[PAGE_SIZE + 2];

                dataLdr.addData(i, obj);
            }
        }

        for (int restartCnt = 0; restartCnt < 5; ++restartCnt) {
            stopGrid(1, true);

            info("Restart #" + restartCnt);
            U.sleep(500);

            ignite = startGrid(1);

            ignite.active(true);

            ThreadLocalRandom locRandom = ThreadLocalRandom.current();

            IgniteCache<Integer, IndexedObject> cache = ignite.getOrCreateCache(dynCacheCfg);

            for (int i = 0; i < LARGE_KEYS_COUNT; ++i) {
                IndexedObject val = cache.get(locRandom.nextInt(LARGE_KEYS_COUNT));

                assertNotNull(val);

                assertEquals(PAGE_SIZE + 2, val.payload.length);
            }
        }
    }
    finally {
        stopAllGrids();
    }
}
 
Example 19
Source File: IgniteWalRecoverySeveralRestartsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception if failed.
 */
@Test
public void testWalRecoveryWithDynamicCache() throws Exception {
    try {
        IgniteEx ignite = startGrid(1);

        ignite.active(true);

        CacheConfiguration<Integer, IndexedObject> dynCacheCfg = new CacheConfiguration<>();

        dynCacheCfg.setName("dyncache");
        dynCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        dynCacheCfg.setRebalanceMode(CacheRebalanceMode.NONE);
        dynCacheCfg.setIndexedTypes(Integer.class, IndexedObject.class);
        dynCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        dynCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
        dynCacheCfg.setReadFromBackup(true);

        ignite.getOrCreateCache(dynCacheCfg);

        try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer("dyncache")) {
            for (int i = 0; i < KEYS_COUNT; ++i) {
                if (i % (KEYS_COUNT / 100) == 0)
                    info("Loading " + i * 100 / KEYS_COUNT + "%");

                dataLdr.addData(i, new IndexedObject(i));
            }
        }

        for (int restartCnt = 0; restartCnt < 5; ++restartCnt) {
            stopGrid(1, true);

            info("Restart #" + restartCnt);
            U.sleep(500);

            ignite = startGrid(1);

            ignite.active(true);

            ThreadLocalRandom locRandom = ThreadLocalRandom.current();

            IgniteCache<Integer, IndexedObject> cache = ignite.getOrCreateCache(dynCacheCfg);

            for (int i = 0; i < KEYS_COUNT; ++i)
                assertNotNull(cache.get(locRandom.nextInt(KEYS_COUNT)));
        }
    }
    finally {
        stopAllGrids();
    }
}