Search in sources :

Example 91 with CacheConfiguration

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;
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 92 with CacheConfiguration

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;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 93 with CacheConfiguration

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;
}
Also used : CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 94 with CacheConfiguration

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;
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 95 with CacheConfiguration

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);
    }
}
Also used : QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

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