Search in sources :

Example 16 with QueryCacheConfig

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

Example 17 with QueryCacheConfig

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

Example 18 with QueryCacheConfig

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

Example 19 with QueryCacheConfig

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

Example 20 with QueryCacheConfig

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());
        }
    });
}
Also used : QueryCache(com.hazelcast.map.QueryCache) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) SqlPredicate(com.hazelcast.query.SqlPredicate) EventLostListener(com.hazelcast.map.listener.EventLostListener) HazelcastInstance(com.hazelcast.core.HazelcastInstance) EventLostEvent(com.hazelcast.map.EventLostEvent) AssertTask(com.hazelcast.test.AssertTask) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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