/** * Checks if a {@link EvictionConfig} is valid in its context. * * @param evictionConfig the {@link EvictionConfig} * @param isNearCache {@code true} if the config is for a Near Cache, {@code false} otherwise */ @SuppressWarnings("ConstantConditions") public static void checkEvictionConfig(EvictionConfig evictionConfig, boolean isNearCache) { if (evictionConfig == null) { throw new IllegalArgumentException("Eviction config cannot be null!"); } EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy(); String comparatorClassName = evictionConfig.getComparatorClassName(); EvictionPolicyComparator comparator = evictionConfig.getComparator(); checkEvictionConfig(evictionPolicy, comparatorClassName, comparator, isNearCache); }
/** * Checks if a {@link EvictionConfig} is valid in its context. * * @param evictionConfig the {@link EvictionConfig} * @param isNearCache {@code true} if the config is for a Near Cache, {@code false} otherwise */ @SuppressWarnings("ConstantConditions") public static void checkEvictionConfig(EvictionConfig evictionConfig, boolean isNearCache) { if (evictionConfig == null) { throw new IllegalArgumentException("Eviction config cannot be null!"); } EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy(); String comparatorClassName = evictionConfig.getComparatorClassName(); EvictionPolicyComparator comparator = evictionConfig.getComparator(); checkEvictionConfig(evictionPolicy, comparatorClassName, comparator, isNearCache); }
protected AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, NearCacheStatsImpl nearCacheStats, SerializationService serializationService, ClassLoader classLoader) { this.nearCacheConfig = nearCacheConfig; this.timeToLiveMillis = nearCacheConfig.getTimeToLiveSeconds() * MILLI_SECONDS_IN_A_SECOND; this.maxIdleMillis = nearCacheConfig.getMaxIdleSeconds() * MILLI_SECONDS_IN_A_SECOND; this.serializationService = serializationService; this.classLoader = classLoader; this.nearCacheStats = nearCacheStats; this.evictionDisabled = nearCacheConfig.getEvictionConfig().getEvictionPolicy() == EvictionPolicy.NONE; }
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; } }
protected AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, NearCacheStatsImpl nearCacheStats, SerializationService serializationService, ClassLoader classLoader) { this.nearCacheConfig = nearCacheConfig; this.inMemoryFormat = nearCacheConfig.getInMemoryFormat(); this.timeToLiveMillis = nearCacheConfig.getTimeToLiveSeconds() * MILLI_SECONDS_IN_A_SECOND; this.maxIdleMillis = nearCacheConfig.getMaxIdleSeconds() * MILLI_SECONDS_IN_A_SECOND; this.serializationService = serializationService; this.classLoader = classLoader; this.nearCacheStats = nearCacheStats; this.evictionDisabled = nearCacheConfig.getEvictionConfig().getEvictionPolicy() == EvictionPolicy.NONE; }
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); }
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(); }