Search in sources :

Example 26 with RendezvousAffinityFunction

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

the class GridCacheRendezvousAffinityClientSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setForceServerMode(true);
    CacheConfiguration ccfg = defaultCacheConfiguration();
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setAffinity(new RendezvousAffinityFunction());
    if (client)
        cfg.setClientMode(true);
    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)

Example 27 with RendezvousAffinityFunction

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

the class IgniteCacheConfigurationTemplateTest method testTemplateCleanup.

/**
     * @throws Exception If failed.
     */
public void testTemplateCleanup() throws Exception {
    startGridsMultiThreaded(3);
    try {
        CacheConfiguration ccfg = new CacheConfiguration("affTemplate-*");
        ccfg.setAffinity(new RendezvousAffinityFunction());
        ignite(0).addCacheConfiguration(ccfg);
        ignite(0).getOrCreateCache("affTemplate-1");
        IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache("affTemplate-2");
        ignite(0).destroyCache("affTemplate-1");
        startGrid(3);
        cache.put(1, 1);
        assertEquals(1, cache.get(1));
    } finally {
        stopAllGrids();
    }
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 28 with RendezvousAffinityFunction

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

the class HibernateL2CacheSelfTest method generalRegionConfiguration.

/**
     * @param regionName Region name.
     * @return Cache configuration for {@link GeneralDataRegion}.
     */
private CacheConfiguration generalRegionConfiguration(String regionName) {
    CacheConfiguration cfg = new CacheConfiguration();
    cfg.setName(regionName);
    cfg.setCacheMode(PARTITIONED);
    cfg.setAtomicityMode(ATOMIC);
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    cfg.setBackups(1);
    cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
    return cfg;
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 29 with RendezvousAffinityFunction

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

the class GridCacheConfigurationValidationSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(spi);
    // Default cache config.
    CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();
    dfltCacheCfg.setCacheMode(PARTITIONED);
    dfltCacheCfg.setRebalanceMode(ASYNC);
    dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    dfltCacheCfg.setAffinity(new RendezvousAffinityFunction());
    dfltCacheCfg.setIndexedTypes(Integer.class, String.class);
    // Non-default cache configuration.
    CacheConfiguration namedCacheCfg = defaultCacheConfiguration();
    namedCacheCfg.setCacheMode(PARTITIONED);
    namedCacheCfg.setRebalanceMode(ASYNC);
    namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
    namedCacheCfg.setAffinity(new RendezvousAffinityFunction());
    // Modify cache config according to test parameters.
    if (igniteInstanceName.contains(WRONG_PRELOAD_MODE_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setRebalanceMode(SYNC);
    else if (igniteInstanceName.contains(WRONG_CACHE_MODE_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setCacheMode(REPLICATED);
    else if (igniteInstanceName.contains(WRONG_AFFINITY_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setAffinity(new TestRendezvousAffinityFunction());
    else if (igniteInstanceName.contains(WRONG_AFFINITY_MAPPER_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setAffinityMapper(new TestCacheDefaultAffinityKeyMapper());
    if (igniteInstanceName.contains(DUP_CACHES_IGNITE_INSTANCE_NAME))
        cfg.setCacheConfiguration(namedCacheCfg, namedCacheCfg);
    else if (igniteInstanceName.contains(DUP_DFLT_CACHES_IGNITE_INSTANCE_NAME))
        cfg.setCacheConfiguration(dfltCacheCfg, dfltCacheCfg);
    else
        // Normal configuration.
        cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg);
    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 30 with RendezvousAffinityFunction

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

the class GridCacheConfigurationConsistencySelfTest method testAffinityForReplicatedCache.

/**
     * @throws Exception If failed.
     */
public void testAffinityForReplicatedCache() throws Exception {
    cacheEnabled = true;
    aff = new RendezvousAffinityFunction(false, 100);
    startGrid(1);
    // Try to start node with  different number of partitions.
    aff = new RendezvousAffinityFunction(false, 200);
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return startGrid(2);
        }
    }, IgniteCheckedException.class, "Affinity partitions count mismatch");
}
Also used : RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

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