Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setEvictionFilter()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setEvictionFilter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgfsHelperImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void preProcessCacheConfiguration(CacheConfiguration cfg) {
    EvictionPolicy evictPlc = cfg.getEvictionPolicyFactory() != null ?
        (EvictionPolicy)cfg.getEvictionPolicyFactory().create()
        : cfg.getEvictionPolicy();

    if (evictPlc instanceof IgfsPerBlockLruEvictionPolicy && cfg.getEvictionFilter() == null)
        cfg.setEvictionFilter(new IgfsEvictionFilter());
}
 
Example 2
Source File: EvictionAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(mode);
    cc.setEvictionPolicy(createPolicy(plcMax));
    cc.setOnheapCacheEnabled(true);
    cc.setWriteSynchronizationMode(syncCommit ? FULL_SYNC : FULL_ASYNC);
    cc.setAtomicityMode(TRANSACTIONAL);

    if (nearEnabled) {
        NearCacheConfiguration nearCfg = new NearCacheConfiguration();

        nearCfg.setNearEvictionPolicy(createNearPolicy(nearMax));

        cc.setNearConfiguration(nearCfg);
    }
    else
        cc.setNearConfiguration(null);

    if (mode == PARTITIONED)
        cc.setBackups(1);

    if (filter != null)
        cc.setEvictionFilter(filter);

    c.setCacheConfiguration(cc);

    c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);

    c.setIncludeProperties();

    return c;
}
 
Example 3
Source File: GridCacheEvictionFilterSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(mode);
    cc.setEvictionPolicy(notSerializableProxy(plc, EvictionPolicy.class));
    cc.setOnheapCacheEnabled(true);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setEvictionFilter(notSerializableProxy(filter, org.apache.ignite.cache.eviction.EvictionFilter.class));
    cc.setRebalanceMode(SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);

    if (nearEnabled) {
        NearCacheConfiguration nearCfg = new NearCacheConfiguration();
        nearCfg.setNearEvictionPolicy(notSerializableProxy(plc, EvictionPolicy.class));

        cc.setNearConfiguration(nearCfg);
    }
    else
        cc.setNearConfiguration(null);

    if (mode == PARTITIONED)
        cc.setBackups(1);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 4
Source File: GridCacheLifecycleAwareSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    ccfg.setWriteBehindEnabled(writeBehind);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    ccfg.setName(CACHE_NAME);

    TestStore store = new TestStore();

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    lifecycleAwares.add(store.lifecycleAware);

    TestAffinityFunction affinity = new TestAffinityFunction();

    ccfg.setAffinity(affinity);

    lifecycleAwares.add(affinity);

    TestEvictionPolicy evictionPlc = new TestEvictionPolicy();

    ccfg.setEvictionPolicy(evictionPlc);
    ccfg.setOnheapCacheEnabled(true);

    lifecycleAwares.add(evictionPlc);

    if (near) {
        TestEvictionPolicy nearEvictionPlc = new TestEvictionPolicy();

        NearCacheConfiguration nearCfg = new NearCacheConfiguration();

        nearCfg.setNearEvictionPolicy(nearEvictionPlc);

        ccfg.setNearConfiguration(nearCfg);

        lifecycleAwares.add(nearEvictionPlc);
    }

    TestEvictionFilter evictionFilter = new TestEvictionFilter();

    ccfg.setEvictionFilter(evictionFilter);

    lifecycleAwares.add(evictionFilter);

    TestAffinityKeyMapper mapper = new TestAffinityKeyMapper();

    ccfg.setAffinityMapper(mapper);

    lifecycleAwares.add(mapper);

    TestInterceptor interceptor = new TestInterceptor();

    lifecycleAwares.add(interceptor);

    ccfg.setInterceptor(interceptor);

    TestTopologyValidator topValidator = new TestTopologyValidator();

    lifecycleAwares.add(topValidator);

    ccfg.setTopologyValidator(topValidator);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}