Search in sources :

Example 51 with CacheConfiguration

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

the class PlatformConfigurationUtils method readCacheConfiguration.

/**
     * Reads cache configuration from a stream.
     *
     * @param in Stream.
     * @return Cache configuration.
     */
public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
    assert in != null;
    CacheConfiguration ccfg = new CacheConfiguration();
    ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
    ccfg.setBackups(in.readInt());
    ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
    ccfg.setCopyOnRead(in.readBoolean());
    ccfg.setEagerTtl(in.readBoolean());
    ccfg.setInvalidate(in.readBoolean());
    ccfg.setStoreKeepBinary(in.readBoolean());
    ccfg.setLoadPreviousValue(in.readBoolean());
    ccfg.setDefaultLockTimeout(in.readLong());
    ccfg.setLongQueryWarningTimeout(in.readLong());
    ccfg.setMaxConcurrentAsyncOperations(in.readInt());
    ccfg.setName(in.readString());
    ccfg.setReadFromBackup(in.readBoolean());
    ccfg.setRebalanceBatchSize(in.readInt());
    ccfg.setRebalanceDelay(in.readLong());
    ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
    ccfg.setRebalanceThrottle(in.readLong());
    ccfg.setRebalanceTimeout(in.readLong());
    ccfg.setSqlEscapeAll(in.readBoolean());
    ccfg.setWriteBehindBatchSize(in.readInt());
    ccfg.setWriteBehindEnabled(in.readBoolean());
    ccfg.setWriteBehindFlushFrequency(in.readLong());
    ccfg.setWriteBehindFlushSize(in.readInt());
    ccfg.setWriteBehindFlushThreadCount(in.readInt());
    ccfg.setWriteBehindCoalescing(in.readBoolean());
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
    ccfg.setReadThrough(in.readBoolean());
    ccfg.setWriteThrough(in.readBoolean());
    ccfg.setStatisticsEnabled(in.readBoolean());
    String memoryPolicyName = in.readString();
    if (memoryPolicyName != null)
        ccfg.setMemoryPolicyName(memoryPolicyName);
    ccfg.setPartitionLossPolicy(PartitionLossPolicy.fromOrdinal((byte) in.readInt()));
    Object storeFactory = in.readObjectDetached();
    if (storeFactory != null)
        ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
    int qryEntCnt = in.readInt();
    if (qryEntCnt > 0) {
        Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
        for (int i = 0; i < qryEntCnt; i++) entities.add(readQueryEntity(in));
        ccfg.setQueryEntities(entities);
    }
    if (in.readBoolean())
        ccfg.setNearConfiguration(readNearConfiguration(in));
    ccfg.setEvictionPolicy(readEvictionPolicy(in));
    if (ccfg.getEvictionPolicy() != null)
        ccfg.setOnheapCacheEnabled(true);
    ccfg.setAffinity(readAffinityFunction(in));
    ccfg.setExpiryPolicyFactory(readExpiryPolicyFactory(in));
    int pluginCnt = in.readInt();
    if (pluginCnt > 0) {
        ArrayList<CachePluginConfiguration> plugins = new ArrayList<>();
        for (int i = 0; i < pluginCnt; i++) {
            if (in.readBoolean()) {
                // Java cache plugin.
                readCachePluginConfiguration(ccfg, in);
            } else {
                // Platform cache plugin.
                plugins.add(new PlatformCachePluginConfiguration(in.readObjectDetached()));
            }
        }
        if (ccfg.getPluginConfigurations() != null) {
            Collections.addAll(plugins, ccfg.getPluginConfigurations());
        }
        ccfg.setPluginConfigurations(plugins.toArray(new CachePluginConfiguration[plugins.size()]));
    }
    return ccfg;
}
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) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 52 with CacheConfiguration

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

the class GridCacheAffinityBackupsSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(backups);
    ccfg.setAffinity(new RendezvousAffinityFunction());
    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 53 with CacheConfiguration

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

the class IgniteCacheAffinitySelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration cache0 = cacheConfiguration(null);
    CacheConfiguration cache2 = cacheConfiguration(null);
    cache2.setName(CACHE2);
    cache2.setAffinity(new RendezvousAffinityFunction());
    if (igniteInstanceName.contains("0"))
        cfg.setCacheConfiguration(cache0);
    else
        cfg.setCacheConfiguration(cache0, cache2);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 54 with CacheConfiguration

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

the class GridAffinityMappedTest 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);
    cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
    if (igniteInstanceName.endsWith("1"))
        // Empty cache configuration.
        cfg.setCacheConfiguration();
    else {
        assert igniteInstanceName.endsWith("2") || igniteInstanceName.endsWith("3");
        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setCacheMode(PARTITIONED);
        cacheCfg.setAffinity(new MockCacheAffinityFunction());
        cacheCfg.setAffinityMapper(new MockCacheAffinityKeyMapper());
        cfg.setCacheConfiguration(cacheCfg);
        cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, igniteInstanceName.endsWith("2") ? 0 : 1));
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 55 with CacheConfiguration

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

the class GridAffinityP2PSelfTest 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);
    c.setFailureDetectionTimeout(Integer.MAX_VALUE);
    c.setDeploymentMode(depMode);
    if (igniteInstanceName.endsWith("1"))
        // Empty cache configuration.
        c.setCacheConfiguration();
    else {
        assert igniteInstanceName.endsWith("2") || igniteInstanceName.endsWith("3");
        CacheConfiguration cc = defaultCacheConfiguration();
        cc.setCacheMode(PARTITIONED);
        GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(URLS);
        cc.setAffinity((AffinityFunction) ldr.loadClass(EXT_AFFINITY_CLS_NAME).newInstance());
        cc.setAffinityMapper((AffinityKeyMapper) ldr.loadClass(EXT_AFFINITY_MAPPER_CLS_NAME).newInstance());
        c.setCacheConfiguration(cc);
        c.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, igniteInstanceName.endsWith("2") ? 0 : 1));
    }
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestExternalClassLoader(org.apache.ignite.testframework.GridTestExternalClassLoader) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)980 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)392 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)287 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)250 Ignite (org.apache.ignite.Ignite)148 ArrayList (java.util.ArrayList)69 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)64 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)59 QueryEntity (org.apache.ignite.cache.QueryEntity)44 IgniteException (org.apache.ignite.IgniteException)43 CacheException (javax.cache.CacheException)42 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)40 IgniteEx (org.apache.ignite.internal.IgniteEx)40 IgniteCache (org.apache.ignite.IgniteCache)39 LinkedHashMap (java.util.LinkedHashMap)35 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)34 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)32 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)30 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)30 Transaction (org.apache.ignite.transactions.Transaction)28