use of com.hazelcast.map.MapStoreAdapter in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testMapDestroy_succeeds_when_writeBehind_and_nearCache_enabled.
@Test
public void testMapDestroy_succeeds_when_writeBehind_and_nearCache_enabled() {
Config config = newConfig();
config.getMapConfig("default").getMapStoreConfig().setEnabled(true).setWriteDelaySeconds(1).setImplementation(new MapStoreAdapter());
IMap<Integer, Integer> map = getNearCachedMapFromClient(config, newInvalidationEnabledNearCacheConfig());
populateMap(map, 10);
populateNearCache(map, 10);
map.destroy();
}
use of com.hazelcast.map.MapStoreAdapter in project hazelcast by hazelcast.
the class TransactionsWithWriteBehind_whenNoCoalescingQueueIsFullTest method getConfig.
private Config getConfig(String mapName, long maxWbqCapacity) {
Config config = smallInstanceConfig();
config.setProperty(ClusterProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY.toString(), String.valueOf(maxWbqCapacity));
config.getMapConfig(mapName).setBackupCount(1).setAsyncBackupCount(0).getMapStoreConfig().setEnabled(true).setImplementation(new MapStoreAdapter()).setWriteCoalescing(false).setWriteDelaySeconds(6);
return config;
}
use of com.hazelcast.map.MapStoreAdapter 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.map.MapStoreAdapter in project hazelcast by hazelcast.
the class MapTransactionTest method testGetForUpdate_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb.
@Test
public void testGetForUpdate_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb() {
final String mapName = randomMapName();
final MapStoreAdapter mock = mock(MapStoreAdapter.class);
when(mock.load(anyObject())).thenReturn(null);
Config config = new Config();
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.getForUpdate(1);
assertNull("value should be null", value);
verify(mock, times(1)).load(anyObject());
return null;
}
});
}
Aggregations