Search in sources :

Example 1 with GridCacheModuloAffinityFunction

use of org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction in project ignite by apache.

the class GridCachePartitionedStorePutSelfTest method cacheConfiguration.

/**
 * @return Cache configuration.
 */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfiguration() {
    CacheConfiguration cfg = defaultCacheConfiguration();
    cfg.setCacheMode(PARTITIONED);
    cfg.setCacheStoreFactory(singletonFactory(new TestStore()));
    cfg.setReadThrough(true);
    cfg.setWriteThrough(true);
    cfg.setLoadPreviousValue(true);
    cfg.setAffinity(new GridCacheModuloAffinityFunction(3, 1));
    cfg.setWriteSynchronizationMode(FULL_SYNC);
    return cfg;
}
Also used : GridCacheModuloAffinityFunction(org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with GridCacheModuloAffinityFunction

use of org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction in project ignite by apache.

the class GridCacheP2PUndeploySelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setNetworkTimeout(2000);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(spi);
    cfg.setMarshaller(new JdkMarshaller());
    CacheConfiguration repCacheCfg = defaultCacheConfiguration();
    repCacheCfg.setName("replicated");
    repCacheCfg.setCacheMode(REPLICATED);
    repCacheCfg.setRebalanceMode(mode);
    repCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    repCacheCfg.setAtomicityMode(TRANSACTIONAL);
    // TODO GG-10884.
    // if (offheap)
    // repCacheCfg.setOffHeapMaxMemory(OFFHEAP);
    // else
    // repCacheCfg.setSwapEnabled(true);
    CacheConfiguration partCacheCfg = defaultCacheConfiguration();
    partCacheCfg.setName("partitioned");
    partCacheCfg.setCacheMode(PARTITIONED);
    partCacheCfg.setRebalanceMode(mode);
    partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(11, 1));
    partCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    partCacheCfg.setAtomicityMode(TRANSACTIONAL);
    // TODO GG-10884.
    // if (offheap)
    // partCacheCfg.setOffHeapMaxMemory(OFFHEAP);
    // else
    // partCacheCfg.setSwapEnabled(true);
    cfg.setCacheConfiguration(repCacheCfg, partCacheCfg);
    cfg.setDeploymentMode(SHARED);
    cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheP2PUndeploySelfTest.class.getName());
    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement()));
    return cfg;
}
Also used : GridCacheModuloAffinityFunction(org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with GridCacheModuloAffinityFunction

use of org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction in project ignite by apache.

the class GridCachePreloadingEvictionsSelfTest 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);
    CacheConfiguration partCacheCfg = defaultCacheConfiguration();
    partCacheCfg.setCacheMode(PARTITIONED);
    partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(1, 1));
    partCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    partCacheCfg.setNearConfiguration(null);
    partCacheCfg.setEvictionPolicy(null);
    partCacheCfg.setRebalanceMode(ASYNC);
    partCacheCfg.setAtomicityMode(TRANSACTIONAL);
    // This test requires artificial slowing down of the preloading.
    partCacheCfg.setRebalanceThrottle(2000);
    cfg.setCacheConfiguration(partCacheCfg);
    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement()));
    cfg.setNetworkTimeout(60000);
    return cfg;
}
Also used : GridCacheModuloAffinityFunction(org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 GridCacheModuloAffinityFunction (org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)1