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;
}
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;
}
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);
}
}
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);
}
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());
}
Aggregations