Search in sources :

Example 36 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 37 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 38 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 39 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 40 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)80 Config (com.hazelcast.config.Config)29 Test (org.junit.Test)29 QuickTest (com.hazelcast.test.annotation.QuickTest)28 MapConfig (com.hazelcast.config.MapConfig)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)21 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)20 PredicateConfig (com.hazelcast.config.PredicateConfig)17 ClientConfig (com.hazelcast.client.config.ClientConfig)15 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)14 AttributeConfig (com.hazelcast.config.AttributeConfig)8 Employee (com.hazelcast.map.impl.querycache.utils.Employee)8 Before (org.junit.Before)8 IndexConfig (com.hazelcast.config.IndexConfig)7 AssertTask (com.hazelcast.test.AssertTask)7 Map (java.util.Map)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 EvictionConfig (com.hazelcast.config.EvictionConfig)6 NearCacheConfig (com.hazelcast.config.NearCacheConfig)5 EventLostEvent (com.hazelcast.map.EventLostEvent)5