@Override public boolean isEvictionRequired() { return cache.size() >= evictionConfig.getSize(); } };
@Override public boolean isEvictionRequired() { return cache.size() >= evictionConfig.getSize(); } };
@Override protected EvictionChecker createNearCacheEvictionChecker(EvictionConfig evictionConfig, NearCacheConfig nearCacheConfig) { MaxSizePolicy maxSizePolicy = evictionConfig.getMaximumSizePolicy(); if (maxSizePolicy != MaxSizePolicy.ENTRY_COUNT) { throw new IllegalArgumentException(format("Invalid max-size policy (%s) for %s! Only %s is supported.", maxSizePolicy, getClass().getName(), MaxSizePolicy.ENTRY_COUNT)); } return new EntryCountNearCacheEvictionChecker(evictionConfig.getSize(), records); }
@Override protected EvictionChecker createNearCacheEvictionChecker(EvictionConfig evictionConfig, NearCacheConfig nearCacheConfig) { MaxSizePolicy maxSizePolicy = evictionConfig.getMaximumSizePolicy(); if (maxSizePolicy != MaxSizePolicy.ENTRY_COUNT) { throw new IllegalArgumentException(format("Invalid max-size policy (%s) for %s! Only %s is supported.", maxSizePolicy, getClass().getName(), MaxSizePolicy.ENTRY_COUNT)); } return new EntryCountNearCacheEvictionChecker(evictionConfig.getSize(), records); }
@Override public boolean reachedMaxCapacity() { EvictionConfig evictionConfig = queryCacheConfig.getEvictionConfig(); EvictionConfig.MaxSizePolicy maximumSizePolicy = evictionConfig.getMaximumSizePolicy(); return maximumSizePolicy == EvictionConfig.MaxSizePolicy.ENTRY_COUNT && size() == evictionConfig.getSize(); }
@Override public boolean reachedMaxCapacity() { EvictionConfig evictionConfig = queryCacheConfig.getEvictionConfig(); EvictionConfig.MaxSizePolicy maximumSizePolicy = evictionConfig.getMaximumSizePolicy(); return maximumSizePolicy == EvictionConfig.MaxSizePolicy.ENTRY_COUNT && size() == evictionConfig.getSize(); }
public NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig) { this.inMemoryFormat = inMemoryFormat; this.invalidateOnChange = invalidateOnChange; this.timeToLiveSeconds = timeToLiveSeconds; this.maxIdleSeconds = maxIdleSeconds; this.maxSize = calculateMaxSize(maxSize); // EvictionConfig is not allowed to be null if (evictionConfig != null) { this.maxSize = evictionConfig.getSize(); this.evictionPolicy = evictionConfig.getEvictionPolicy().toString(); this.evictionConfig = evictionConfig; } }
public NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig) { this.inMemoryFormat = inMemoryFormat; this.invalidateOnChange = invalidateOnChange; this.timeToLiveSeconds = timeToLiveSeconds; this.maxIdleSeconds = maxIdleSeconds; this.maxSize = calculateMaxSize(maxSize); // EvictionConfig is not allowed to be null if (evictionConfig != null) { this.maxSize = evictionConfig.getSize(); this.evictionPolicy = evictionConfig.getEvictionPolicy().toString(); this.evictionConfig = evictionConfig; } }
System.out.println("max-size: " + evictionConfig.getSize()); System.out.println("max-size-policy: " + evictionConfig.getMaximumSizePolicy()); System.out.println("eviction-policy: " + evictionConfig.getEvictionPolicy());
private static void evictionConfigXmlGenerator(XmlGenerator gen, EvictionConfig e) { if (e == null) { return; } String comparatorClassName = !isNullOrEmpty(e.getComparatorClassName()) ? e.getComparatorClassName() : null; gen.node("eviction", null, "size", e.getSize(), "max-size-policy", e.getMaximumSizePolicy(), "eviction-policy", e.getEvictionPolicy(), "comparator-class-name", comparatorClassName); }
private static void evictionConfigXmlGenerator(XmlGenerator gen, EvictionConfig e) { if (e == null) { return; } String comparatorClassName = !isNullOrEmpty(e.getComparatorClassName()) ? e.getComparatorClassName() : null; gen.node("eviction", null, "size", e.getSize(), "max-size-policy", e.getMaximumSizePolicy(), "eviction-policy", e.getEvictionPolicy(), "comparator-class-name", comparatorClassName); }
System.out.println("cache configured with eviction -> size:" + evictionConfig.getSize() + " policy:" + evictionConfig.getEvictionPolicyType());
public static EvictionConfigHolder of(EvictionConfig config, SerializationService serializationService) { return new EvictionConfigHolder(config.getSize(), config.getMaximumSizePolicy().name(), config.getEvictionPolicy().name(), config.getComparatorClassName(), serializationService.toData(config.getComparator())); } }
public static EvictionConfigHolder of(EvictionConfig config, SerializationService serializationService) { return new EvictionConfigHolder(config.getSize(), config.getMaximumSizePolicy().name(), config.getEvictionPolicy().name(), config.getComparatorClassName(), serializationService.toData(config.getComparator())); } }
private static void queryCaches(XmlGenerator gen, Map<String, Map<String, QueryCacheConfig>> queryCaches) { if (queryCaches.isEmpty()) { return; } gen.open("query-caches"); for (Map.Entry<String, Map<String, QueryCacheConfig>> entry : queryCaches.entrySet()) { String mapName = entry.getKey(); Map<String, QueryCacheConfig> queryCachesPerMap = entry.getValue(); for (QueryCacheConfig queryCache : queryCachesPerMap.values()) { gen.open("query-cache", "mapName", mapName, "name", queryCache.getName()) .node("include-value", queryCache.isIncludeValue()) .node("in-memory-format", queryCache.getInMemoryFormat()) .node("populate", queryCache.isPopulate()) .node("coalesce", queryCache.isCoalesce()) .node("delay-seconds", queryCache.getDelaySeconds()) .node("batch-size", queryCache.getBatchSize()) .node("buffer-size", queryCache.getBufferSize()) .node("eviction", null, "size", queryCache.getEvictionConfig().getSize(), "max-size-policy", queryCache.getEvictionConfig().getMaximumSizePolicy(), "eviction-policy", queryCache.getEvictionConfig().getEvictionPolicy()); queryCachePredicate(gen, queryCache.getPredicateConfig()); entryListeners(gen, queryCache.getEntryListenerConfigs()); indexes(gen, queryCache.getIndexConfigs()); //close query-cache gen.close(); } } //close query-caches gen.close(); }
private static void queryCaches(XmlGenerator gen, Map<String, Map<String, QueryCacheConfig>> queryCaches) { if (queryCaches.isEmpty()) { return; } gen.open("query-caches"); for (Map.Entry<String, Map<String, QueryCacheConfig>> entry : queryCaches.entrySet()) { String mapName = entry.getKey(); Map<String, QueryCacheConfig> queryCachesPerMap = entry.getValue(); for (QueryCacheConfig queryCache : queryCachesPerMap.values()) { gen.open("query-cache", "mapName", mapName, "name", queryCache.getName()) .node("include-value", queryCache.isIncludeValue()) .node("in-memory-format", queryCache.getInMemoryFormat()) .node("populate", queryCache.isPopulate()) .node("coalesce", queryCache.isCoalesce()) .node("delay-seconds", queryCache.getDelaySeconds()) .node("batch-size", queryCache.getBatchSize()) .node("buffer-size", queryCache.getBufferSize()) .node("eviction", null, "size", queryCache.getEvictionConfig().getSize(), "max-size-policy", queryCache.getEvictionConfig().getMaximumSizePolicy(), "eviction-policy", queryCache.getEvictionConfig().getEvictionPolicy()); queryCachePredicate(gen, queryCache.getPredicateConfig()); entryListeners(gen, queryCache.getEntryListenerConfigs()); indexes(gen, queryCache.getIndexConfigs()); //close query-cache gen.close(); } } //close query-caches gen.close(); }
private static void nearCache(XmlGenerator gen, String name, NearCacheConfig nearCache) { EvictionConfig eviction = nearCache.getEvictionConfig(); NearCachePreloaderConfig preloader = nearCache.getPreloaderConfig(); gen.open("near-cache", "name", name) .node("in-memory-format", nearCache.getInMemoryFormat()) .node("serialize-keys", nearCache.isSerializeKeys()) .node("invalidate-on-change", nearCache.isInvalidateOnChange()) .node("cache-local-entries", nearCache.isCacheLocalEntries()) .node("time-to-live-seconds", nearCache.getTimeToLiveSeconds()) .node("max-idle-seconds", nearCache.getMaxIdleSeconds()) .node("local-update-policy", nearCache.getLocalUpdatePolicy()) .node("eviction", null, "size", eviction.getSize(), "max-size-policy", eviction.getMaximumSizePolicy(), "eviction-policy", eviction.getEvictionPolicy()) .node("preloader", null, "enabled", preloader.isEnabled(), "directory", preloader.getDirectory(), "store-initial-delay-seconds", preloader.getStoreInitialDelaySeconds(), "store-interval-seconds", preloader.getStoreIntervalSeconds()); //close near-cache gen.close(); }
private static void nearCache(XmlGenerator gen, String name, NearCacheConfig nearCache) { EvictionConfig eviction = nearCache.getEvictionConfig(); NearCachePreloaderConfig preloader = nearCache.getPreloaderConfig(); gen.open("near-cache", "name", name) .node("in-memory-format", nearCache.getInMemoryFormat()) .node("serialize-keys", nearCache.isSerializeKeys()) .node("invalidate-on-change", nearCache.isInvalidateOnChange()) .node("cache-local-entries", nearCache.isCacheLocalEntries()) .node("time-to-live-seconds", nearCache.getTimeToLiveSeconds()) .node("max-idle-seconds", nearCache.getMaxIdleSeconds()) .node("local-update-policy", nearCache.getLocalUpdatePolicy()) .node("eviction", null, "size", eviction.getSize(), "max-size-policy", eviction.getMaximumSizePolicy(), "eviction-policy", eviction.getEvictionPolicy()) .node("preloader", null, "enabled", preloader.isEnabled(), "directory", preloader.getDirectory(), "store-initial-delay-seconds", preloader.getStoreInitialDelaySeconds(), "store-interval-seconds", preloader.getStoreIntervalSeconds()); //close near-cache gen.close(); }
this.evictionChecker = createCacheEvictionChecker(evictionConfig.getSize(), evictionConfig.getMaximumSizePolicy()); this.evictionPolicyEvaluator = createEvictionPolicyEvaluator(evictionConfig); this.evictionStrategy = createEvictionStrategy(evictionConfig);
this.evictionChecker = createCacheEvictionChecker(evictionConfig.getSize(), evictionConfig.getMaximumSizePolicy()); this.evictionPolicyEvaluator = createEvictionPolicyEvaluator(evictionConfig); this.evictionStrategy = createEvictionStrategy(evictionConfig);