use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientQueryCacheSimpleStressTest method setQueryCacheConfig.
private void setQueryCacheConfig() {
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
queryCacheConfig.setBufferSize(30).setDelaySeconds(2).setBatchSize(2).setPopulate(true).getPredicateConfig().setImplementation(TruePredicate.INSTANCE);
config.addQueryCacheConfig(mapName, queryCacheConfig);
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientQueryCacheTest method addConfig.
private ClientConfig addConfig(QueryCacheConfig queryCacheConfig, String mapName) {
ClientConfig clientConfig = new ClientConfig();
Map<String, Map<String, QueryCacheConfig>> queryCacheConfigs = clientConfig.getQueryCacheConfigs();
Map<String, QueryCacheConfig> queryCacheConfigMap = queryCacheConfigs.get(mapName);
if (queryCacheConfigMap == null) {
queryCacheConfigMap = new HashMap<String, QueryCacheConfig>();
queryCacheConfigs.put(mapName, queryCacheConfigMap);
}
queryCacheConfigMap.put(queryCacheConfig.getName(), queryCacheConfig);
return clientConfig;
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientQueryCacheConfigurator method getOrCreateConfiguration.
@Override
public QueryCacheConfig getOrCreateConfiguration(String mapName, String cacheName) {
Map<String, Map<String, QueryCacheConfig>> allQueryCacheConfig = clientConfig.getQueryCacheConfigs();
Map<String, QueryCacheConfig> mapQueryCacheConfig = allQueryCacheConfig.get(mapName);
if (mapQueryCacheConfig == null) {
mapQueryCacheConfig = new HashMap<String, QueryCacheConfig>();
allQueryCacheConfig.put(mapName, mapQueryCacheConfig);
}
QueryCacheConfig config = mapQueryCacheConfig.get(cacheName);
if (config == null) {
config = new QueryCacheConfig(cacheName);
mapQueryCacheConfig.put(cacheName, config);
}
setPredicateImpl(config);
setEntryListener(mapName, cacheName, config);
return config;
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class QueryCacheConfigBuilderHelper method handleQueryCache.
void handleQueryCache(ClientConfig clientConfig, Node node) {
for (Node queryCacheNode : childElements(node)) {
if ("query-cache".equals(cleanNodeName(queryCacheNode))) {
NamedNodeMap attrs = queryCacheNode.getAttributes();
String cacheName = getTextContent(attrs.getNamedItem("name"));
String mapName = getTextContent(attrs.getNamedItem("mapName"));
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
for (Node childNode : childElements(queryCacheNode)) {
String textContent = getTextContent(childNode);
String nodeName = cleanNodeName(childNode);
populateQueryCacheConfig(queryCacheConfig, childNode, textContent, nodeName);
}
clientConfig.addQueryCacheConfig(mapName, queryCacheConfig);
}
}
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientQueryCacheBasicTest method setup.
// setup a map with 2 query caches, same predicate, one includes values, the other excludes values
@Before
public void setup() {
Config config = new Config();
ClientConfig clientConfig = new ClientConfig();
clientConfig.addQueryCacheConfig(TEST_MAP_NAME, new QueryCacheConfig(QUERY_CACHE_NAME).setPredicateConfig(new PredicateConfig(predicate)).setIncludeValue(includeValues));
if (useNearCache) {
clientConfig.addNearCacheConfig(new NearCacheConfig().setName(TEST_MAP_NAME).setInvalidateOnChange(true));
}
clientConfig.setProperty(MapEventPublisherImpl.LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES.getName(), Boolean.toString(useQueryCacheNaturalFilteringStrategy));
factory = new TestHazelcastFactory();
factory.newHazelcastInstance(config);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
map = client.getMap(TEST_MAP_NAME);
queryCache = map.getQueryCache(QUERY_CACHE_NAME);
}
Aggregations