Search in sources :

Example 6 with RendezvousAffinityFunction

use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.

the class IgniteCacheReadThroughStoreCallTest method cacheConfiguration.

/**
     * @param cacheMode Cache mode.
     * @param atomicityMode Atomicity mode.
     * @param backups Number of backups.
     * @return Cache configuration.
     */
@SuppressWarnings("unchecked")
protected CacheConfiguration<Object, Object> cacheConfiguration(CacheMode cacheMode, CacheAtomicityMode atomicityMode, int backups) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setCacheStoreFactory(new TestStoreFactory());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setCacheMode(cacheMode);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    if (cacheMode == PARTITIONED)
        ccfg.setBackups(backups);
    return ccfg;
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 7 with RendezvousAffinityFunction

use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.

the class IgniteClientAffinityAssignmentSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    if (cache) {
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setCacheMode(CacheMode.PARTITIONED);
        ccfg.setBackups(1);
        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        ccfg.setNearConfiguration(null);
        ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
        cfg.setCacheConfiguration(ccfg);
    } else
        cfg.setClientMode(true);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 8 with RendezvousAffinityFunction

use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.

the class IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest method createCache.

/**
     * @param cacheName Cache name.
     * @param mode Atomicity mode.
     * @throws Exception If failed.
     */
private void createCache(String cacheName, CacheAtomicityMode mode) throws Exception {
    CacheConfiguration ccfg = cacheConfiguration(grid(0).name());
    ccfg.setName(cacheName);
    ccfg.setAtomicityMode(mode);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));
    grid(0).createCache(ccfg);
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 9 with RendezvousAffinityFunction

use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.

the class AffinityHistoryCleanupTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    CacheConfiguration[] ccfgs = new CacheConfiguration[4];
    for (int i = 0; i < ccfgs.length; i++) {
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setName("static-cache-" + i);
        ccfg.setAffinity(new RendezvousAffinityFunction());
        ccfgs[i] = ccfg;
    }
    cfg.setCacheConfiguration(ccfgs);
    cfg.setClientMode(client);
    cfg.setLateAffinityAssignment(lateAffAssignment);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 10 with RendezvousAffinityFunction

use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.

the class LocalAffinityFunctionTest method getConfiguration.

@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setBackups(1);
    ccfg.setName(CACHE1);
    ccfg.setCacheMode(CacheMode.LOCAL);
    ccfg.setAffinity(new RendezvousAffinityFunction());
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)73 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)64 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)35 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)34 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)8 AffinityFunction (org.apache.ignite.cache.affinity.AffinityFunction)7 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 Ignite (org.apache.ignite.Ignite)2 IgniteCache (org.apache.ignite.IgniteCache)2 QueryEntity (org.apache.ignite.cache.QueryEntity)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 MemoryConfiguration (org.apache.ignite.configuration.MemoryConfiguration)2 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)2 PlatformAffinityFunction (org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction)2 PlatformDotNetAffinityFunction (org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)2 TestTcpCommunicationSpi (org.apache.ignite.util.TestTcpCommunicationSpi)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CacheLoader (javax.cache.integration.CacheLoader)1