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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setOnheapCacheEnabled() . 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: GridIndexingWithNoopSwapSelfTest.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<?,?> cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setRebalanceMode(SYNC);
    cc.setNearConfiguration(new NearCacheConfiguration());

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

    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);
    cc.setBackups(1);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setIndexedTypes(
        Integer.class, ObjectValue.class
    );

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 2
Source File: ClusterNodeMetricsSelfTest.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);

    cfg.setCacheConfiguration();
    cfg.setMetricsUpdateFrequency(500);

    CacheConfiguration<Integer, Object> ccfg = defaultCacheConfiguration();
    ccfg.setName(CACHE_NAME);
    ccfg.setStatisticsEnabled(true);

    FifoEvictionPolicy plc = new FifoEvictionPolicy();
    plc.setMaxMemorySize(MAX_VALS_AMOUNT * VAL_SIZE);
    plc.setMaxSize(0);

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

    return cfg.setCacheConfiguration(ccfg);
}
 
Example 3
Source File: TxRollbackOnTimeoutOnePhaseCommitTest.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);

    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    if (!igniteInstanceName.startsWith("client")) {
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

        ccfg.setAtomicityMode(TRANSACTIONAL);
        ccfg.setBackups(1);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setOnheapCacheEnabled(false);

        cfg.setCacheConfiguration(ccfg);
    }

    return cfg;
}
 
Example 4
Source File: GridCacheBinaryObjectsAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configuration with basic settings.
 */
@SuppressWarnings("unchecked")
private CacheConfiguration createCacheConfig() {
    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(cacheMode());
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setNearConfiguration(nearConfiguration());
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    cacheCfg.setBackups(1);
    cacheCfg.setOnheapCacheEnabled(false);

    return cacheCfg;
}
 
Example 5
Source File: IgniteCacheLoadRebalanceEvictionSelfTest.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);

    LruEvictionPolicy evictionPolicy = new LruEvictionPolicy<>();
    evictionPolicy.setMaxSize(LRU_MAX_SIZE);

    CacheConfiguration<String, byte[]> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setReadFromBackup(true);
    cacheCfg.setEvictionPolicy(evictionPolicy);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setStatisticsEnabled(true);

    cacheCfg.setWriteThrough(false);
    cacheCfg.setReadThrough(false);

    cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new Storage()));

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 6
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 7
Source File: IgniteCacheGroupsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param grpName Cache group name.
 * @param name Cache name.
 * @param cacheMode Cache mode.
 * @param atomicityMode Atomicity mode.
 * @param backups Backups number.
 * @param heapCache On heap cache flag.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(
    String grpName,
    String name,
    CacheMode cacheMode,
    CacheAtomicityMode atomicityMode,
    int backups,
    boolean heapCache
) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(grpName);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(backups);
    ccfg.setCacheMode(cacheMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setOnheapCacheEnabled(heapCache);

    return ccfg;
}
 
Example 8
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 9
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 10
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 11
Source File: GridCacheAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    if (storeStgy != null) {
        Factory<? extends CacheStore<Object, Object>> storeFactory = storeStgy.getStoreFactory();

        CacheStore<?, ?> store = storeFactory.create();

        if (store != null) {
            cfg.setCacheStoreFactory(storeFactory);
            cfg.setReadThrough(true);
            cfg.setWriteThrough(true);
            cfg.setLoadPreviousValue(true);
            storeStgy.updateCacheConfiguration(cfg);
        }
    }

    cfg.setCacheMode(cacheMode());
    cfg.setAtomicityMode(atomicityMode());
    cfg.setWriteSynchronizationMode(writeSynchronization());
    cfg.setNearConfiguration(nearConfiguration());
    cfg.setOnheapCacheEnabled(onheapCacheEnabled());

    Class<?>[] idxTypes = indexedTypes();

    if (!F.isEmpty(idxTypes))
        cfg.setIndexedTypes(idxTypes);

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

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

    AtomicConfiguration atomicCfg = new AtomicConfiguration();

    atomicCfg.setCacheMode(PARTITIONED);
    atomicCfg.setBackups(1);
    atomicCfg.setAtomicSequenceReserveSize(10);

    c.setAtomicConfiguration(atomicCfg);

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

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setRebalanceMode(CacheRebalanceMode.SYNC);
    cc.setWriteSynchronizationMode(FULL_SYNC);

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

    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);
    cc.setBackups(1);
    cc.setAffinity(new RendezvousAffinityFunction(true));

    c.setCacheConfiguration(cc);

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

    TransactionConfiguration txCfg = c.getTransactionConfiguration();

    txCfg.setDefaultTxConcurrency(txConcurrency);
    txCfg.setDefaultTxIsolation(txIsolation);
    txCfg.setTxSerializableEnabled(true);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setAtomicityMode(TRANSACTIONAL);

    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

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

    if (testStore != null) {
        cc.setCacheStoreFactory(singletonFactory(testStore));
        cc.setReadThrough(true);
        cc.setWriteThrough(true);
        cc.setLoadPreviousValue(true);
    }
    else
        cc.setCacheStoreFactory(null);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 14
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 15
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 16
Source File: GridCachePartitionedEvictionSelfTest.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().setTxSerializableEnabled(true);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setWriteSynchronizationMode(FULL_SYNC);

    FifoEvictionPolicy plc = new FifoEvictionPolicy();
    plc.setMaxSize(EVICT_CACHE_SIZE);
    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);

    FifoEvictionPolicy nearPlc = new FifoEvictionPolicy();
    nearPlc.setMaxSize(EVICT_CACHE_SIZE);
    cc.getNearConfiguration().setNearEvictionPolicy(nearPlc);

    // We set 1 backup explicitly.
    cc.setBackups(1);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 17
Source File: TxCrossCachePartitionConsistencyTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param name Name.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(String name, int backups) {
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(name);

    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setBackups(backups);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setOnheapCacheEnabled(false);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));

    return ccfg;
}
 
Example 18
Source File: TxPartitionCounterStateAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param name Name.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(String name) {
    CacheConfiguration ccfg = new CacheConfiguration(name);

    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setBackups(backups);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setOnheapCacheEnabled(false);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, partitions()));

    return ccfg;
}
 
Example 19
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 20
Source File: IgfsCachePerBlockLruEvictionPolicySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start a grid with the primary file system.
 *
 * @throws Exception If failed.
 */
private void startPrimary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_PRIMARY);
    igfsCfg.setBlockSize(512);
    igfsCfg.setDefaultMode(DUAL_SYNC);
    igfsCfg.setPrefetchBlocks(1);
    igfsCfg.setSequentialReadsBeforePrefetch(Integer.MAX_VALUE);
    igfsCfg.setSecondaryFileSystem(secondaryFs.asSecondary());

    Map<String, IgfsMode> pathModes = new HashMap<>();

    pathModes.put(FILE.toString(), PRIMARY);

    igfsCfg.setPathModes(pathModes);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    evictPlc = new IgfsPerBlockLruEvictionPolicy();

    dataCacheCfg.setEvictionPolicy(evictPlc);
    dataCacheCfg.setOnheapCacheEnabled(true);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setNearConfiguration(null);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("grid-primary");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

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

    Ignite g = G.start(cfg);

    igfsPrimary = (IgfsImpl)g.fileSystem(IGFS_PRIMARY);

    dataCache = igfsPrimary.context().kernalContext().cache().internalCache(
        igfsPrimary.context().configuration().getDataCacheConfiguration().getName());
}