Search in sources :

Example 11 with RendezvousAffinityFunction

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

the class GridCacheClientModesAbstractSelfTest method cacheConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);
    cfg.setCacheStoreFactory(null);
    cfg.setReadThrough(false);
    cfg.setWriteThrough(false);
    cfg.setBackups(1);
    if (cfg.getCacheMode() == REPLICATED)
        cfg.setAffinity(null);
    else
        cfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    return cfg;
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 12 with RendezvousAffinityFunction

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

the class GridCachePartitionedTxSalvageSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    // Discovery.
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(PARTITIONED);
    cc.setAffinity(new RendezvousAffinityFunction(false, 18));
    cc.setBackups(1);
    cc.setRebalanceMode(SYNC);
    c.setCacheConfiguration(cc);
    return c;
}
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 13 with RendezvousAffinityFunction

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

the class GridCachePartitionedOptimisticTxNodeRestartTest method cacheConfiguration.

/** {@inheritDoc} */
@Override
protected CacheConfiguration cacheConfiguration() {
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setName(CACHE_NAME);
    cc.setCacheMode(PARTITIONED);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setRebalanceMode(rebalancMode);
    cc.setRebalanceBatchSize(rebalancBatchSize);
    cc.setAffinity(new RendezvousAffinityFunction(false, partitions));
    cc.setBackups(backups);
    cc.setNearConfiguration(nearEnabled() ? new NearCacheConfiguration() : null);
    return cc;
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 14 with RendezvousAffinityFunction

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

the class IgniteDbAbstractTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    MemoryConfiguration dbCfg = new MemoryConfiguration();
    dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
    if (isLargePage())
        dbCfg.setPageSize(16 * 1024);
    else
        dbCfg.setPageSize(1024);
    configure(dbCfg);
    cfg.setMemoryConfiguration(dbCfg);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    if (indexingEnabled())
        ccfg.setIndexedTypes(Integer.class, DbValue.class);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    CacheConfiguration ccfg2 = new CacheConfiguration("non-primitive");
    if (indexingEnabled())
        ccfg2.setIndexedTypes(DbKey.class, DbValue.class);
    ccfg2.setAtomicityMode(TRANSACTIONAL);
    ccfg2.setWriteSynchronizationMode(FULL_SYNC);
    ccfg2.setRebalanceMode(SYNC);
    ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
    CacheConfiguration ccfg3 = new CacheConfiguration("large");
    if (indexingEnabled())
        ccfg3.setIndexedTypes(Integer.class, LargeDbValue.class);
    ccfg3.setAtomicityMode(TRANSACTIONAL);
    ccfg3.setWriteSynchronizationMode(FULL_SYNC);
    ccfg3.setRebalanceMode(SYNC);
    ccfg3.setAffinity(new RendezvousAffinityFunction(false, 32));
    CacheConfiguration ccfg4 = new CacheConfiguration("tiny");
    ccfg4.setAtomicityMode(TRANSACTIONAL);
    ccfg4.setWriteSynchronizationMode(FULL_SYNC);
    ccfg4.setRebalanceMode(SYNC);
    ccfg4.setAffinity(new RendezvousAffinityFunction(1, null));
    CacheConfiguration ccfg5 = new CacheConfiguration("atomic");
    if (indexingEnabled())
        ccfg5.setIndexedTypes(DbKey.class, DbValue.class);
    ccfg5.setAtomicityMode(ATOMIC);
    ccfg5.setWriteSynchronizationMode(FULL_SYNC);
    ccfg5.setRebalanceMode(SYNC);
    ccfg5.setAffinity(new RendezvousAffinityFunction(false, 32));
    cfg.setCacheConfiguration(ccfg, ccfg2, ccfg3, ccfg4, ccfg5);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(discoSpi);
    cfg.setMarshaller(null);
    configure(cfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) MemoryConfiguration(org.apache.ignite.configuration.MemoryConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 15 with RendezvousAffinityFunction

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

the class IgniteDbDynamicCacheSelfTest method testMultipleDynamicCaches.

/**
     * @throws Exception If failed.
     */
public void testMultipleDynamicCaches() throws Exception {
    int caches = 10;
    int entries = 10;
    startGrids(1);
    Ignite ignite = ignite(0);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg.setIndexedTypes(Integer.class, String.class);
    long finishTime = U.currentTimeMillis() + 20_000;
    int iteration = 0;
    while (U.currentTimeMillis() < finishTime) {
        System.out.println("Iteration: " + iteration);
        for (int i = 0; i < caches; i++) {
            ccfg.setName("cache" + i);
            IgniteCache cache = ignite.createCache(ccfg);
            for (int j = 0; j < entries; j++) cache.put(j, "val " + j);
            ignite.destroyCache("cache" + i);
        }
        iteration++;
    }
}
Also used : IgniteCache(org.apache.ignite.IgniteCache) Ignite(org.apache.ignite.Ignite) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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