Search in sources :

Example 21 with MapStoreConfig

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

the class MapStoreTest method issue614.

@Test(timeout = 120000)
public void issue614() {
    final ConcurrentMap<Long, String> STORE = new ConcurrentHashMap<Long, String>();
    STORE.put(1L, "Event1");
    STORE.put(2L, "Event2");
    STORE.put(3L, "Event3");
    STORE.put(4L, "Event4");
    STORE.put(5L, "Event5");
    STORE.put(6L, "Event6");
    Config config = getConfig();
    config.getMapConfig("map").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1).setImplementation(new SimpleMapStore<Long, String>(STORE)));
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    IMap map = instance.getMap("map");
    map.values();
    LocalMapStats localMapStats = map.getLocalMapStats();
    assertEquals(0, localMapStats.getDirtyEntryCount());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) AtomicLong(java.util.concurrent.atomic.AtomicLong) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 22 with MapStoreConfig

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

the class MapStoreTest method testMapInitialLoad.

@Test(timeout = 240000)
public void testMapInitialLoad() throws InterruptedException {
    int size = 10000;
    String mapName = randomMapName();
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);
    Config config = getConfig();
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(new SimpleMapLoader(size, true));
    MapConfig mc = config.getMapConfig(mapName);
    mc.setMapStoreConfig(mapStoreConfig);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    nodeFactory.newHazelcastInstance(config);
    IMap<Integer, Integer> map = instance.getMap(mapName);
    // trigger initial loads by touching partitions.
    for (int i = 0; i < size; i++) {
        assertEquals(i, map.get(i).intValue());
    }
    assertSizeEventually(size, map);
    for (int i = 0; i < size; i++) {
        assertEquals(i, map.get(i).intValue());
    }
    assertNull(map.put(size, size));
    assertEquals(size, map.remove(size).intValue());
    assertNull(map.get(size));
    nodeFactory.newHazelcastInstance(config);
    for (int i = 0; i < size; i++) {
        assertEquals(i, map.get(i).intValue());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 23 with MapStoreConfig

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

the class MapStoreTest method testMapStoreNotCalledFromEntryProcessorBackup.

@Test(timeout = 120000)
public void testMapStoreNotCalledFromEntryProcessorBackup() throws Exception {
    final String mapName = "testMapStoreNotCalledFromEntryProcessorBackup_" + randomString();
    final int instanceCount = 2;
    Config config = getConfig();
    // configure map with one backup and dummy map store
    MapConfig mapConfig = config.getMapConfig(mapName);
    mapConfig.setBackupCount(1);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    MapStoreWithStoreCount mapStore = new MapStoreWithStoreCount(1, 120);
    mapStoreConfig.setImplementation(mapStore);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(instanceCount);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    nodeFactory.newHazelcastInstance(config);
    final IMap<String, String> map = instance.getMap(mapName);
    final String key = "key";
    final String value = "value";
    //executeOnKey
    map.executeOnKey(key, new ValueSetterEntryProcessor(value));
    mapStore.awaitStores();
    assertEquals(value, map.get(key));
    assertEquals(1, mapStore.getCount());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MapConfig(com.hazelcast.config.MapConfig) 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 24 with MapStoreConfig

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

the class MapStoreTest method testMapstoreDeleteOnClear.

/*
     * Test for Issue 572
    */
@Test(timeout = 120000)
public void testMapstoreDeleteOnClear() throws Exception {
    Config config = getConfig();
    SimpleMapStore store = new SimpleMapStore();
    config.getMapConfig("testMapstoreDeleteOnClear").setMapStoreConfig(new MapStoreConfig().setEnabled(true).setImplementation(store));
    HazelcastInstance hz = createHazelcastInstance(config);
    IMap<Object, Object> map = hz.getMap("testMapstoreDeleteOnClear");
    int size = 10;
    for (int i = 0; i < size; i++) {
        map.put(i, i);
    }
    assertEquals(size, map.size());
    assertEquals(size, store.store.size());
    assertEquals(size, store.loadAllKeys().size());
    map.clear();
    assertEquals(0, map.size());
    assertEquals(0, store.loadAllKeys().size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 25 with MapStoreConfig

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

the class PostProcessingMapStoreTest method createInstanceAndGetMap.

private IMap<Integer, SampleObject> createInstanceAndGetMap() {
    String name = randomString();
    Config config = new Config();
    MapConfig mapConfig = config.getMapConfig(name);
    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true).setClassName(IncrementerPostProcessingMapStore.class.getName());
    mapConfig.setMapStoreConfig(mapStoreConfig);
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    warmUpPartitions(instance);
    return instance.getMap(name);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) 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