use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method queryCache_withEntryEventListenerClass.
@Test
public void queryCache_withEntryEventListenerClass() {
String queryCacheName = randomString();
QueryCacheConfig expected = createQueryCacheConfig(queryCacheName).addEntryListenerConfig(new EntryListenerConfig().setIncludeValue(true).setLocal(true).setImplementation(new TestMapListener()));
String mapName = randomString();
clientConfig.addQueryCacheConfig(mapName, expected);
QueryCacheConfig actual = newConfigViaGenerator().getQueryCacheConfigs().get(mapName).get(queryCacheName);
ConfigCompatibilityChecker.checkQueryCacheConfig(expected, actual);
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class AbstractClientConfigBuilderTest method testQueryCacheFullConfig.
@Test
public void testQueryCacheFullConfig() throws Exception {
QueryCacheConfig queryCacheClassPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-class-name-predicate");
QueryCacheConfig queryCacheSqlPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-sql-predicate");
EntryListenerConfig entryListenerConfig = queryCacheClassPredicateConfig.getEntryListenerConfigs().get(0);
assertEquals("query-cache-class-name-predicate", queryCacheClassPredicateConfig.getName());
assertTrue(entryListenerConfig.isIncludeValue());
assertFalse(entryListenerConfig.isLocal());
assertEquals("com.hazelcast.examples.EntryListener", entryListenerConfig.getClassName());
assertTrue(queryCacheClassPredicateConfig.isIncludeValue());
assertEquals(1, queryCacheClassPredicateConfig.getBatchSize());
assertEquals(16, queryCacheClassPredicateConfig.getBufferSize());
assertEquals(0, queryCacheClassPredicateConfig.getDelaySeconds());
EvictionConfig evictionConfig = queryCacheClassPredicateConfig.getEvictionConfig();
assertEquals(EvictionPolicy.LRU, evictionConfig.getEvictionPolicy());
assertEquals(MaxSizePolicy.ENTRY_COUNT, evictionConfig.getMaxSizePolicy());
assertEquals(10000, evictionConfig.getSize());
assertEquals("com.hazelcast.examples.MyEvictionComparator", evictionConfig.getComparatorClassName());
assertEquals(InMemoryFormat.BINARY, queryCacheClassPredicateConfig.getInMemoryFormat());
assertFalse(queryCacheClassPredicateConfig.isCoalesce());
assertTrue(queryCacheClassPredicateConfig.isPopulate());
assertFalse(queryCacheClassPredicateConfig.isSerializeKeys());
for (IndexConfig indexConfig : queryCacheClassPredicateConfig.getIndexConfigs()) {
assertEquals("name", indexConfig.getAttributes().get(0));
assertFalse(indexConfig.getType() == IndexType.SORTED);
}
assertEquals("com.hazelcast.examples.ExamplePredicate", queryCacheClassPredicateConfig.getPredicateConfig().getClassName());
assertEquals("query-cache-sql-predicate", queryCacheSqlPredicateConfig.getName());
assertEquals("%age=40", queryCacheSqlPredicateConfig.getPredicateConfig().getSql());
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class DynamicConfigBouncingTest method createMapConfig.
private static MapConfig createMapConfig(String mapName) {
NearCacheConfig nearCacheConfig = new NearCacheConfig().setCacheLocalEntries(true).setInMemoryFormat(InMemoryFormat.NATIVE).setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy.CACHE_ON_UPDATE).setPreloaderConfig(new NearCachePreloaderConfig().setEnabled(true));
HotRestartConfig hotRestartConfig = new HotRestartConfig().setEnabled(true).setFsync(true);
EvictionConfig evictionConfig = new EvictionConfig();
evictionConfig.setSize(1000).setMaxSizePolicy(MaxSizePolicy.FREE_HEAP_SIZE).setComparator(new LRUEvictionPolicyComparator());
MapStoreConfig mapStoreConfig = new MapStoreConfig().setEnabled(true).setClassName("foo.bar.MapStoreDoesNotExist");
WanReplicationRef wanRef = new WanReplicationRef("name", "foo.bar.PolicyClass", Collections.<String>emptyList(), true);
EntryListenerConfig classEntryListener = new EntryListenerConfig("foo.bar.ClassName", true, true);
EntryListenerConfig entryListener = new EntryListenerConfig(new MyEntryListener(), true, true);
EntryListenerConfig mapListener = new EntryListenerConfig(new MyEntryUpdatedListener(), true, true);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig("queryCacheName").setBatchSize(100).addIndexConfig(new IndexConfig(IndexType.HASH, "attribute")).addEntryListenerConfig(new EntryListenerConfig("foo.bar.Classname", false, true)).setInMemoryFormat(InMemoryFormat.OBJECT);
return new MapConfig(mapName).setBackupCount(2).setBackupCount(3).setTimeToLiveSeconds(12).setMaxIdleSeconds(20).setNearCacheConfig(nearCacheConfig).setReadBackupData(true).setCacheDeserializedValues(CacheDeserializedValues.ALWAYS).setInMemoryFormat(InMemoryFormat.OBJECT).setHotRestartConfig(hotRestartConfig).setEvictionConfig(evictionConfig).setMapStoreConfig(mapStoreConfig).setWanReplicationRef(wanRef).addEntryListenerConfig(classEntryListener).addEntryListenerConfig(entryListener).addEntryListenerConfig(mapListener).addMapPartitionLostListenerConfig(new MapPartitionLostListenerConfig("foo.bar.Classname")).addIndexConfig(new IndexConfig(IndexType.SORTED, "orderAttribute")).addIndexConfig(new IndexConfig(IndexType.HASH, "unorderedAttribute")).addAttributeConfig(new AttributeConfig("attribute", "foo.bar.ExtractorClass")).addQueryCacheConfig(queryCacheConfig).setStatisticsEnabled(false).setPerEntryStatsEnabled(true).setPartitioningStrategyConfig(new PartitioningStrategyConfig("foo.bar.Class")).setSplitBrainProtectionName("split-brain-protection");
}
use of com.hazelcast.config.QueryCacheConfig in project hazelcast by hazelcast.
the class AbstractQueryCacheTestSupport method getIMapWithDefaultConfig.
<K, V> IMap<K, V> getIMapWithDefaultConfig(Predicate predicate, String useNaturalFilteringStrategy) {
Config config = new Config();
config.setProperty("hazelcast.map.entry.filtering.natural.event.types", useNaturalFilteringStrategy);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
queryCacheConfig.getPredicateConfig().setImplementation(predicate);
queryCacheConfig.setInMemoryFormat(getInMemoryFormat());
config.getMapConfig(mapName).addQueryCacheConfig(queryCacheConfig);
return factory.newInstances(config)[0].getMap(mapName);
}
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).setMaxSizePolicy(MaxSizePolicy.ENTRY_COUNT);
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.addQueryCacheConfig(cacheConfig);
return config;
}
Aggregations