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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#getBackups() . 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: VisorCacheAffinityConfiguration.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Create data transfer object for affinity configuration properties.
 *
 * @param ccfg Cache configuration.
 */
public VisorCacheAffinityConfiguration(CacheConfiguration ccfg) {
    AffinityFunction aff = ccfg.getAffinity();

    function = compactClass(aff);
    mapper = compactClass(ccfg.getAffinityMapper());
    partitions = aff.partitions();
    partitionedBackups = ccfg.getBackups();

    Method mthd = findNonPublicMethod(aff.getClass(), "isExcludeNeighbors");

    if (mthd != null) {
        try {
            exclNeighbors = (Boolean)mthd.invoke(aff);
        }
        catch (InvocationTargetException | IllegalAccessException ignored) {
            //  No-op.
        }
    }
}
 
Example 2
Source File: CacheSerializableTransactionsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (!cache.unwrap(Ignite.class).configuration().isClientMode()) {
        if (ccfg.getCacheMode() == PARTITIONED)
            keys.add(nearKey(cache));

        keys.add(primaryKey(cache));

        if (ccfg.getBackups() != 0)
            keys.add(backupKey(cache));
    }
    else
        keys.add(nearKey(cache));

    return keys;
}
 
Example 3
Source File: CacheOptimisticTransactionsWithFilterTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (!cache.unwrap(Ignite.class).configuration().isClientMode()) {
        if (ccfg.getCacheMode() == PARTITIONED && serversNumber() > 1)
            keys.add(nearKey(cache));

        keys.add(primaryKey(cache));

        if (ccfg.getBackups() != 0 && serversNumber() > 1)
            keys.add(backupKey(cache));
    }
    else
        keys.add(nearKey(cache));

    return keys;
}
 
Example 4
Source File: CacheGetRemoveSkipStoreTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if failed.
 */
private void checkNoNullReads(Ignite client, CacheConfiguration<Integer, Integer> ccfg) throws Exception {
    client.getOrCreateCache(ccfg);

    try {
        checkNoNullReads(client.cache(ccfg.getName()), 0);
        checkNoNullReads(grid(0).cache(ccfg.getName()), primaryKey(grid(0).cache(ccfg.getName())));

        if (ccfg.getBackups() > 0)
            checkNoNullReads(grid(0).cache(ccfg.getName()), backupKey(grid(0).cache(ccfg.getName())));
    }
    finally {
        client.destroyCache(ccfg.getName());
    }
}
 
Example 5
Source File: CacheMvccTransactionsTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param cache Cache.
 * @return Test keys.
 * @throws Exception If failed.
 */
private List<Integer> testKeys(IgniteCache<Integer, Integer> cache) throws Exception {
    CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);

    List<Integer> keys = new ArrayList<>();

    if (ccfg.getCacheMode() == PARTITIONED)
        keys.add(nearKey(cache));

    keys.add(primaryKey(cache));

    if (ccfg.getBackups() != 0)
        keys.add(backupKey(cache));

    return keys;
}