use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteHadoopFileSystemIpcCacheSelfTest method dataCacheConfiguration.
/**
* Gets cache configuration.
*
* @return Cache configuration.
*/
private CacheConfiguration dataCacheConfiguration() {
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setName("partitioned");
ccfg.setCacheMode(PARTITIONED);
ccfg.setNearConfiguration(null);
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE));
ccfg.setBackups(0);
ccfg.setAtomicityMode(TRANSACTIONAL);
return ccfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheJoinPartitionedAndReplicatedCollocationTest method accountCache.
/**
* @param backups Number of backups.
* @return Cache configuration.
*/
private CacheConfiguration accountCache(int backups) {
CacheConfiguration ccfg = configuration(ACCOUNT_CACHE, backups);
QueryEntity entity = new QueryEntity();
entity.setKeyType(Integer.class.getName());
entity.setValueType(Account.class.getName());
entity.addQueryField("personId", Integer.class.getName(), null);
entity.addQueryField("name", String.class.getName(), null);
entity.setIndexes(F.asList(new QueryIndex("personId")));
ccfg.setQueryEntities(F.asList(entity));
return ccfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheJoinPartitionedAndReplicatedTest method configuration.
/**
* @param name Cache name.
* @return Cache configuration.
*/
private CacheConfiguration configuration(String name) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(name);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setAtomicityMode(ATOMIC);
ccfg.setBackups(1);
return ccfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheJoinQueryWithAffinityKeyTest method cacheConfiguration.
/**
* @param cacheMode Cache mode.
* @param backups Number of backups.
* @param affKey If {@code true} uses key with affinity key field.
* @param includeAffKey If {@code true} includes affinity key field in query fields.
* @return Cache configuration.
*/
private CacheConfiguration cacheConfiguration(CacheMode cacheMode, int backups, boolean affKey, boolean includeAffKey) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(cacheMode);
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
String personKeyType = affKey ? TestKeyWithAffinity.class.getName() : TestKey.class.getName();
QueryEntity account = new QueryEntity();
account.setKeyType(Integer.class.getName());
account.setValueType(affKey ? AccountKeyWithAffinity.class.getName() : Account.class.getName());
account.addQueryField("personKey", personKeyType, null);
account.addQueryField("personId", Integer.class.getName(), null);
account.setIndexes(F.asList(new QueryIndex("personKey"), new QueryIndex("personId")));
QueryEntity person = new QueryEntity();
person.setKeyType(personKeyType);
person.setValueType(Person.class.getName());
person.addQueryField("orgId", Integer.class.getName(), null);
person.addQueryField("id", Integer.class.getName(), null);
person.addQueryField("name", String.class.getName(), null);
person.setIndexes(F.asList(new QueryIndex("orgId"), new QueryIndex("id"), new QueryIndex("name")));
if (affKey && includeAffKey)
person.addQueryField("affKey", Integer.class.getName(), null);
QueryEntity org = new QueryEntity();
org.setKeyType(Integer.class.getName());
org.setValueType(Organization.class.getName());
org.addQueryField("name", String.class.getName(), null);
org.setIndexes(F.asList(new QueryIndex("name")));
ccfg.setQueryEntities(F.asList(account, person, org));
ccfg.setSqlEscapeAll(escape);
return ccfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheDuplicateEntityConfigurationSelfTest method testClassDuplicatesQueryEntity.
/**
* @throws Exception If failed.
*/
public void testClassDuplicatesQueryEntity() throws Exception {
String cacheName = "duplicate";
CacheConfiguration ccfg = new CacheConfiguration(cacheName);
ccfg.setIndexedTypes(Integer.class, Person.class);
QueryEntity entity = new QueryEntity();
entity.setKeyType(Integer.class.getName());
entity.setValueType(Person.class.getName());
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("name", String.class.getName());
entity.setFields(fields);
ccfg.setQueryEntities(Arrays.asList(entity));
try {
ignite(0).getOrCreateCache(ccfg);
} finally {
ignite(0).destroyCache(cacheName);
}
}
Aggregations