Search in sources :

Example 1 with SimpleMapStore

use of com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore in project hazelcast by hazelcast.

the class MapStoreWriteBehindTest method testWriteBehindDestroy.

@Test(timeout = 120000)
@Category(NightlyTest.class)
public // issue #2747: when MapStore configured with write behind, distributed objects' destroy method does not work
void testWriteBehindDestroy() throws InterruptedException {
    final int writeDelaySeconds = 5;
    String mapName = randomMapName();
    final MapStore<String, String> store = new SimpleMapStore<String, String>();
    Config config = newConfig(mapName, store, writeDelaySeconds);
    HazelcastInstance hzInstance = createHazelcastInstance(config);
    IMap<String, String> map = hzInstance.getMap(mapName);
    map.put("key", "value");
    map.destroy();
    sleepSeconds(2 * writeDelaySeconds);
    assertNotEquals("value", store.load("key"));
}
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) Category(org.junit.experimental.categories.Category) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with SimpleMapStore

use of com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore in project hazelcast by hazelcast.

the class MapStoreWriteBehindTest method mapStore_setOnIMapDoesNotRemoveKeyFromWriteBehindDeleteQueue.

@Test(timeout = 120000)
public void mapStore_setOnIMapDoesNotRemoveKeyFromWriteBehindDeleteQueue() {
    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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) AbstractMapStoreTest(com.hazelcast.map.impl.mapstore.AbstractMapStoreTest) Test(org.junit.Test)

Example 3 with SimpleMapStore

use of com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore 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 4 with SimpleMapStore

use of com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore in project hazelcast by hazelcast.

the class MapStoreWriteBehindTest method testWriteBehindDestroy.

@Test(timeout = 120000)
@Category(NightlyTest.class)
public // issue #2747: when MapStore configured with write behind, distributed objects' destroy method does not work
void testWriteBehindDestroy() {
    final int writeDelaySeconds = 5;
    String mapName = randomMapName();
    final MapStore<String, String> store = new SimpleMapStore<String, String>();
    Config config = newConfig(mapName, store, writeDelaySeconds);
    HazelcastInstance hzInstance = createHazelcastInstance(config);
    IMap<String, String> map = hzInstance.getMap(mapName);
    map.put("key", "value");
    map.destroy();
    sleepSeconds(2 * writeDelaySeconds);
    assertNotEquals("value", store.load("key"));
}
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) Category(org.junit.experimental.categories.Category) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) AbstractMapStoreTest(com.hazelcast.map.impl.mapstore.AbstractMapStoreTest) Test(org.junit.Test)

Aggregations

Config (com.hazelcast.config.Config)4 MapConfig (com.hazelcast.config.MapConfig)4 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 SimpleMapStore (com.hazelcast.map.impl.mapstore.MapStoreTest.SimpleMapStore)4 NightlyTest (com.hazelcast.test.annotation.NightlyTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 AbstractMapStoreTest (com.hazelcast.map.impl.mapstore.AbstractMapStoreTest)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 Category (org.junit.experimental.categories.Category)2