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