Search in sources :

Example 1 with FifoEvictionPolicyFactory

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory in project ignite by apache.

the class GridCacheConfigurationConsistencySelfTest method testPartitionedOnlyAttributesIgnoredForReplicated.

/**
 * @throws Exception If failed.
 */
@Test
public void testPartitionedOnlyAttributesIgnoredForReplicated() throws Exception {
    cacheEnabled = true;
    cacheMode = REPLICATED;
    initCache = new C1<CacheConfiguration, Void>() {

        @Override
        public Void apply(CacheConfiguration cfg) {
            NearCacheConfiguration nearCfg = new NearCacheConfiguration();
            nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
            nearCfg.setNearEvictionPolicy(new LruEvictionPolicy());
            cfg.setNearConfiguration(nearCfg);
            return null;
        }
    };
    startGrid(1);
    initCache = new C1<CacheConfiguration, Void>() {

        @Override
        public Void apply(CacheConfiguration cfg) {
            NearCacheConfiguration nearCfg = new NearCacheConfiguration();
            nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
            nearCfg.setNearEvictionPolicy(new FifoEvictionPolicy());
            cfg.setNearConfiguration(nearCfg);
            return null;
        }
    };
    startGrid(2);
}
Also used : FifoEvictionPolicyFactory(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with FifoEvictionPolicyFactory

use of org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory in project ignite by apache.

the class GridEvictionPolicyMBeansTest method getConfiguration.

/**
 * {@inheritDoc}
 *
 * This implementation  adds eviction policies.
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    FifoEvictionPolicyFactory<String, String> plc = new FifoEvictionPolicyFactory<>();
    plc.setMaxSize(100);
    plc.setBatchSize(10);
    plc.setMaxMemorySize(20);
    CacheConfiguration cache1 = defaultCacheConfiguration();
    cache1.setName("cache1");
    cache1.setOnheapCacheEnabled(true);
    cache1.setEvictionPolicyFactory(plc);
    NearCacheConfiguration ncf = new NearCacheConfiguration<>();
    ncf.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(40, 10, 500));
    CacheConfiguration cache2 = defaultCacheConfiguration();
    cache2.setName("cache2");
    cache2.setOnheapCacheEnabled(true);
    LruEvictionPolicy lep = new LruEvictionPolicy();
    lep.setBatchSize(10);
    lep.setMaxMemorySize(125);
    lep.setMaxSize(30);
    cache2.setEvictionPolicy(lep);
    ncf = new NearCacheConfiguration<>();
    lep = new LruEvictionPolicy();
    lep.setBatchSize(10);
    lep.setMaxMemorySize(500);
    lep.setMaxSize(40);
    ncf.setNearEvictionPolicy(lep);
    if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) {
        cache1.setNearConfiguration(ncf);
        cache2.setNearConfiguration(ncf);
    }
    cfg.setCacheConfiguration(cache1, cache2);
    return cfg;
}
Also used : FifoEvictionPolicyFactory(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Aggregations

FifoEvictionPolicyFactory (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory)2 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1