use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheListenerTest method published_event_contains_key_when_include_value_is_false.
@Test
public void published_event_contains_key_when_include_value_is_false() {
CountDownLatch waitEventLatch = new CountDownLatch(1);
AtomicReference<EntryEvent<Integer, Employee>> eventObject = new AtomicReference<>();
MapConfig mapConfig = new MapConfig(mapName);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName).setPredicateConfig(new PredicateConfig(TRUE_PREDICATE)).addEntryListenerConfig(new EntryListenerConfig((EntryAddedListener<Integer, Employee>) event -> {
eventObject.set(event);
waitEventLatch.countDown();
}, true, false));
mapConfig.addQueryCacheConfig(queryCacheConfig);
Config config = new Config();
config.addMapConfig(mapConfig);
IMap<Integer, Employee> map = getIMap(config);
// trigger creation of the query cache
map.getQueryCache(cacheName);
map.put(1, new Employee(1));
assertOpenEventually(waitEventLatch);
assertEquals(1, eventObject.get().getKey().intValue());
}
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 = getConfig();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.setInMemoryFormat(inMemoryFormat);
mapConfig.getMapStoreConfig().setEnabled(true).setImplementation(mapLoader);
QueryCacheConfig cacheConfig = new QueryCacheConfig(cacheName);
mapConfig.addQueryCacheConfig(cacheConfig);
return config;
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheNoEventLossTest method newConfig.
private Config newConfig() {
QueryCacheConfig queryCacheConfig = new QueryCacheConfig().setName(QUERY_CACHE_NAME).setPredicateConfig(new PredicateConfig(Predicates.alwaysTrue()));
MapConfig mapConfig = new MapConfig(MAP_NAME).addQueryCacheConfig(queryCacheConfig);
return smallInstanceConfig().addMapConfig(mapConfig);
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCachePredicateConfigTest method test_whenSqlIsSet.
@Test
public void test_whenSqlIsSet() {
String mapName = randomString();
String cacheName = randomString();
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
QueryCacheConfig cacheConfig = new QueryCacheConfig(cacheName);
PredicateConfig predicateConfig = cacheConfig.getPredicateConfig();
predicateConfig.setSql("id > 10");
mapConfig.addQueryCacheConfig(cacheConfig);
HazelcastInstance node = createHazelcastInstance(config);
IMap<Integer, Employee> map = getMap(node, mapName);
for (int i = 0; i < 15; i++) {
map.put(i, new Employee(i));
}
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName);
assertEquals(4, cache.size());
}
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.setMaxSizePolicy(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(Predicates.alwaysTrue());
queryCacheConfig.setEvictionConfig(evictionConfig);
MapConfig mapConfig = new MapConfig(mapName);
mapConfig.addQueryCacheConfig(queryCacheConfig);
config.addMapConfig(mapConfig);
}
Aggregations