use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class MapStoreTest method testInitialLoadModeEager.
@Test(timeout = 120000)
public void testInitialLoadModeEager() {
int size = 10000;
String mapName = "default";
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
Config config = getConfig();
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(new SimpleMapLoader(size, true));
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
nodeFactory.newHazelcastInstance(config);
IMap map = instance.getMap(mapName);
assertSizeEventually(size, map);
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class MapLoaderMultiNodeTest method newConfig.
protected Config newConfig(String mapName, MapStoreConfig.InitialLoadMode loadMode, int backups, MapLoader loader) {
Config cfg = getConfig();
cfg.setGroupConfig(new GroupConfig(getClass().getSimpleName()));
cfg.setProperty(GroupProperty.MAP_LOAD_CHUNK_SIZE.getName(), Integer.toString(BATCH_SIZE));
cfg.setProperty(GroupProperty.PARTITION_COUNT.getName(), "31");
MapStoreConfig mapStoreConfig = new MapStoreConfig().setImplementation(loader).setInitialLoadMode(loadMode);
cfg.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig).setBackupCount(backups);
return cfg;
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class MapTransactionTest method testGet_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb.
@Test
public void testGet_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb() {
final String mapName = randomMapName();
final MapStoreAdapter mock = mock(MapStoreAdapter.class);
when(mock.load(anyObject())).thenReturn(null);
Config config = getConfig();
MapStoreConfig storeConfig = new MapStoreConfig();
storeConfig.setEnabled(true).setImplementation(mock);
config.getMapConfig(mapName).setMapStoreConfig(storeConfig);
HazelcastInstance instance = createHazelcastInstance(config);
instance.executeTransaction(new TransactionalTask<Object>() {
@Override
public Object execute(TransactionalTaskContext context) throws TransactionException {
TransactionalMap<Object, Object> map = context.getMap(mapName);
Object value = map.get(1);
assertNull("value should be null", value);
verify(mock, times(1)).load(anyObject());
return null;
}
});
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testAfterLoadAllNearCacheIsInvalidated.
@Test
public void testAfterLoadAllNearCacheIsInvalidated() {
int mapSize = 1000;
String mapName = randomMapName();
HazelcastInstance server = hazelcastFactory.newHazelcastInstance(newConfig());
HazelcastInstance client = getClient(hazelcastFactory, newInvalidationOnChangeEnabledNearCacheConfig(mapName));
Config config = server.getConfig();
SimpleMapStore store = new SimpleMapStore();
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(store);
config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
final IMap<Integer, Integer> clientMap = client.getMap(mapName);
populateMap(clientMap, mapSize);
populateNearCache(clientMap, mapSize);
clientMap.loadAll(true);
assertTrueEventually(new AssertTask() {
public void run() {
assertThatOwnedEntryCountEquals(clientMap, 0);
}
});
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testAfterLoadAllWithDefinedKeysNearCacheIsInvalidated.
@Test
public void testAfterLoadAllWithDefinedKeysNearCacheIsInvalidated() {
int mapSize = 1000;
String mapName = randomMapName();
HazelcastInstance server = hazelcastFactory.newHazelcastInstance(newConfig());
HazelcastInstance client = getClient(hazelcastFactory, newInvalidationOnChangeEnabledNearCacheConfig(mapName));
Config config = server.getConfig();
SimpleMapStore store = new SimpleMapStore();
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(store);
config.getMapConfig(mapName).setMapStoreConfig(mapStoreConfig);
final IMap<Integer, Integer> clientMap = client.getMap(mapName);
HashSet<Integer> keys = new HashSet<Integer>();
for (int i = 0; i < mapSize; i++) {
clientMap.put(i, i);
keys.add(i);
}
for (int i = 0; i < mapSize; i++) {
clientMap.get(i);
}
clientMap.loadAll(keys, false);
assertTrueEventually(new AssertTask() {
public void run() {
assertThatOwnedEntryCountEquals(clientMap, 0);
}
});
}
Aggregations