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;
}
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);
}
Aggregations