use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheSimpleStressTest method setUp.
@Before
public void setUp() {
EvictionConfig evictionConfig = new EvictionConfig();
evictionConfig.setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT);
evictionConfig.setSize(Integer.MAX_VALUE);
evictionConfig.setEvictionPolicy(EvictionPolicy.LRU);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
queryCacheConfig.setBufferSize(30).setDelaySeconds(2).setBatchSize(2).setPopulate(true).getPredicateConfig().setImplementation(TruePredicate.INSTANCE);
queryCacheConfig.setEvictionConfig(evictionConfig);
MapConfig mapConfig = new MapConfig(mapName);
mapConfig.addQueryCacheConfig(queryCacheConfig);
config.addMapConfig(mapConfig);
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheTest method initConfig.
private void initConfig(String mapName, String cacheName, boolean enableInitialPopulation) {
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
queryCacheConfig.setPopulate(enableInitialPopulation).getPredicateConfig().setImplementation(TRUE_PREDICATE);
MapConfig mapConfig = new MapConfig(mapName).addQueryCacheConfig(queryCacheConfig);
config.addMapConfig(mapConfig);
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class EvictionTest method getConfig.
private Config getConfig(int maxSize, String mapName, String cacheName) {
QueryCacheConfig cacheConfig = new QueryCacheConfig(cacheName);
cacheConfig.getEvictionConfig().setSize(maxSize).setEvictionPolicy(EvictionPolicy.LFU).setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT);
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.addQueryCacheConfig(cacheConfig);
return config;
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheMapLoaderTest method getConfig.
private Config getConfig(String mapName, String cacheName) {
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.getMapStoreConfig().setEnabled(true).setImplementation(new TestMapLoader());
QueryCacheConfig cacheConfig = new QueryCacheConfig(cacheName);
mapConfig.addQueryCacheConfig(cacheConfig);
return config;
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientQueryCacheRecoveryUponEventLossTest method testForceConsistency.
@Test
public void testForceConsistency() {
String mapName = randomMapName("map");
String queryCacheName = randomMapName("cache");
Config config = new Config();
config.setProperty(PARTITION_COUNT.getName(), "1");
factory.newHazelcastInstance(config);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(queryCacheName);
queryCacheConfig.setBatchSize(1111);
queryCacheConfig.setDelaySeconds(3);
ClientConfig clientConfig = new ClientConfig();
clientConfig.addQueryCacheConfig(mapName, queryCacheConfig);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
IMap<Integer, Integer> map = client.getMap(mapName);
// set test sequencer to subscriber
int count = 30;
setTestSequencer(map, 9);
final QueryCache queryCache = map.getQueryCache(queryCacheName, new SqlPredicate("this > 20"), true);
queryCache.addEntryListener(new EventLostListener() {
@Override
public void eventLost(EventLostEvent event) {
queryCache.tryRecover();
}
}, false);
for (int i = 0; i < count; i++) {
map.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(9, queryCache.size());
}
});
}
Aggregations