use of com.hazelcast.core.MapLoader 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.core.MapLoader in project hazelcast by hazelcast.
the class MapLoaderTest method test1770.
// https://github.com/hazelcast/hazelcast/issues/1770
@Test
public void test1770() throws InterruptedException {
Config config = getConfig();
config.getManagementCenterConfig().setEnabled(true);
config.getManagementCenterConfig().setUrl("http://127.0.0.1:8090/mancenter");
MapConfig mapConfig = config.getMapConfig("foo");
final AtomicBoolean loadAllCalled = new AtomicBoolean();
MapLoader<Object, Object> mapLoader = new MapLoader<Object, Object>() {
@Override
public Object load(Object key) {
return null;
}
@Override
public Map<Object, Object> loadAll(Collection keys) {
loadAllCalled.set(true);
return new HashMap<Object, Object>();
}
@Override
public Set<Object> loadAllKeys() {
return new HashSet<Object>(Collections.singletonList(1));
}
};
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(mapLoader);
mapConfig.setMapStoreConfig(mapStoreConfig);
HazelcastInstance hz = createHazelcastInstance(config);
hz.getMap(mapConfig.getName());
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() {
assertFalse("LoadAll should not have been called", loadAllCalled.get());
}
}, 10);
}
Aggregations