Search in sources :

Example 66 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class WriteBehindFlushTest method testWriteBehindQueues_emptied_onBackupNodes.

@Test
public void testWriteBehindQueues_emptied_onBackupNodes() throws Exception {
    int nodeCount = 3;
    String mapName = randomName();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
    mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
    Config config = getConfig();
    config.setProperty(GroupProperty.MAP_REPLICA_SCHEDULED_TASK_DELAY_SECONDS.getName(), "0");
    config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
    HazelcastInstance member1 = factory.newHazelcastInstance(config);
    HazelcastInstance member2 = factory.newHazelcastInstance(config);
    HazelcastInstance member3 = factory.newHazelcastInstance(config);
    IMap<Integer, Integer> map = member1.getMap(mapName);
    for (int i = 0; i < 1000; i++) {
        map.put(i, i);
    }
    map.flush();
    assertWriteBehindQueuesEmpty(mapName, asList(member1, member2, member3));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 67 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class WriteBehindFlushTest method newMapStoredConfig.

private Config newMapStoredConfig(MapStore store, int writeDelaySeconds) {
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setWriteDelaySeconds(writeDelaySeconds);
    mapStoreConfig.setImplementation(store);
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig("default");
    mapConfig.setMapStoreConfig(mapStoreConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 68 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class MapStoreWriteBehindTest method testIssue1085WriteBehindBackup.

@Test(timeout = 120000)
public void testIssue1085WriteBehindBackup() throws InterruptedException {
    Config config = getConfig();
    String name = "testIssue1085WriteBehindBackup";
    MapConfig writeBehindBackup = config.getMapConfig(name);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setWriteDelaySeconds(5);
    int size = 1000;
    MapStoreWithStoreCount mapStore = new MapStoreWithStoreCount(size, 120);
    mapStoreConfig.setImplementation(mapStore);
    writeBehindBackup.setMapStoreConfig(mapStoreConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    final IMap<Integer, Integer> map = instance.getMap(name);
    for (int i = 0; i < size; i++) {
        map.put(i, i);
    }
    instance2.getLifecycleService().shutdown();
    mapStore.awaitStores();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) MapStoreWithStoreCount(com.hazelcast.map.impl.mapstore.MapStoreTest.MapStoreWithStoreCount) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 69 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class MapStoreWriteBehindTest method mapStore_setOnIMapDoesNotRemoveKeyFromWriteBehindDeleteQueue.

@Test(timeout = 120000)
public void mapStore_setOnIMapDoesNotRemoveKeyFromWriteBehindDeleteQueue() throws Exception {
    MapStoreConfig mapStoreConfig = new MapStoreConfig().setEnabled(true).setImplementation(new SimpleMapStore<String, String>()).setWriteDelaySeconds(Integer.MAX_VALUE);
    Config config = getConfig();
    config.getMapConfig("map").setMapStoreConfig(mapStoreConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    IMap<String, String> map = instance.getMap("map");
    map.put("foo", "bar");
    map.remove("foo");
    map.set("foo", "bar");
    assertEquals("bar", map.get("foo"));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) SimpleMapStore(com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 70 with MapStoreConfig

use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.

the class NearCacheLiteMemberTest method createNearCachedMapConfigWithMapStoreConfig.

public static Config createNearCachedMapConfigWithMapStoreConfig(String mapName, boolean liteMember) {
    NearCacheTestSupport.SimpleMapStore store = new NearCacheTestSupport.SimpleMapStore();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(store);
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInvalidateOnChange(true);
    Config config = new Config();
    config.setLiteMember(liteMember);
    config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig).setNearCacheConfig(nearCacheConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig)

Aggregations

MapStoreConfig (com.hazelcast.config.MapStoreConfig)76 Config (com.hazelcast.config.Config)70 MapConfig (com.hazelcast.config.MapConfig)61 HazelcastInstance (com.hazelcast.core.HazelcastInstance)51 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)43 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 GroupConfig (com.hazelcast.config.GroupConfig)21 IMap (com.hazelcast.core.IMap)12 AssertTask (com.hazelcast.test.AssertTask)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MapIndexConfig (com.hazelcast.config.MapIndexConfig)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)9 NightlyTest (com.hazelcast.test.annotation.NightlyTest)8 HashSet (java.util.HashSet)8 NearCacheConfig (com.hazelcast.config.NearCacheConfig)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 MapStoreAdapter (com.hazelcast.core.MapStoreAdapter)5