use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapLoaderTest method testMapCanBeLoaded_whenLoadAllKeysThrowsExceptionFirstTime.
@Test(timeout = MINUTE)
public void testMapCanBeLoaded_whenLoadAllKeysThrowsExceptionFirstTime() throws InterruptedException {
Config config = getConfig();
MapLoader failingMapLoader = new FailingMapLoader();
MapStoreConfig mapStoreConfig = new MapStoreConfig().setImplementation(failingMapLoader);
MapConfig mapConfig = config.getMapConfig(getClass().getName()).setMapStoreConfig(mapStoreConfig);
HazelcastInstance[] hz = createHazelcastInstanceFactory(2).newInstances(config, 2);
IMap map = hz[0].getMap(mapConfig.getName());
Throwable exception = null;
try {
map.get(generateKeyNotOwnedBy(hz[0]));
} catch (Throwable e) {
exception = e;
}
assertNotNull("Exception wasn't propagated", exception);
map.loadAll(true);
assertEquals(1, map.size());
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapLoaderTest method givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore.
@Test
public void givenSpecificKeysWereReloaded_whenLoadAllIsCalled_thenAllEntriesAreLoadedFromTheStore() {
String name = randomString();
int keysInMapStore = 10000;
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(name);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(new DummyMapLoader(keysInMapStore));
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapConfig.setMapStoreConfig(mapStoreConfig);
TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(2);
HazelcastInstance[] instances = instanceFactory.newInstances(config);
IMap<Integer, Integer> map = instances[0].getMap(name);
//load specific keys
map.loadAll(setOfValuesBetween(0, keysInMapStore), true);
//remove everything
map.clear();
//assert loadAll with load all entries provided by the mapLoader
map.loadAll(true);
assertEquals(keysInMapStore, map.size());
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapStoreEvictionTest method newConfig.
private Config newConfig(String mapName, boolean sizeLimited, MapStoreConfig.InitialLoadMode loadMode) {
Config cfg = new Config();
cfg.setGroupConfig(new GroupConfig(getClass().getSimpleName()));
cfg.setProperty("hazelcast.partition.count", "5");
MapStoreConfig mapStoreConfig = new MapStoreConfig().setImplementation(loader).setInitialLoadMode(loadMode);
MapConfig mapConfig = cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
if (sizeLimited) {
MaxSizeConfig maxSizeConfig = new MaxSizeConfig(MAX_SIZE_PER_NODE, MaxSizeConfig.MaxSizePolicy.PER_NODE);
mapConfig.setMaxSizeConfig(maxSizeConfig);
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
mapConfig.setMinEvictionCheckMillis(0);
}
return cfg;
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapStoreTest method testIssue1070.
// bug: store is called twice on loadAll
@Test(timeout = 120000)
public void testIssue1070() {
final String mapName = randomMapName();
final Config config = getConfig();
final MapConfig mapConfig = config.getMapConfig(mapName);
final MapStoreConfig mapStoreConfig = new MapStoreConfig();
final NoDuplicateMapStore myMapStore = new NoDuplicateMapStore();
final MapStoreConfig implementation = mapStoreConfig.setImplementation(myMapStore);
mapConfig.setMapStoreConfig(implementation);
myMapStore.store.put(1, 2);
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
nodeFactory.newHazelcastInstance(config);
IMap<Object, Object> map = instance.getMap(mapName);
for (int i = 0; i < 271; i++) {
map.get(i);
}
assertFalse(myMapStore.failed);
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapStoreTest method createChunkedMapLoaderConfig.
private Config createChunkedMapLoaderConfig(String mapName, int chunkSize, ChunkedLoader chunkedLoader) {
Config cfg = getConfig();
cfg.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
cfg.setProperty(GroupProperty.MAP_LOAD_CHUNK_SIZE.getName(), String.valueOf(chunkSize));
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(chunkedLoader);
MapConfig mapConfig = cfg.getMapConfig(mapName);
mapConfig.setMapStoreConfig(mapStoreConfig);
return cfg;
}
Aggregations