Search in sources :

Example 11 with EvictionConfig

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

the class ConfigValidatorTest method getEvictionConfig.

private EvictionConfig getEvictionConfig(boolean setComparatorClass, boolean setComparator, EvictionPolicy evictionPolicy) {
    EvictionConfig evictionConfig = new EvictionConfig();
    if (setComparatorClass) {
        evictionConfig.setComparatorClassName("myComparatorClass");
    }
    if (setComparator) {
        evictionConfig.setComparator(new EvictionPolicyComparator() {

            @Override
            @SuppressWarnings("ComparatorMethodParameterNotUsed")
            public int compare(EvictableEntryView e1, EvictableEntryView e2) {
                return 0;
            }

            @Override
            @SuppressWarnings("ComparatorMethodParameterNotUsed")
            public int compare(Object o1, Object o2) {
                return 0;
            }
        });
    }
    evictionConfig.setEvictionPolicy(evictionPolicy);
    return evictionConfig;
}
Also used : EvictableEntryView(com.hazelcast.internal.eviction.EvictableEntryView) ConfigValidator.checkEvictionConfig(com.hazelcast.internal.config.ConfigValidator.checkEvictionConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) EvictionPolicyComparator(com.hazelcast.internal.eviction.EvictionPolicyComparator)

Example 12 with EvictionConfig

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

the class XmlClientConfigBuilder method getEvictionConfig.

private EvictionConfig getEvictionConfig(Node node) {
    EvictionConfig evictionConfig = new EvictionConfig();
    Node size = node.getAttributes().getNamedItem("size");
    Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy");
    Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy");
    if (size != null) {
        evictionConfig.setSize(Integer.parseInt(getTextContent(size)));
    }
    if (maxSizePolicy != null) {
        evictionConfig.setMaximumSizePolicy(MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))));
    }
    if (evictionPolicy != null) {
        evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))));
    }
    return evictionConfig;
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) Node(org.w3c.dom.Node)

Example 13 with EvictionConfig

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

the class AbstractNearCacheRecordStore method initialize.

@Override
public void initialize() {
    EvictionConfig evictionConfig = nearCacheConfig.getEvictionConfig();
    this.records = createNearCacheRecordMap(nearCacheConfig);
    this.evictionChecker = createNearCacheEvictionChecker(evictionConfig, nearCacheConfig);
    this.evictionPolicyEvaluator = createEvictionPolicyEvaluator(evictionConfig);
    this.evictionStrategy = createEvictionStrategy(evictionConfig);
    this.evictionPolicyType = evictionConfig.getEvictionPolicyType();
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig)

Aggregations

EvictionConfig (com.hazelcast.config.EvictionConfig)13 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 Node (org.w3c.dom.Node)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 MapConfig (com.hazelcast.config.MapConfig)1 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 LifecycleEvent (com.hazelcast.core.LifecycleEvent)1 LifecycleListener (com.hazelcast.core.LifecycleListener)1 ConfigValidator.checkEvictionConfig (com.hazelcast.internal.config.ConfigValidator.checkEvictionConfig)1 EvictableEntryView (com.hazelcast.internal.eviction.EvictableEntryView)1 EvictionPolicyComparator (com.hazelcast.internal.eviction.EvictionPolicyComparator)1 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1