Search in sources :

Example 1 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}
     * @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);
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) EvictionPolicyComparator(com.hazelcast.internal.eviction.EvictionPolicyComparator)

Example 2 with EvictionPolicy

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());
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) EvictionConfig(com.hazelcast.config.EvictionConfig) MapConfig(com.hazelcast.config.MapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 3 with EvictionPolicy

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());
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) EvictionPolicyComparator(com.hazelcast.spi.eviction.EvictionPolicyComparator)

Example 4 with EvictionPolicy

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;
}
Also used : EvictionPolicy(com.hazelcast.config.EvictionPolicy) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 5 with EvictionPolicy

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()));
}
Also used : HazelcastProperties(org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties) MaxSizeConfig(com.hazelcast.config.MaxSizeConfig) EvictionPolicy(com.hazelcast.config.EvictionPolicy) MapConfig(com.hazelcast.config.MapConfig)

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