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}
* @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);
}
use of com.hazelcast.config.EvictionPolicy in project hazelcast by hazelcast.
the class TestFullApplicationContext method testWhenBothMapEvictionPolicyClassNameAndEvictionPolicySet.
@Test
public void testWhenBothMapEvictionPolicyClassNameAndEvictionPolicySet() {
MapConfig mapConfig = config.getMapConfig("mapWithBothComparatorClassNameAndEvictionPolicy");
String expectedComparatorClassName = "com.hazelcast.internal.eviction.impl.comparator.LFUEvictionPolicyComparator";
EvictionConfig evictionConfig = mapConfig.getEvictionConfig();
EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy();
assertEquals(EvictionPolicy.LRU, evictionPolicy);
assertEquals(expectedComparatorClassName, evictionConfig.getComparatorClassName());
}
use of com.hazelcast.config.EvictionPolicy in project hazelcast by hazelcast.
the class ConfigValidator method checkMapEvictionConfig.
public static void checkMapEvictionConfig(EvictionConfig evictionConfig) {
EvictionPolicyComparator comparator = evictionConfig.getComparator();
String comparatorClassName = evictionConfig.getComparatorClassName();
EvictionPolicy evictionPolicy = evictionConfig.getEvictionPolicy();
checkComparatorDefinedOnlyOnce(comparatorClassName, comparator);
checkEvictionPolicyConfiguredOnlyOnce(evictionPolicy, comparatorClassName, comparator, MapConfig.DEFAULT_EVICTION_POLICY);
checkMapMaxSizePolicyConfig(evictionConfig.getMaxSizePolicy());
}
use of com.hazelcast.config.EvictionPolicy in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isEvictionEnabled.
private boolean isEvictionEnabled(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
EvictionPolicy evictionPolicy = mapContainer.getMapConfig().getEvictionConfig().getEvictionPolicy();
return evictionPolicy != NONE;
}
use of com.hazelcast.config.EvictionPolicy in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method createMapConfig.
private MapConfig createMapConfig(final TicketDefinition definition) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final EvictionPolicy evictionPolicy = EvictionPolicy.valueOf(cluster.getEvictionPolicy());
LOGGER.debug("Creating Hazelcast map configuration for [{}] with idle timeout [{}] second(s)", definition.getProperties().getStorageName(), definition.getProperties().getStorageTimeout());
return new MapConfig().setName(definition.getProperties().getStorageName()).setMaxIdleSeconds((int) definition.getProperties().getStorageTimeout()).setBackupCount(cluster.getBackupCount()).setAsyncBackupCount(cluster.getAsyncBackupCount()).setEvictionPolicy(evictionPolicy).setMaxSizeConfig(new MaxSizeConfig().setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.valueOf(cluster.getMaxSizePolicy())).setSize(cluster.getMaxHeapSizePercentage()));
}
Aggregations