Search in sources :

Example 6 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 7 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());
    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());
    writer.writeString(ccfg.getMemoryPolicyName());
    writer.writeInt(ccfg.getPartitionLossPolicy().ordinal());
    if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
        writer.writeObject(((PlatformDotNetCacheStoreFactoryNative) ccfg.getCacheStoreFactory()).getNativeFactory());
    else
        writer.writeObject(null);
    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());
    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)
                writer.writeObject(((PlatformCachePluginConfiguration) cfg).nativeCfg());
        }
    }
}
Also used : PlatformDotNetCacheStoreFactoryNative(org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative) 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 8 with NearCacheConfiguration

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

the class IgniteCacheTopologySafeGetSelfTest method cacheCfg.

/**
     * @param name Cache name.
     * @param cacheMode Cache mode.
     * @param near Near enabled flag.
     * @return Cache configuration.
     */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheCfg(String name, CacheAtomicityMode cacheMode, boolean near) {
    CacheConfiguration cfg = new CacheConfiguration(name);
    cfg.setAtomicityMode(cacheMode);
    cfg.setBackups(1);
    if (near)
        cfg.setNearConfiguration(new NearCacheConfiguration());
    else
        cfg.setNearConfiguration(null);
    return cfg;
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 9 with NearCacheConfiguration

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

the class GridCacheNearMultiNodeSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
    cfg.setDiscoverySpi(spi);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setCacheStoreFactory(singletonFactory(store));
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setAffinity(aff);
    cacheCfg.setAtomicityMode(atomicityMode());
    cacheCfg.setBackups(BACKUPS);
    cacheCfg.setNearConfiguration(new NearCacheConfiguration());
    cfg.setCacheConfiguration(cacheCfg);
    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) 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 10 with NearCacheConfiguration

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

the class GridCacheGetStoreErrorSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(cacheMode);
    if (nearEnabled)
        cc.setNearConfiguration(new NearCacheConfiguration());
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setCacheStoreFactory(new IgniteReflectionFactory<CacheStore>(TestStore.class));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);
    c.setCacheConfiguration(cc);
    c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheStore(org.apache.ignite.cache.store.CacheStore) 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)

Aggregations

NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)140 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)110 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)45 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)38 Ignite (org.apache.ignite.Ignite)32 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 CacheException (javax.cache.CacheException)11 IgniteCache (org.apache.ignite.IgniteCache)11 IgniteEx (org.apache.ignite.internal.IgniteEx)9 IgniteException (org.apache.ignite.IgniteException)8 Transaction (org.apache.ignite.transactions.Transaction)8 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)7 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)6 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 Callable (java.util.concurrent.Callable)5 TimeoutException (java.util.concurrent.TimeoutException)5 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)5 ArrayList (java.util.ArrayList)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4