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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setEvictionPolicy() . 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: GridCacheMultithreadedFailoverAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Node configuration.
 *
 * @param idx Node index.
 * @return Node configuration.
 * @throws Exception If failed.
 */
private IgniteConfiguration configuration(int idx) throws Exception {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(CACHE_NAME);
    ccfg.setCacheMode(cacheMode());
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setRebalanceMode(SYNC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setEvictionPolicy(null);

    if (cacheMode() == PARTITIONED)
        ccfg.setBackups(backups());

    if (atomicityMode() != ATOMIC && cacheMode() == PARTITIONED) {
        ccfg.setNearConfiguration(new NearCacheConfiguration());
    }

    IgniteConfiguration cfg = getConfiguration(nodeName(idx));

    cfg.setLocalHost("127.0.0.1");
    cfg.setCacheConfiguration(ccfg);
    cfg.setConnectorConfiguration(null);

    return cfg;
}
 
Example 2
Source File: IgniteCacheQueryMultiThreadedSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configuration.
 */
protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setBackups(1);

    LruEvictionPolicy plc = null;

    if (evictsEnabled()) {
        plc = new LruEvictionPolicy();
        plc.setMaxSize(100);
    }

    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(plc != null);

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

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(CACHE_NAME);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(PRIMARY_SYNC);
    ccfg.setBackups(2);
    ccfg.setCacheMode(PARTITIONED);

    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(100000);

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

    c.setCacheConfiguration(ccfg);

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

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setName(CACHE_NAME);
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setNearConfiguration(null);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(100000);

    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setBackups(1);

    cacheCfg.setRebalanceMode(SYNC);

    cfg.setCacheConfiguration(cacheCfg);

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

    c.getTransactionConfiguration().setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(TransactionIsolation.READ_COMMITTED);

    CacheConfiguration cc1 = defaultCacheConfiguration();

    cc1.setName("one");
    cc1.setCacheMode(PARTITIONED);
    cc1.setBackups(1);
    cc1.setWriteSynchronizationMode(FULL_SYNC);
    cc1.setRebalanceMode(preloadMode);
    cc1.setEvictionPolicy(null);
    cc1.setCacheStoreFactory(null);

    // Identical configuration.
    CacheConfiguration cc2 = new CacheConfiguration(cc1);

    cc2.setName("two");

    c.setCacheConfiguration(cc1, cc2);

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

    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setName("cache-1");
    ccfg.setEvictionPolicy(new LruEvictionPolicy(10));
    ccfg.setOnheapCacheEnabled(true);
    ccfg.setIndexedTypes(Integer.class, TestData.class);

    cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(256L * 1024 * 1024));
    cfg.setDataStorageConfiguration(memCfg);

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

    CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setBackups(0);
    cacheCfg.setEvictionPolicy(null);
    cacheCfg.setNearConfiguration(null);

    cacheCfg.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 8
Source File: CacheRandomOperationsMultithreadedTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param atomicityMode Cache atomicity mode.
 * @param evictionPlc Eviction policy.
 * @param indexing Indexing flag.
 * @return Cache configuration.
 */
private CacheConfiguration<Object, Object> cacheConfiguration(
    CacheMode cacheMode,
    CacheAtomicityMode atomicityMode,
    @Nullable EvictionPolicy<Object, Object> evictionPlc,
    boolean indexing) {
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setCacheMode(cacheMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setEvictionPolicy(evictionPlc);
    ccfg.setOnheapCacheEnabled(evictionPlc != null);

    if (cacheMode == PARTITIONED)
        ccfg.setBackups(1);

    if (indexing)
        ccfg.setIndexedTypes(TestKey.class, TestData.class);

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

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(cacheMode);
    ccfg.setEagerTtl(true);
    ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100));
    ccfg.setOnheapCacheEnabled(true);
    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 10
Source File: GridCacheEvictionLockUnlockSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(mode);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setEvictionPolicy(new EvictionPolicy());
    cc.setOnheapCacheEnabled(true);
    cc.setAtomicityMode(TRANSACTIONAL);

    NearCacheConfiguration nearCfg = new NearCacheConfiguration();

    nearCfg.setNearEvictionPolicy(new EvictionPolicy());
    cc.setNearConfiguration(nearCfg);

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

    c.setCacheConfiguration(cc);

    c.setIncludeEventTypes(EventType.EVTS_ALL);

    return c;
}
 
Example 11
Source File: GridAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return New cache configuration with modified defaults.
 */
@SuppressWarnings("unchecked")
public static CacheConfiguration defaultCacheConfiguration() {
    CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    if (MvccFeatureChecker.forcedMvcc())
        cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    else
        cfg.setAtomicityMode(TRANSACTIONAL).setNearConfiguration(new NearCacheConfiguration<>());
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setEvictionPolicy(null);

    return cfg;
}
 
Example 12
Source File: GridCacheConcurrentTxMultiNodeLoadTest.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);

    c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);

    AtomicConfiguration atomicCfg = new AtomicConfiguration();

    atomicCfg.setAtomicSequenceReserveSize(100000);
    atomicCfg.setCacheMode(mode);

    c.setAtomicConfiguration(atomicCfg);

    if (cacheOn) {
        CacheConfiguration cc = defaultCacheConfiguration();

        cc.setCacheMode(mode);

        LruEvictionPolicy plc = new LruEvictionPolicy();
        plc.setMaxSize(1000);

        cc.setEvictionPolicy(plc);
        cc.setOnheapCacheEnabled(true);
        cc.setWriteSynchronizationMode(FULL_SYNC);
        cc.setRebalanceMode(NONE);

        c.setCacheConfiguration(cc);
    }
    else
        c.setCacheConfiguration();

    c.setPeerClassLoadingEnabled(false);

    return c;
}
 
Example 13
Source File: GridCacheOffheapIndexGetSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration.
 */
protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setEvictionPolicy(null);

    return cacheCfg;
}
 
Example 14
Source File: GridCachePartitionedHitsAndMissesSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Cache configuration.
 *
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
protected CacheConfiguration cacheConfiguration() throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setCacheMode(PARTITIONED);
    cfg.setWriteSynchronizationMode(FULL_ASYNC);
    cfg.setEvictionPolicy(null);
    cfg.setBackups(1);
    cfg.setNearConfiguration(null);
    cfg.setStatisticsEnabled(true);

    return cfg;
}
 
Example 15
Source File: IgniteCachePutRetryAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param evict If {@code true} adds eviction policy.
 * @param store If {@code true} adds cache store.
 * @return Cache configuration.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(boolean evict, boolean store) throws Exception {
    CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cfg.setAtomicityMode(atomicityMode());
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setBackups(1);
    cfg.setRebalanceMode(SYNC);

    if (evict) {
        LruEvictionPolicy plc = new LruEvictionPolicy();

        plc.setMaxSize(100);

        cfg.setEvictionPolicy(plc);

        cfg.setOnheapCacheEnabled(true);
    }

    if (store) {
        cfg.setCacheStoreFactory(new TestStoreFactory());
        cfg.setWriteThrough(true);
    }

    return cfg;
}
 
Example 16
Source File: IgniteHadoopFileSystemClientSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Gets cache configuration.
 *
 * @return Cache configuration.
 */
protected CacheConfiguration dataCacheConfiguration() {
    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName("partitioned");
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setNearConfiguration(null);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setEvictionPolicy(null);
    ccfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    ccfg.setBackups(0);
    ccfg.setAtomicityMode(TRANSACTIONAL);

    return ccfg;
}
 
Example 17
Source File: GridCacheConcurrentEvictionsSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);

    CacheConfiguration<?, ?> cc = defaultCacheConfiguration();

    cc.setCacheMode(mode);

    cc.setWriteSynchronizationMode(FULL_SYNC);

    cc.setNearConfiguration(null);

    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);

    c.setCacheConfiguration(cc);

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

    CacheConfiguration<?, ?> ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT);

    ccfg.setNearConfiguration(null);
    ccfg.setEvictionPolicy(null);

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);

    cfg.setCacheConfiguration(ccfg);

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

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setNearConfiguration(null);

    SortedEvictionPolicy plc = new SortedEvictionPolicy();
    plc.setMaxSize(MAX_SIZE);

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

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setCacheConfiguration(ccfg);

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

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(1);

    FifoEvictionPolicy plc = new FifoEvictionPolicy();
    plc.setMaxSize(10);

    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);

    NearCacheConfiguration nearCfg = new NearCacheConfiguration();

    FifoEvictionPolicy nearPlc = new FifoEvictionPolicy();
    nearPlc.setMaxSize(10);

    nearCfg.setNearEvictionPolicy(nearPlc);

    cacheCfg.setNearConfiguration(nearCfg);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}