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());
}
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());
}
}
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());
}
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());
}
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);
}
Aggregations