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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setWriteSynchronizationMode() . 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: CacheKeepBinaryIterationTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param backups Number of backups.
 * @param atomicityMode Cache atomicity mode.
 * @return Cache configuration.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(
    CacheMode cacheMode,
    int backups,
    CacheAtomicityMode atomicityMode) {
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

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

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

    return ccfg;
}
 
Example 2
Source File: GridCacheGetAndTransformStoreAbstractTest.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 {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(atomicityMode());
    cc.setRebalanceMode(SYNC);

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

    c.setCacheConfiguration(cc);

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

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

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

    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(TestObject.class.getName());
    entity.addQueryField("parentId", Integer.class.getName(), null);
    entity.setIndexes(F.asList(new QueryIndex("parentId")));

    ccfg.setQueryEntities(F.asList(entity));

    return ccfg;
}
 
Example 4
Source File: GridCacheBasicStoreAbstractTest.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 {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setAtomicityMode(atomicityMode());
    cc.setRebalanceMode(SYNC);

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

    c.setCacheConfiguration(cc);

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

    final CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(CACHE_NAME);

    assertNotNull(interceptor);

    ccfg.setInterceptor(interceptor);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setBackups(2);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 6
Source File: GridCacheCrossCacheQuerySelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Creates new cache configuration.
 *
 * @param name Cache name.
 * @param mode Cache mode.
 * @param clsK Key class.
 * @param clsV Value class.
 * @return Cache configuration.
 */
private static CacheConfiguration createCache(String name, CacheMode mode, Class<?> clsK, Class<?> clsV) {
    CacheConfiguration<?,?> cc = defaultCacheConfiguration();

    cc.setName(name);
    cc.setCacheMode(mode);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setRebalanceMode(SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setIndexedTypes(clsK, clsV);

    if ((mode != CacheMode.PARTITIONED) && (mode != CacheMode.REPLICATED))
        throw new IllegalStateException("mode: " + mode);

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

    cfg.setActiveOnStart(false);

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg.setBackups(2);

    cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(200L * 1024 * 1024).setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY)
        .setCheckpointFrequency(CHECKPOINT_FREQUENCY);

    cfg.setDataStorageConfiguration(memCfg);

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

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

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

    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setCacheMode(REPLICATED);
    cfg.setAtomicityMode(ATOMIC);
    cfg.setName("replicated");

    test(cfg);
}
 
Example 10
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Gets cache configuration.
 *
 * @param gridName Grid name.
 * @return Cache configuration.
 */
protected CacheConfiguration metaCacheConfiguration(String gridName) {
    CacheConfiguration ccfg = defaultCacheConfiguration();

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

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

    cfg.setConsistentId(gridName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
        .setPageSize(1024)
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(memCfg);

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

    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg.setRebalanceMode(ASYNC);
    ccfg.setCacheMode(REPLICATED);

    cfg.setCacheConfiguration(ccfg);

    cfg.setIndexingSpi(new ErrorOnRebalanceIndexingSpi());

    return cfg;
}
 
Example 12
Source File: IgniteTxConsistencyRestartAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 */
public CacheConfiguration cacheConfiguration(String igniteInstanceName) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setCacheMode(cacheMode());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setNearConfiguration(nearConfiguration());
    ccfg.setRebalanceMode(SYNC);

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

    return ccfg;
}
 
Example 13
Source File: TxMultiCacheAsyncOpsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param idx Index.
 */
private CacheConfiguration cacheConfiguration(int idx) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + idx);

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

    return ccfg;
}
 
Example 14
Source File: IgniteCacheClientNodeChangingTopologyTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration.
 */
private CacheConfiguration testPessimisticTx3Cfg() {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(0);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 16));

    return ccfg;
}
 
Example 15
Source File: DataStreamerUpdateAfterLoadTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param atomicityMode Cache atomicity mode.
 * @param backups Number of backups.
 * @param name Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, Integer> cacheConfiguration(CacheAtomicityMode atomicityMode,
    int backups,
    @NotNull String name) {
    CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setName(name);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(backups);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    return ccfg;
}
 
Example 16
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param regionName Region name.
 * @return Transactional Cache configuration
 */
protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
    CacheConfiguration cfg = new CacheConfiguration();

    cfg.setName(regionName);

    cfg.setCacheMode(PARTITIONED);

    cfg.setAtomicityMode(TRANSACTIONAL);

    cfg.setWriteSynchronizationMode(FULL_SYNC);

    cfg.setBackups(1);

    cfg.setStatisticsEnabled(true);

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

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

    DataStorageConfiguration memCfg = new DataStorageConfiguration();

    memCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
        .setMaxSize(10L * 1024 * 1024 + 1));

    cfg.setDataStorageConfiguration(memCfg);

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

    baseCfg.setAtomicityMode(this.atomicityMode);
    baseCfg.setCacheMode(this.mode);
    baseCfg.setBackups(this.backupsCnt);
    baseCfg.setWriteSynchronizationMode(this.writeSyncMode);

    cfg.setCacheConfiguration(baseCfg);

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

    cfg.setPeerClassLoadingEnabled(true);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(REPLICATED);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

    cfg.setCacheConfiguration(cacheCfg);

    MessageCountingCommunicationSpi commSpi = new MessageCountingCommunicationSpi();

    commSpis.put(igniteInstanceName, commSpi);

    cfg.setCommunicationSpi(commSpi);

    return cfg;
}
 
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: IgniteSemaphoreAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Implementation of ignite data structures internally uses special system caches, need make sure
 * that transaction on these system caches do not intersect with transactions started by user.
 *
 * @throws Exception If failed.
 */
@Test
public void testIsolation() throws Exception {
    Ignite ignite = grid(0);

    CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cfg.setName("myCache");
    cfg.setAtomicityMode(TRANSACTIONAL);
    cfg.setWriteSynchronizationMode(FULL_SYNC);

    IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cfg);

    try {
        IgniteSemaphore semaphore = ignite.semaphore("testIsolation", 1, true, true);

        assertNotNull(semaphore);

        try (Transaction tx = ignite.transactions().txStart()) {
            cache.put(1, 1);

            assertEquals(1, semaphore.availablePermits());

            semaphore.acquire();

            tx.rollback();
        }

        assertEquals(0, cache.size());

        assertEquals(0, semaphore.availablePermits());

        semaphore.close();

        assertTrue(semaphore.removed());
    }
    finally {
        ignite.destroyCache(cfg.getName());
    }
}