Search in sources :

Example 46 with CacheConfiguration

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

the class DataStructuresProcessor method compatibleConfiguration.

/**
     * @param cfg Collection configuration.
     * @return Cache name.
     * @throws IgniteCheckedException If failed.
     */
private String compatibleConfiguration(CollectionConfiguration cfg) throws IgniteCheckedException {
    List<CacheCollectionInfo> caches = utilityDataCache.context().affinityNode() ? utilityDataCache.localPeek(DATA_STRUCTURES_CACHE_KEY, null, null) : utilityDataCache.get(DATA_STRUCTURES_CACHE_KEY);
    String cacheName = findCompatibleConfiguration(cfg, caches);
    if (cacheName == null)
        cacheName = utilityDataCache.invoke(DATA_STRUCTURES_CACHE_KEY, new AddDataCacheProcessor(cfg)).get();
    assert cacheName != null;
    CacheConfiguration newCfg = cacheConfiguration(cfg, cacheName);
    if (ctx.cache().cache(cacheName) == null) {
        ctx.cache().dynamicStartCache(newCfg, cacheName, null, CacheType.INTERNAL, false, false, true, true).get();
    }
    assert ctx.cache().cache(cacheName) != null : cacheName;
    return cacheName;
}
Also used : CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 47 with CacheConfiguration

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

the class IgfsUtils method defaultMetaCacheConfig.

/**
     * @return Default IGFS meta cache configuration.
     */
private static CacheConfiguration defaultMetaCacheConfig() {
    CacheConfiguration cfg = defaultCacheConfig();
    cfg.setBackups(1);
    return cfg;
}
Also used : CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 48 with CacheConfiguration

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

the class PlatformCache method processOutStream.

/** {@inheritDoc} */
@Override
public void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
    switch(type) {
        case OP_GET_NAME:
            writer.writeObject(cache.getName());
            break;
        case OP_LOCAL_METRICS:
            {
                CacheMetrics metrics = cache.localMetrics();
                writeCacheMetrics(writer, metrics);
                break;
            }
        case OP_GLOBAL_METRICS:
            {
                CacheMetrics metrics = cache.metrics();
                writeCacheMetrics(writer, metrics);
                break;
            }
        case OP_GET_CONFIG:
            CacheConfiguration ccfg = ((IgniteCache<Object, Object>) cache).getConfiguration(CacheConfiguration.class);
            PlatformConfigurationUtils.writeCacheConfiguration(writer, ccfg);
            break;
        case OP_GET_LOST_PARTITIONS:
            Collection<Integer> parts = cache.lostPartitions();
            writer.writeInt(parts.size());
            for (int p : parts) {
                writer.writeInt(p);
            }
            break;
        default:
            super.processOutStream(type, writer);
    }
}
Also used : CacheMetrics(org.apache.ignite.cache.CacheMetrics) IgniteCache(org.apache.ignite.IgniteCache) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 49 with CacheConfiguration

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

the class PlatformProcessorImpl method getOrCreateCacheFromConfig.

/** {@inheritDoc} */
@Override
public PlatformTargetProxy getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
    BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
    CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
    IgniteCacheProxy cache = reader.readBoolean() ? (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg, PlatformConfigurationUtils.readNearConfiguration(reader)) : (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg);
    return createPlatformCache(cache);
}
Also used : IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 50 with CacheConfiguration

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

the class GridQueryProcessor method dynamicTableCreate.

/**
     * Create cache and table from given query entity.
     *
     * @param schemaName Schema name to create table in.
     * @param entity Entity to create table from.
     * @param templateName Template name.
     * @param atomicityMode Atomicity mode.
     * @param backups Backups.
     * @param ifNotExists Quietly ignore this command if table already exists.
     * @throws IgniteCheckedException If failed.
     */
@SuppressWarnings("unchecked")
public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateName, @Nullable CacheAtomicityMode atomicityMode, int backups, boolean ifNotExists) throws IgniteCheckedException {
    assert !F.isEmpty(templateName);
    assert backups >= 0;
    CacheConfiguration<?, ?> ccfg = ctx.cache().getConfigFromTemplate(templateName);
    if (ccfg == null) {
        if (QueryUtils.TEMPLATE_PARTITIONED.equalsIgnoreCase(templateName))
            ccfg = new CacheConfiguration<>().setCacheMode(CacheMode.PARTITIONED);
        else if (QueryUtils.TEMPLATE_REPLICÄTED.equalsIgnoreCase(templateName))
            ccfg = new CacheConfiguration<>().setCacheMode(CacheMode.REPLICATED);
        else
            throw new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND, templateName);
    }
    if (!F.isEmpty(ccfg.getQueryEntities()))
        throw new SchemaOperationException("Template cache already contains query entities which it should not: " + templateName);
    ccfg.setName(entity.getTableName());
    if (atomicityMode != null)
        ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(backups);
    ccfg.setSqlSchema(schemaName);
    ccfg.setSqlEscapeAll(true);
    ccfg.setQueryEntities(Collections.singleton(entity));
    boolean res = ctx.grid().getOrCreateCache0(ccfg, true).get2();
    if (!res && !ifNotExists)
        throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_EXISTS, entity.getTableName());
}
Also used : SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

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