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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setRebalanceMode() . 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: GridCacheAbstractUsersAffinityMapperSelfTest.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 = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(getCacheMode());
    cacheCfg.setAtomicityMode(getAtomicMode());
    cacheCfg.setNearConfiguration(nearConfiguration());
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAffinityMapper(AFFINITY_MAPPER);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 2
Source File: GridCachePreloadingEvictionsSelfTest.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 partCacheCfg = defaultCacheConfiguration();

    partCacheCfg.setCacheMode(PARTITIONED);
    partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(1, 1));
    partCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    partCacheCfg.setNearConfiguration(null);
    partCacheCfg.setEvictionPolicy(null);
    partCacheCfg.setRebalanceMode(ASYNC);
    partCacheCfg.setAtomicityMode(TRANSACTIONAL);

    // This test requires artificial slowing down of the preloading.
    partCacheCfg.setRebalanceThrottle(2000);

    cfg.setCacheConfiguration(partCacheCfg);

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

    cfg.setNetworkTimeout(60000);

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

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<Integer, TestObject> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    cacheCfg.setCacheStoreFactory(new StoreFactory());
    cacheCfg.setReadThrough(true);
    cacheCfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 4
Source File: GridCacheDhtPreloadUnloadSelfTest.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.setRebalanceBatchSize(preloadBatchSize);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setRebalanceMode(preloadMode);
    cc.setAffinity(new RendezvousAffinityFunction(false, partitions));
    cc.setBackups(backups);
    cc.setAtomicityMode(TRANSACTIONAL);

    if (lbean != null)
        c.setLifecycleBeans(lbean);

    c.setCacheConfiguration(cc);
    c.setDeploymentMode(CONTINUOUS);
    c.setNetworkTimeout(netTimeout);

    return c;
}
 
Example 5
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 6
Source File: GridCacheAtomicNearCacheSelfTest.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(PARTITIONED);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setNearConfiguration(new NearCacheConfiguration());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setBackups(backups);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 7
Source File: GridCacheNearEvictionSelfTest.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(FULL_SYNC);
    cc.setBackups(1);
    cc.setRebalanceMode(SYNC);
    cc.setAtomicityMode(atomicityMode());

    NearCacheConfiguration nearCfg = new NearCacheConfiguration();

    cc.setNearConfiguration(nearCfg);

    c.setCacheConfiguration(cc);

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

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setBackups(BACKUPS);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 9
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 10
Source File: DataStructuresProcessor.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cfg Atomic configuration.
 * @param name Cache name.
 * @param grpName Group name.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(AtomicConfiguration cfg, String name, String grpName) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(grpName);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setCacheMode(cfg.getCacheMode());
    ccfg.setNodeFilter(CacheConfiguration.ALL_NODES);
    ccfg.setAffinity(cfg.getAffinity());

    if (cfg.getCacheMode() == PARTITIONED)
        ccfg.setBackups(cfg.getBackups());

    return ccfg;
}
 
Example 11
Source File: GridCachePartitionedNodeRestartTxSelfTest.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(FULL_SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setBackups(1);

    cfg.setCacheConfiguration(cacheCfg);

    AtomicConfiguration atomicCfg = new AtomicConfiguration();

    atomicCfg.setCacheMode(PARTITIONED);
    atomicCfg.setGroupName("testGroup");
    atomicCfg.setBackups(1);

    cfg.setAtomicConfiguration(atomicCfg);

    return cfg;
}
 
Example 12
Source File: ClusterStateTestUtils.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheName Cache name.
 * @return Replicated cache configuration.
 */
public static CacheConfiguration replicatedCache(String cacheName) {
    CacheConfiguration ccfg = new CacheConfiguration(cacheName);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setCacheMode(CacheMode.REPLICATED);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);

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

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setRebalanceBatchSize(preloadBatchSize);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setRebalanceMode(preloadMode);
    cacheCfg.setAffinity(new RendezvousAffinityFunction(false, partitions));
    cacheCfg.setBackups(backups);
    cacheCfg.setOnheapCacheEnabled(onheapCacheEnabled());

    return cacheCfg;
}
 
Example 14
Source File: GridCacheRebalancingOrderingTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Cache configuration used by test.
 * @see #getConfiguration().
 */
protected CacheConfiguration<IntegerKey, Integer> getCacheConfiguration() {
    CacheConfiguration<IntegerKey, Integer> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cfg.setAtomicityMode(TRANSACTIONAL ? CacheAtomicityMode.TRANSACTIONAL : CacheAtomicityMode.ATOMIC);
    cfg.setCacheMode(CacheMode.PARTITIONED);
    cfg.setName(TEST_CACHE_NAME);
    cfg.setAffinity(new RendezvousAffinityFunction(true /* machine-safe */, 271));
    cfg.setBackups(1);
    cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    cfg.setWriteSynchronizationMode(FULL_SYNC);

    return cfg;
}
 
Example 15
Source File: IgniteCacheNearRestartRollbackSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 */
protected CacheConfiguration<Object, Object> cacheConfiguration(String igniteInstanceName) {
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    ccfg.setBackups(1);

    ccfg.setNearConfiguration(new NearCacheConfiguration<>());

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);

    return ccfg;
}
 
Example 16
Source File: GridCacheNearReadersSelfTest.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 cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setRebalanceMode(NONE);

    cacheCfg.setAffinity(aff);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(aff.backups());

    NearCacheConfiguration nearCfg = new NearCacheConfiguration();

    cacheCfg.setNearConfiguration(nearCfg);

    cfg.setCacheConfiguration(cacheCfg);

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

    return cfg;
}
 
Example 17
Source File: GridCacheP2PUndeploySelfTest.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.setNetworkTimeout(2000);

        cfg.setMarshaller(new JdkMarshaller());

        CacheConfiguration repCacheCfg = defaultCacheConfiguration();

        repCacheCfg.setName("replicated");
        repCacheCfg.setCacheMode(REPLICATED);
        repCacheCfg.setRebalanceMode(mode);
        repCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        repCacheCfg.setAtomicityMode(TRANSACTIONAL);

        // TODO GG-10884.
//        if (offheap)
//            repCacheCfg.setOffHeapMaxMemory(OFFHEAP);
//        else
//            repCacheCfg.setSwapEnabled(true);

        CacheConfiguration partCacheCfg = defaultCacheConfiguration();

        partCacheCfg.setName("partitioned");
        partCacheCfg.setCacheMode(PARTITIONED);
        partCacheCfg.setRebalanceMode(mode);
        partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(11, 1));
        partCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        partCacheCfg.setAtomicityMode(TRANSACTIONAL);

        // TODO GG-10884.
//        if (offheap)
//            partCacheCfg.setOffHeapMaxMemory(OFFHEAP);
//        else
//            partCacheCfg.setSwapEnabled(true);

        cfg.setCacheConfiguration(repCacheCfg, partCacheCfg);

        cfg.setDeploymentMode(SHARED);
        cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheP2PUndeploySelfTest.class.getName());

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

        return cfg;
    }
 
Example 18
Source File: IgniteCacheFullTextQueryNodeJoiningSelfTest.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 cache = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cache.setCacheMode(PARTITIONED);
    cache.setAtomicityMode(atomicityMode());
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setBackups(1);
    cache.setRebalanceMode(CacheRebalanceMode.SYNC);

    QueryEntity qryEntity = new QueryEntity();

    qryEntity.setKeyType(AffinityKey.class.getName());
    qryEntity.setValueType(IndexedEntity.class.getName());

    LinkedHashMap<String, String> fields = new LinkedHashMap<>();

    fields.put("val", String.class.getName());

    qryEntity.setFields(fields);

    qryEntity.setIndexes(Arrays.asList(new QueryIndex("val", QueryIndexType.FULLTEXT)));

    cache.setQueryEntities(Arrays.asList(qryEntity));

    cfg.setCacheConfiguration(cache);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setSharedMemoryPort(-1);

    cfg.setCommunicationSpi(commSpi);

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

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY)
        .setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);

    cfg.setDataStorageConfiguration(memCfg);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);

    ccfg.setIndexedTypes(Integer.class, DbValue.class);

    ccfg.setRebalanceMode(CacheRebalanceMode.NONE);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

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

    cfg.setCacheConfiguration(ccfg);

    cfg.setMarshaller(null);

    BinaryConfiguration bCfg = new BinaryConfiguration();

    bCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(bCfg);

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

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

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
    ccfg.setIndexedTypes(Integer.class, IndexedValue.class);

    if (extraCcfg != null)
        cfg.setCacheConfiguration(ccfg, new CacheConfiguration<>(extraCcfg));
    else
        cfg.setCacheConfiguration(ccfg);

    DataStorageConfiguration dbCfg = new DataStorageConfiguration();

    dbCfg.setPageSize(pageSize);

    dbCfg.setWalHistorySize(WAL_HIST_SIZE);

    dbCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
        .setMaxSize(100L * 1024 * 1024)
        .setPersistenceEnabled(true));

    if (checkpointFreq != null)
        dbCfg.setCheckpointFrequency(checkpointFreq);

    cfg.setDataStorageConfiguration(dbCfg);

    cfg.setMarshaller(null);

    BinaryConfiguration binCfg = new BinaryConfiguration();

    binCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(binCfg);

    return cfg;
}