Search in sources :

Example 6 with EvictionPolicy

use of com.hazelcast.config.EvictionPolicy 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)

Example 7 with EvictionPolicy

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

the class ConfigValidator method checkEvictionConfig.

/**
 * Checks if a {@link EvictionConfig} is valid in its context.
 *
 * @param evictionConfig the {@link EvictionConfig}
 */
public static void checkEvictionConfig(EvictionConfig evictionConfig, EnumSet<EvictionPolicy> supportedEvictionPolicies) {
    if (evictionConfig == null) {
        throw new InvalidConfigurationException("Eviction config cannot be null!");
    }
    EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy();
    String comparatorClassName = evictionConfig.getComparatorClassName();
    EvictionPolicyComparator comparator = evictionConfig.getComparator();
    checkEvictionConfig(evictionPolicy, comparatorClassName, comparator, supportedEvictionPolicies);
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) EvictionPolicyComparator(com.hazelcast.spi.eviction.EvictionPolicyComparator) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

EvictionPolicy (com.hazelcast.config.EvictionPolicy)7 EvictionConfig (com.hazelcast.config.EvictionConfig)2 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)2 MapConfig (com.hazelcast.config.MapConfig)2 EvictionPolicyComparator (com.hazelcast.spi.eviction.EvictionPolicyComparator)2 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)1 MaxSizePolicy (com.hazelcast.config.MaxSizePolicy)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)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 EvictionPolicyComparator (com.hazelcast.internal.eviction.EvictionPolicyComparator)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 HazelcastProperties (org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties)1 Test (org.junit.Test)1