Search in sources :

Example 36 with CacheConfiguration

use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.

the class IgniteVariousConnectionNumberTest method testVariousConnectionNumber.

/**
 * @throws Exception If failed.
 */
public void testVariousConnectionNumber() throws Exception {
    startGridsMultiThreaded(3);
    client = true;
    startGridsMultiThreaded(3, 3);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(REPLICATED);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ignite(0).createCache(ccfg);
    for (int i = 0; i < 10; i++) {
        log.info("Iteration: " + i);
        runOperations(5000);
        awaitPartitionMapExchange();
        int idx = ThreadLocalRandom.current().nextInt(NODES);
        Ignite node = ignite(idx);
        client = node.configuration().isClientMode();
        stopGrid(idx);
        startGrid(idx);
    }
}
Also used : Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 37 with CacheConfiguration

use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.

the class GridDiscoveryManagerAliveCacheSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration cCfg = defaultCacheConfiguration();
    cCfg.setCacheMode(PARTITIONED);
    cCfg.setBackups(1);
    cCfg.setNearConfiguration(new NearCacheConfiguration());
    cCfg.setRebalanceMode(SYNC);
    cCfg.setWriteSynchronizationMode(FULL_SYNC);
    TcpDiscoverySpi disc = new TcpDiscoverySpi();
    if (clientMode && ((igniteInstanceName.charAt(igniteInstanceName.length() - 1) - '0') & 1) != 0)
        cfg.setClientMode(true);
    else
        cfg.setClientFailureDetectionTimeout(50000);
    disc.setIpFinder(IP_FINDER);
    disc.setAckTimeout(1000);
    disc.setSocketTimeout(1000);
    cfg.setCacheConfiguration(cCfg);
    cfg.setDiscoverySpi(disc);
    cfg.setMetricsUpdateFrequency(500);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 38 with CacheConfiguration

use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.

the class GridCacheConcurrentTxMultiNodeTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
    AtomicConfiguration atomicCfg = new AtomicConfiguration();
    atomicCfg.setAtomicSequenceReserveSize(100000);
    atomicCfg.setCacheMode(mode);
    c.setAtomicConfiguration(atomicCfg);
    if (cacheOn) {
        CacheConfiguration cc = defaultCacheConfiguration();
        cc.setCacheMode(mode);
        LruEvictionPolicy plc = new LruEvictionPolicy();
        plc.setMaxSize(1000);
        cc.setEvictionPolicy(plc);
        cc.setOnheapCacheEnabled(true);
        cc.setWriteSynchronizationMode(FULL_SYNC);
        cc.setRebalanceMode(NONE);
        c.setCacheConfiguration(cc);
    } else
        c.setCacheConfiguration();
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    c.setPeerClassLoadingEnabled(false);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 39 with CacheConfiguration

use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.

the class GridCacheConfigurationConsistencySelfTest method testPartitionedOnlyAttributesIgnoredForReplicated.

/**
 * @throws Exception If failed.
 */
public void testPartitionedOnlyAttributesIgnoredForReplicated() throws Exception {
    cacheEnabled = true;
    cacheMode = REPLICATED;
    initCache = new C1<CacheConfiguration, Void>() {

        @Override
        public Void apply(CacheConfiguration cfg) {
            NearCacheConfiguration nearCfg = new NearCacheConfiguration();
            nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
            nearCfg.setNearEvictionPolicy(new LruEvictionPolicy());
            cfg.setNearConfiguration(nearCfg);
            return null;
        }
    };
    startGrid(1);
    initCache = new C1<CacheConfiguration, Void>() {

        @Override
        public Void apply(CacheConfiguration cfg) {
            NearCacheConfiguration nearCfg = new NearCacheConfiguration();
            nearCfg.setNearEvictionPolicyFactory(new FifoEvictionPolicyFactory<>());
            nearCfg.setNearEvictionPolicy(new FifoEvictionPolicy());
            cfg.setNearConfiguration(nearCfg);
            return null;
        }
    };
    startGrid(2);
}
Also used : FifoEvictionPolicyFactory(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicyFactory) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)

Example 40 with CacheConfiguration

use of org.apache.ignite.configuration.CacheConfiguration 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.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);
    if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_NAME_IGNITE_INSTANCE_NAME))
        namedCacheCfg.setName(DataStructuresProcessor.ATOMICS_CACHE_NAME + "@abc");
    else
        namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
    if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_GROUP_NAME_IGNITE_INSTANCE_NAME))
        namedCacheCfg.setGroupName("default-ds-group");
    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

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1234 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)474 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)330 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)292 Ignite (org.apache.ignite.Ignite)202 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)127 ArrayList (java.util.ArrayList)95 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)82 IgniteEx (org.apache.ignite.internal.IgniteEx)60 QueryEntity (org.apache.ignite.cache.QueryEntity)59 IgniteCache (org.apache.ignite.IgniteCache)55 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)54 CacheException (javax.cache.CacheException)51 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)51 IgniteException (org.apache.ignite.IgniteException)50 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)45 LinkedHashMap (java.util.LinkedHashMap)41 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)41 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)38 Transaction (org.apache.ignite.transactions.Transaction)35