use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class RecordStoreTest method testRecordStoreReset.
private IMap<Object, Object> testRecordStoreReset() {
String mapName = randomName();
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
MapIndexConfig indexConfig = new MapIndexConfig("name", false);
mapConfig.addMapIndexConfig(indexConfig);
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
int key = 1;
map.put(key, new SampleObjects.Employee("tom", 24, true, 10));
DefaultRecordStore defaultRecordStore = getRecordStore(map, key);
defaultRecordStore.reset();
assertNull(map.get(key));
return map;
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class StoreLatencyPlugin_MapIntegrationTest method addMapConfig.
private static MapConfig addMapConfig(Config config) {
MapConfig mapConfig = config.getMapConfig("mappy");
mapConfig.getMapStoreConfig().setEnabled(true).setImplementation(new MapStore() {
private final Random random = new Random();
@Override
public void store(Object key, Object value) {
}
@Override
public Object load(Object key) {
randomSleep();
return null;
}
private void randomSleep() {
long delay = random.nextInt(100);
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Map loadAll(Collection keys) {
return null;
}
@Override
public void storeAll(Map map) {
}
@Override
public void delete(Object key) {
}
@Override
public Iterable loadAllKeys() {
return null;
}
@Override
public void deleteAll(Collection keys) {
}
});
return mapConfig;
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MigrationTest method testMigration_whenRemovingInstances_withStatisticsDisabled.
@Test
public void testMigration_whenRemovingInstances_withStatisticsDisabled() {
int size = 100;
String name = randomString();
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(name);
mapConfig.setStatisticsEnabled(false);
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);
HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config);
HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config);
HazelcastInstance instance3 = nodeFactory.newHazelcastInstance(config);
IMap<Integer, Integer> map = instance1.getMap(name);
for (int i = 0; i < size; i++) {
map.put(i, i);
}
instance2.shutdown();
instance3.shutdown();
waitAllForSafeState(instance1);
assertEquals("Some records have been lost.", size, map.values().size());
for (int i = 0; i < size; i++) {
assertEquals(i, map.get(i).intValue());
}
assertThatMigrationIsDoneAndReplicasAreIntact(singletonList(instance1));
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class AbstractMapStoreTest method newConfig.
public Config newConfig(String mapName, Object storeImpl, int writeDelaySeconds, MapStoreConfig.InitialLoadMode loadMode) {
Config config = getConfig();
config.getManagementCenterConfig().setEnabled(false);
MapConfig mapConfig = config.getMapConfig(mapName);
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setImplementation(storeImpl);
mapStoreConfig.setWriteDelaySeconds(writeDelaySeconds);
mapStoreConfig.setInitialLoadMode(loadMode);
mapConfig.setMapStoreConfig(mapStoreConfig);
return config;
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapClassLoaderTest method testIssue2721.
// https://github.com/hazelcast/hazelcast/issues/2721
@Test
public void testIssue2721() throws InterruptedException {
final Config config = new Config();
// get map config
final MapConfig mapConfig = config.getMapConfig(MAP_NAME);
// create shared map store implementation
final InMemoryMapStore store = new InMemoryMapStore();
store.preload(PRE_LOAD_SIZE);
// create map store config
final MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapStoreConfig.setWriteDelaySeconds(WRITE_DELAY_SECONDS);
mapStoreConfig.setClassName(null);
mapStoreConfig.setImplementation(store);
mapConfig.setMapStoreConfig(mapStoreConfig);
final HazelcastInstance instance = createHazelcastInstance(config);
// Get map so map store is triggered
instance.getMap(MAP_NAME);
boolean anEmptyCtxClassLoaderExist = false;
// test if all load threads had a context class loader set
for (boolean hasCtxClassLoader : store.getContextClassLoaders().values()) {
if (!hasCtxClassLoader) {
anEmptyCtxClassLoaderExist = true;
break;
}
}
assertFalse(anEmptyCtxClassLoaderExist);
}
Aggregations