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);
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class TestMapUsingMapStoreBuilder method build.
public IMap<K, V> build() {
if (backupCount != 0 && backupCount > nodeCount - 1) {
throw new IllegalArgumentException("backupCount > nodeCount - 1");
}
final MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(writeDelaySeconds).setWriteBatchSize(writeBatchSize).setWriteCoalescing(writeCoalescing);
final Config config = new Config();
config.getMapConfig(mapName).setBackupCount(backupCount).setMapStoreConfig(mapStoreConfig).setInMemoryFormat(inMemoryFormat);
if (writeBehindQueueCapacity > 0) {
config.setProperty(GroupProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY.getName(), String.valueOf(writeBehindQueueCapacity));
}
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), String.valueOf(partitionCount));
if (backupDelaySeconds > 0) {
config.setProperty(GroupProperty.MAP_REPLICA_SCHEDULED_TASK_DELAY_SECONDS.getName(), String.valueOf(backupDelaySeconds));
}
// nodes
nodes = new HazelcastInstance[nodeCount];
for (int i = 0; i < nodeCount; i++) {
nodes[i] = instanceFactory.newHazelcastInstance(config);
}
return nodes[0].getMap(mapName);
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class WriteBehindFlushTest method testWriteBehindQueues_flushed_onNodeShutdown.
@Test
public void testWriteBehindQueues_flushed_onNodeShutdown() throws Exception {
int nodeCount = 3;
String mapName = randomName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
Config config = getConfig();
config.getMapConfig(mapName).setBackupCount(0).setMapStoreConfig(mapStoreConfig);
HazelcastInstance member = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Integer, Integer> map = member.getMap(mapName);
for (int i = 0; i < 1000; i++) {
map.put(i, i);
}
factory.shutdownAll();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
for (int i = 0; i < 1000; i++) {
assertEquals(i, mapStore.store.get(i));
}
}
});
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class WriteBehindFlushTest method testWriteBehindQueues_flushed_uponEviction.
@Test
public void testWriteBehindQueues_flushed_uponEviction() throws Exception {
int nodeCount = 3;
String mapName = randomName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
final MapStoreWithCounter mapStore = new MapStoreWithCounter<Integer, String>();
mapStoreConfig.setImplementation(mapStore).setWriteDelaySeconds(3000);
Config config = getConfig();
config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
HazelcastInstance node3 = factory.newHazelcastInstance(config);
IMap<Integer, Integer> map = node1.getMap(mapName);
for (int i = 0; i < 1000; i++) {
map.put(i, i);
}
for (int i = 0; i < 1000; i++) {
map.evict(i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1000, mapStore.countStore.get());
}
});
assertWriteBehindQueuesEmpty(mapName, asList(node1, node2, node3));
}
Aggregations