Search in sources :

Example 71 with NearCacheConfiguration

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

the class GridCacheDhtEvictionNearReadersSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(disco);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(1);
    FifoEvictionPolicy plc = new FifoEvictionPolicy();
    plc.setMaxSize(10);
    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);
    NearCacheConfiguration nearCfg = new NearCacheConfiguration();
    FifoEvictionPolicy nearPlc = new FifoEvictionPolicy();
    nearPlc.setMaxSize(10);
    nearCfg.setNearEvictionPolicy(nearPlc);
    cacheCfg.setNearConfiguration(nearCfg);
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FifoEvictionPolicy(org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 72 with NearCacheConfiguration

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

the class GridCacheEvictionFilterSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(mode);
    cc.setEvictionPolicy(notSerializableProxy(plc, EvictionPolicy.class));
    cc.setOnheapCacheEnabled(true);
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setEvictionFilter(notSerializableProxy(filter, org.apache.ignite.cache.eviction.EvictionFilter.class));
    cc.setRebalanceMode(SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);
    if (nearEnabled) {
        NearCacheConfiguration nearCfg = new NearCacheConfiguration();
        nearCfg.setNearEvictionPolicy(notSerializableProxy(plc, EvictionPolicy.class));
        cc.setNearConfiguration(nearCfg);
    } else
        cc.setNearConfiguration(null);
    if (mode == PARTITIONED)
        cc.setBackups(1);
    c.setCacheConfiguration(cc);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) EvictionPolicy(org.apache.ignite.cache.eviction.EvictionPolicy) 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 73 with NearCacheConfiguration

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

the class PlatformConfigurationUtils method readNearConfiguration.

/**
 * Reads the near config.
 *
 * @param in Stream.
 * @return NearCacheConfiguration.
 */
public static NearCacheConfiguration readNearConfiguration(BinaryRawReader in) {
    NearCacheConfiguration cfg = new NearCacheConfiguration();
    cfg.setNearStartSize(in.readInt());
    cfg.setNearEvictionPolicy(readEvictionPolicy(in));
    return cfg;
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 74 with NearCacheConfiguration

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

the class PlatformConfigurationUtils method writeCacheConfiguration.

/**
 * Writes cache configuration.
 *
 * @param writer Writer.
 * @param ccfg Configuration.
 */
public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
    assert writer != null;
    assert ccfg != null;
    writeEnumInt(writer, ccfg.getAtomicityMode(), CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE);
    writer.writeInt(ccfg.getBackups());
    writeEnumInt(writer, ccfg.getCacheMode(), CacheConfiguration.DFLT_CACHE_MODE);
    writer.writeBoolean(ccfg.isCopyOnRead());
    writer.writeBoolean(ccfg.isEagerTtl());
    writer.writeBoolean(ccfg.isInvalidate());
    writer.writeBoolean(ccfg.isStoreKeepBinary());
    writer.writeBoolean(ccfg.isLoadPreviousValue());
    writer.writeLong(ccfg.getDefaultLockTimeout());
    // noinspection deprecation
    writer.writeLong(ccfg.getLongQueryWarningTimeout());
    writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
    writer.writeString(ccfg.getName());
    writer.writeBoolean(ccfg.isReadFromBackup());
    writer.writeInt(ccfg.getRebalanceBatchSize());
    writer.writeLong(ccfg.getRebalanceDelay());
    writeEnumInt(writer, ccfg.getRebalanceMode(), CacheConfiguration.DFLT_REBALANCE_MODE);
    writer.writeLong(ccfg.getRebalanceThrottle());
    writer.writeLong(ccfg.getRebalanceTimeout());
    writer.writeBoolean(ccfg.isSqlEscapeAll());
    writer.writeInt(ccfg.getWriteBehindBatchSize());
    writer.writeBoolean(ccfg.isWriteBehindEnabled());
    writer.writeLong(ccfg.getWriteBehindFlushFrequency());
    writer.writeInt(ccfg.getWriteBehindFlushSize());
    writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
    writer.writeBoolean(ccfg.getWriteBehindCoalescing());
    writeEnumInt(writer, ccfg.getWriteSynchronizationMode());
    writer.writeBoolean(ccfg.isReadThrough());
    writer.writeBoolean(ccfg.isWriteThrough());
    writer.writeBoolean(ccfg.isStatisticsEnabled());
    // noinspection deprecation
    writer.writeString(ccfg.getMemoryPolicyName());
    writer.writeInt(ccfg.getPartitionLossPolicy().ordinal());
    writer.writeString(ccfg.getGroupName());
    if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
        writer.writeObject(((PlatformDotNetCacheStoreFactoryNative) ccfg.getCacheStoreFactory()).getNativeFactory());
    else
        writer.writeObject(null);
    writer.writeInt(ccfg.getSqlIndexMaxInlineSize());
    writer.writeBoolean(ccfg.isOnheapCacheEnabled());
    writer.writeInt(ccfg.getStoreConcurrentLoadAllThreshold());
    writer.writeInt(ccfg.getRebalanceOrder());
    writer.writeLong(ccfg.getRebalanceBatchesPrefetchCount());
    writer.writeInt(ccfg.getMaxQueryIteratorsCount());
    writer.writeInt(ccfg.getQueryDetailMetricsSize());
    writer.writeInt(ccfg.getQueryParallelism());
    writer.writeString(ccfg.getSqlSchema());
    Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
    if (qryEntities != null) {
        writer.writeInt(qryEntities.size());
        for (QueryEntity e : qryEntities) writeQueryEntity(writer, e);
    } else
        writer.writeInt(0);
    NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();
    if (nearCfg != null) {
        writer.writeBoolean(true);
        writeNearConfiguration(writer, nearCfg);
    } else
        writer.writeBoolean(false);
    writeEvictionPolicy(writer, ccfg.getEvictionPolicy());
    writeAffinityFunction(writer, ccfg.getAffinity());
    writeExpiryPolicyFactory(writer, ccfg.getExpiryPolicyFactory());
    CacheKeyConfiguration[] keys = ccfg.getKeyConfiguration();
    if (keys != null) {
        writer.writeInt(keys.length);
        for (CacheKeyConfiguration key : keys) {
            writer.writeString(key.getTypeName());
            writer.writeString(key.getAffinityKeyFieldName());
        }
    } else {
        writer.writeInt(0);
    }
    CachePluginConfiguration[] plugins = ccfg.getPluginConfigurations();
    if (plugins != null) {
        int cnt = 0;
        for (CachePluginConfiguration cfg : plugins) {
            if (cfg instanceof PlatformCachePluginConfiguration)
                cnt++;
        }
        writer.writeInt(cnt);
        for (CachePluginConfiguration cfg : plugins) {
            if (cfg instanceof PlatformCachePluginConfiguration) {
                // Pure platform plugin.
                writer.writeBoolean(false);
                writer.writeObject(((PlatformCachePluginConfiguration) cfg).nativeCfg());
            }
        }
    }
}
Also used : PlatformDotNetCacheStoreFactoryNative(org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative) CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) CachePluginConfiguration(org.apache.ignite.plugin.CachePluginConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) PlatformCachePluginConfiguration(org.apache.ignite.internal.processors.platform.plugin.cache.PlatformCachePluginConfiguration) QueryEntity(org.apache.ignite.cache.QueryEntity) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 75 with NearCacheConfiguration

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

the class CacheGetInsideLockChangingTopologyTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
    super.beforeTestsStarted();
    startGridsMultiThreaded(SRVS);
    client.set(true);
    Ignite client1 = startGrid(SRVS);
    assertTrue(client1.configuration().isClientMode());
    client.set(true);
    Ignite client2 = startGrid(SRVS + 1);
    assertTrue(client2.configuration().isClientMode());
    client2.createNearCache(TX_CACHE1, new NearCacheConfiguration<>().setNearEvictionPolicy(new GridCacheAlwaysEvictionPolicy<>()));
    client2.createNearCache(TX_CACHE2, new NearCacheConfiguration<>().setNearEvictionPolicy(new GridCacheAlwaysEvictionPolicy<>()));
    client2.createNearCache(ATOMIC_CACHE, new NearCacheConfiguration<>().setNearEvictionPolicy(new GridCacheAlwaysEvictionPolicy<>()));
}
Also used : Ignite(org.apache.ignite.Ignite) GridCacheAlwaysEvictionPolicy(org.apache.ignite.internal.processors.cache.GridCacheAlwaysEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Aggregations

NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)158 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)121 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)50 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)41 Ignite (org.apache.ignite.Ignite)37 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 IgniteCache (org.apache.ignite.IgniteCache)12 CacheException (javax.cache.CacheException)11 IgniteEx (org.apache.ignite.internal.IgniteEx)9 Transaction (org.apache.ignite.transactions.Transaction)9 ArrayList (java.util.ArrayList)8 IgniteException (org.apache.ignite.IgniteException)8 HashMap (java.util.HashMap)7 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)7 LinkedHashMap (java.util.LinkedHashMap)6 Callable (java.util.concurrent.Callable)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)6 QuerySchema (org.apache.ignite.internal.processors.query.QuerySchema)6 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)6