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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setPartitionLossPolicy() . 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: IgniteLostPartitionsOnLeaveBaselineSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param name          Cache name.
 * @param cacheMode     Cache mode.
 * @param atomicityMode Atomicity mode.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(
    String name,
    CacheMode cacheMode,
    CacheAtomicityMode atomicityMode,
    String dataRegName
) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(0);
    ccfg.setCacheMode(cacheMode);
    ccfg.setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE);
    ccfg.setDataRegionName(dataRegName);

    return ccfg;
}
 
Example 2
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 3
Source File: IgniteCachePartitionMapUpdateTest.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 ccfg1 = new CacheConfiguration(CACHE1);

    ccfg1.setCacheMode(PARTITIONED);
    ccfg1.setBackups(1);
    ccfg1.setPartitionLossPolicy(policy());
    ccfg1.setNodeFilter(new AttributeFilter(CACHE1_ATTR));

    CacheConfiguration ccfg2 = new CacheConfiguration(CACHE2);

    ccfg2.setCacheMode(PARTITIONED);
    ccfg2.setPartitionLossPolicy(policy());
    ccfg2.setNodeFilter(new AttributeFilter(CACHE2_ATTR));

    List<CacheConfiguration> ccfgs = new ArrayList<>();

    Map<String, String> attrs = new HashMap<>();

    if (cache1)
        attrs.put(CACHE1_ATTR, "true");

    if (cache1 || startClientCache)
        ccfgs.add(ccfg1);

    if (cache2)
        attrs.put(CACHE2_ATTR, "true");

    if (cache2 || startClientCache)
        ccfgs.add(ccfg2);

    cfg.setUserAttributes(attrs);

    cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));

    return cfg;
}
 
Example 4
Source File: CacheJdbcPojoWriteBehindStoreWithCoalescingTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** */
public CacheConfiguration getCacheConfiguration() {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName("TEST_CACHE");

    ccfg.setCacheMode(REPLICATED);

    ccfg.setAtomicityMode(ATOMIC);

    ccfg.setPartitionLossPolicy(READ_WRITE_SAFE);

    ccfg.setReadThrough(true);

    ccfg.setWriteThrough(true);

    ccfg.setWriteBehindEnabled(true);

    ccfg.setWriteBehindBatchSize(1000);

    QueryEntity queryEntity = new QueryEntity();

    queryEntity.setKeyType("java.lang.Integer");

    queryEntity.setValueType("org.apache.ignite.cache.store.jdbc.model.TestPojo");

    queryEntity.setTableName("TEST_CACHE");

    queryEntity.setKeyFieldName("value3");

    Set<String> keyFiles = new HashSet<>();

    keyFiles.add("value3");

    queryEntity.setKeyFields(keyFiles);

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

    fields.put("value1", "java.lang.String");

    fields.put("value2", "java.lang.Integer");

    fields.put("value3", "java.sql.Date");

    queryEntity.setFields(fields);

    Map<String, String> aliases = new HashMap<>();

    aliases.put("value1", "VALUE1");

    aliases.put("value2", "VALUE2");

    aliases.put("value3", "VALUE3");

    queryEntity.setAliases(aliases);

    ArrayList<QueryEntity> queryEntities = new ArrayList<>();

    queryEntities.add(queryEntity);

    ccfg.setQueryEntities(queryEntities);

    return ccfg;
}