use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientWriteBehindFlushTest method newMapStoredConfig.
protected Config newMapStoredConfig(MapStore store, int writeDelaySeconds) {
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setWriteDelaySeconds(writeDelaySeconds);
mapStoreConfig.setImplementation(store);
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(MAP_NAME);
mapConfig.setMapStoreConfig(mapStoreConfig);
return config;
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapLoadAllTest 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 MapLoaderTest.DummyMapLoader(keysInMapStore));
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapConfig.setMapStoreConfig(mapStoreConfig);
hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
IMap<Integer, Integer> map = client.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.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapStoreTest method mapStore_OperationQueue_AtMaxCapacity.
@Test
public void mapStore_OperationQueue_AtMaxCapacity() {
int maxCapacity = 1000;
Config config = new Config();
config.setProperty(GroupProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY.getName(), String.valueOf(maxCapacity));
MapConfig mapConfig = new MapConfig();
MapStoreConfig mapStoreConfig = new MapStoreConfig();
MapStoreBackup store = new MapStoreBackup();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(store);
mapStoreConfig.setWriteDelaySeconds(60);
mapStoreConfig.setWriteCoalescing(false);
mapConfig.setName(MAP_NAME);
mapConfig.setMapStoreConfig(mapStoreConfig);
config.addMapConfig(mapConfig);
HazelcastInstance server = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
IMap<Integer, Integer> map = client.getMap(MAP_NAME);
for (int i = 0; i < maxCapacity; i++) {
map.put(i, i);
}
assertEquals(maxCapacity, map.size());
try {
map.put(maxCapacity, maxCapacity);
fail("Should not exceed max capacity");
} catch (ReachedMaxSizeException expected) {
ignore(expected);
}
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapStoreTest method setup.
@Before
public void setup() {
nodeConfig = new Config();
MapConfig mapConfig = new MapConfig();
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(new SimpleMapStore());
mapStoreConfig.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER);
mapConfig.setName(MAP_NAME);
mapConfig.setMapStoreConfig(mapStoreConfig);
nodeConfig.addMapConfig(mapConfig);
}
use of com.hazelcast.config.MapStoreConfig in project hazelcast by hazelcast.
the class ClientMapTest method setup.
@Before
public void setup() {
Config config = getConfig();
config.getMapConfig("flushMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(flushMapStore));
config.getMapConfig("putTransientMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(transientMapStore));
server = hazelcastFactory.newHazelcastInstance(config);
ClientConfig clientConfig = new ClientConfig();
clientConfig.getSerializationConfig().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortable();
}
});
client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Aggregations