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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setCacheMode() . 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: GridCacheLeakTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Gets cache configuration.
 *
 * @return Data cache configuration.
 */
protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setName(CACHE_NAME);

    cfg.setAffinity(new RendezvousAffinityFunction(false, 128));

    cfg.setCacheMode(PARTITIONED);
    cfg.setBackups(1);
    cfg.setNearConfiguration(null);
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setAtomicityMode(atomicityMode);

    return cfg;
}
 
Example 2
Source File: IgniteCacheCrossCacheTxFailoverTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param name Cache name.
 * @param cacheMode Cache mode.
 * @param parts Number of partitions.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(@NotNull String name,
    CacheMode cacheMode,
    int parts) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(name);
    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

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

    ccfg.setAffinity(new RendezvousAffinityFunction(false, parts));

    return ccfg;
}
 
Example 3
Source File: GridCacheDhtMappingSelfTest.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.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setBackups(BACKUPS);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 4
Source File: GridCacheNearPartitionedClearSelfTest.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.setLocalHost("127.0.0.1");

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setNearConfiguration(new NearCacheConfiguration());
    ccfg.setRebalanceMode(SYNC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setBackups(BACKUP_CNT);
    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(ccfg);

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

    cfg.setCacheMode(PARTITIONED);
    cfg.setBackups(gridCount() - 1);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setAtomicityMode(TRANSACTIONAL);
    cfg.setNearConfiguration(new NearCacheConfiguration());

    // Setting preload mode to SYNC is necessary due to race condition with test scenario in ASYNC mode.
    // In ASYNC mode preloader can fetch value from previous test and update it before next test run.
    // As a result test will see previous value while it expects null
    cfg.setRebalanceMode(SYNC);

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

    cfg.setCacheMode(PARTITIONED);
    cfg.setBackups(gridCount() - 1);
    cfg.setRebalanceMode(SYNC);
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setNearConfiguration(null);

    return cfg;
}
 
Example 7
Source File: CacheStopAndDestroySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return near config
 */
private CacheConfiguration getNearConfig() {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setName(CACHE_NAME_NEAR);
    cfg.setCacheMode(PARTITIONED);
    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cfg.setNearConfiguration(new NearCacheConfiguration());

    return cfg;
}
 
Example 8
Source File: CacheGetEntryAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testLocalTransactional() throws Exception {
    CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setCacheMode(LOCAL);
    cfg.setAtomicityMode(TRANSACTIONAL);
    cfg.setName("localT");

    test(cfg);
}
 
Example 9
Source File: GridCacheNearMultiNodeSelfTest.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 {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setCacheStoreFactory(singletonFactory(store));
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setAffinity(aff);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(BACKUPS);
    cacheCfg.setNearConfiguration(new NearCacheConfiguration());

    cfg.setCacheConfiguration(cacheCfg);

    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));

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

    cfg.setCacheMode(PARTITIONED);
    cfg.setBackups(1);
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setIndexedTypes(Integer.class, H2TextValue.class);

    return cfg;
}
 
Example 11
Source File: GridCacheNearMultiGetSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration() {
    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(PARTITIONED);
    cc.setBackups(1);
    cc.setAtomicityMode(atomicityMode);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setRebalanceMode(NONE);
    cc.setNearConfiguration(new NearCacheConfiguration());

    return cc;
}
 
Example 12
Source File: JdbcBulkLoadSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param gridName Grid name.
 * @return Grid configuration used for starting the grid.
 * @throws Exception If failed.
 */
private IgniteConfiguration getConfiguration0(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

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

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Person.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
Example 13
Source File: HadoopSecondaryFileSystemConfigurationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Gets cache configuration.
 *
 * @return Meta cache configuration.
 */
protected CacheConfiguration metaCacheConfiguration() {

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName("replicated");
    ccfg.setCacheMode(REPLICATED);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAtomicityMode(TRANSACTIONAL);

    return ccfg;
}
 
Example 14
Source File: IgniteCacheBinaryEntryProcessorSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param atomicityMode Atomicity mode.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, TestValue> cacheConfiguration(CacheMode cacheMode, CacheAtomicityMode atomicityMode) {
    CacheConfiguration<Integer, TestValue> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(atomicityMode);

    ccfg.setBackups(1);

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

    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS);
    cfg.setFailoverSpi(failSpi);

    if (!igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT))) {
        // Default cache configuration.
        CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();

        dfltCacheCfg.setCacheMode(PARTITIONED);
        dfltCacheCfg.setBackups(1);
        dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);

        // Non-default cache configuration.
        CacheConfiguration namedCacheCfg = defaultCacheConfiguration();

        namedCacheCfg.setCacheMode(PARTITIONED);
        namedCacheCfg.setBackups(1);
        namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
        namedCacheCfg.setName(NON_DFLT_CACHE_NAME);

        cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg);
    }
    else {
        // No cache should be configured for extra node.
        cfg.setCacheConfiguration();
    }

    return cfg;
}
 
Example 16
Source File: CacheTxNotAllowReadFromBackupTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupConsistencyReplicatedFullSyncMvcc() throws Exception {
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");

    cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cfg.setCacheMode(CacheMode.REPLICATED);
    cfg.setReadFromBackup(false);

    checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);

    checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
 
Example 17
Source File: CacheGetEntryAbstractTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testNearTransactional() throws Exception {
    CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setCacheMode(PARTITIONED);
    cfg.setAtomicityMode(TRANSACTIONAL);
    cfg.setName("nearT");
    cfg.setNearConfiguration(new NearCacheConfiguration());

    test(cfg);
}
 
Example 18
Source File: GridCacheReplicatedPreloadSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Gets cache configuration for grid with specified name.
 *
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 */
CacheConfiguration cacheConfiguration(String igniteInstanceName) {
    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(REPLICATED);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setRebalanceMode(preloadMode);
    cacheCfg.setRebalanceBatchSize(batchSize);

    if (extClassloadingAtCfg)
        loadExternalClassesToCfg(cacheCfg);

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

    IgniteConfiguration cfg = super.getConfiguration();

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(disco);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(LOCAL);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 20
Source File: IgniteClientReconnectCacheTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testReconnectTransactionInProgress2() throws Exception {
    final IgniteEx client = startClientGrid(SRV_CNT);

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

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

    txInProgressFails(client, ccfg, GridNearTxPrepareResponse.class, OPTIMISTIC, 1);

    txInProgressFails(client, ccfg, GridNearTxPrepareResponse.class, PESSIMISTIC, 2);

    txInProgressFails(client, ccfg, GridNearTxFinishResponse.class, OPTIMISTIC, 3);

    txInProgressFails(client, ccfg, GridNearTxFinishResponse.class, PESSIMISTIC, 4);

    txInProgressFails(client, ccfg, GridNearLockResponse.class, PESSIMISTIC, 5);
}