Search in sources :

Example 21 with QueryCacheConfig

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);
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig)

Example 22 with 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;
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap)

Example 23 with QueryCacheConfig

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;
}
Also used : QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) Map(java.util.Map) HashMap(java.util.HashMap)

Example 24 with QueryCacheConfig

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);
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) Node(org.w3c.dom.Node)

Example 25 with 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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Aggregations

QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)31 MapConfig (com.hazelcast.config.MapConfig)16 Config (com.hazelcast.config.Config)14 QuickTest (com.hazelcast.test.annotation.QuickTest)13 Test (org.junit.Test)13 HazelcastInstance (com.hazelcast.core.HazelcastInstance)12 ParallelTest (com.hazelcast.test.annotation.ParallelTest)10 ClientConfig (com.hazelcast.client.config.ClientConfig)6 SqlPredicate (com.hazelcast.query.SqlPredicate)6 PredicateConfig (com.hazelcast.config.PredicateConfig)5 AssertTask (com.hazelcast.test.AssertTask)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)3 EventLostEvent (com.hazelcast.map.EventLostEvent)3 QueryCache (com.hazelcast.map.QueryCache)3 EventLostListener (com.hazelcast.map.listener.EventLostListener)3 Employee (com.hazelcast.mapreduce.helpers.Employee)3 Before (org.junit.Before)3 EvictionConfig (com.hazelcast.config.EvictionConfig)2 NearCacheConfig (com.hazelcast.config.NearCacheConfig)2