Search in sources :

Example 6 with MaxSizePolicy

use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.

the class ConfigValidator method checkMapMaxSizePolicyPerInMemoryFormat.

static void checkMapMaxSizePolicyPerInMemoryFormat(MapConfig mapConfig) {
    MaxSizePolicy maxSizePolicy = mapConfig.getEvictionConfig().getMaxSizePolicy();
    InMemoryFormat inMemoryFormat = mapConfig.getInMemoryFormat();
    if (inMemoryFormat == NATIVE) {
        if (!MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES.contains(maxSizePolicy)) {
            throwNotMatchingMaxSizePolicy(inMemoryFormat, maxSizePolicy, MAP_SUPPORTED_NATIVE_MAX_SIZE_POLICIES);
        }
    } else {
        if (!MAP_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES.contains(maxSizePolicy)) {
            throwNotMatchingMaxSizePolicy(inMemoryFormat, maxSizePolicy, MAP_SUPPORTED_ON_HEAP_MAX_SIZE_POLICIES);
        }
    }
}
Also used : MaxSizePolicy(com.hazelcast.config.MaxSizePolicy) InMemoryFormat(com.hazelcast.config.InMemoryFormat)

Example 7 with MaxSizePolicy

use of com.hazelcast.config.MaxSizePolicy in project hazelcast by hazelcast.

the class ConfigFactory method newEvictionConfig.

public static EvictionConfig newEvictionConfig(Integer maxSize, MaxSizePolicy maxSizePolicy, EvictionPolicy evictionPolicy, boolean isNearCache, boolean isIMap, String comparatorClassName, EvictionPolicyComparator<?, ?, ?> comparator) {
    int finalSize = maxSize(maxSize, isIMap);
    MaxSizePolicy finalMaxSizePolicy = maxSizePolicy(maxSizePolicy, isIMap);
    EvictionPolicy finalEvictionPolicy = evictionPolicy(evictionPolicy, isIMap);
    try {
        doEvictionConfigChecks(finalMaxSizePolicy, finalEvictionPolicy, comparatorClassName, comparator, isIMap, isNearCache);
    } catch (IllegalArgumentException e) {
        throw new InvalidConfigurationException(e.getMessage());
    }
    EvictionConfig evictionConfig = new EvictionConfig().setSize(finalSize).setMaxSizePolicy(finalMaxSizePolicy).setEvictionPolicy(finalEvictionPolicy);
    if (comparatorClassName != null) {
        evictionConfig.setComparatorClassName(comparatorClassName);
    }
    if (comparator != null) {
        evictionConfig.setComparator(comparator);
    }
    return evictionConfig;
}
Also used : MaxSizePolicy(com.hazelcast.config.MaxSizePolicy) EvictionPolicy(com.hazelcast.config.EvictionPolicy) ConfigValidator.checkNearCacheEvictionConfig(com.hazelcast.internal.config.ConfigValidator.checkNearCacheEvictionConfig) ConfigValidator.checkEvictionConfig(com.hazelcast.internal.config.ConfigValidator.checkEvictionConfig) ConfigValidator.checkMapEvictionConfig(com.hazelcast.internal.config.ConfigValidator.checkMapEvictionConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

MaxSizePolicy (com.hazelcast.config.MaxSizePolicy)7 EvictionConfig (com.hazelcast.config.EvictionConfig)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 Config (com.hazelcast.config.Config)2 InMemoryFormat (com.hazelcast.config.InMemoryFormat)2 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)2 EvictionPolicy (com.hazelcast.config.EvictionPolicy)1 ConfigValidator.checkEvictionConfig (com.hazelcast.internal.config.ConfigValidator.checkEvictionConfig)1 ConfigValidator.checkMapEvictionConfig (com.hazelcast.internal.config.ConfigValidator.checkMapEvictionConfig)1 ConfigValidator.checkNearCacheEvictionConfig (com.hazelcast.internal.config.ConfigValidator.checkNearCacheEvictionConfig)1 MapContainer (com.hazelcast.map.impl.MapContainer)1