Search in sources :

Example 91 with QueryEntity

use of org.apache.ignite.cache.QueryEntity in project ignite by apache.

the class IgniteCacheJoinPartitionedAndReplicatedCollocationTest method personCache.

/**
 * @return Cache configuration.
 */
private CacheConfiguration personCache() {
    CacheConfiguration ccfg = configuration(PERSON_CACHE, 0);
    // Person cache is replicated.
    ccfg.setCacheMode(REPLICATED);
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(Person.class.getName());
    entity.addQueryField("name", String.class.getName(), null);
    ccfg.setQueryEntities(F.asList(entity));
    return ccfg;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 92 with QueryEntity

use of org.apache.ignite.cache.QueryEntity in project ignite by apache.

the class IgniteCacheJoinPartitionedAndReplicatedTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi spi = ((TcpDiscoverySpi) cfg.getDiscoverySpi());
    spi.setIpFinder(IP_FINDER);
    List<CacheConfiguration> ccfgs = new ArrayList<>();
    {
        CacheConfiguration ccfg = configuration(PERSON_CACHE);
        ccfg.setCacheMode(REPLICATED);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Person.class.getName());
        entity.addQueryField("orgId", Integer.class.getName(), null);
        entity.addQueryField("name", String.class.getName(), null);
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ORG_CACHE);
        ccfg.setCacheMode(PARTITIONED);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Organization.class.getName());
        entity.addQueryField("id", Integer.class.getName(), null);
        entity.addQueryField("name", String.class.getName(), null);
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ORG_CACHE_REPLICATED);
        ccfg.setCacheMode(REPLICATED);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Organization.class.getName());
        entity.addQueryField("id", Integer.class.getName(), null);
        entity.addQueryField("name", String.class.getName(), null);
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
    cfg.setClientMode(client);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 93 with QueryEntity

use of org.apache.ignite.cache.QueryEntity in project ignite by apache.

the class IncorrectQueryEntityTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();
    QueryEntity queryEntity = new QueryEntity(Object.class.getName(), Object.class.getName());
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    fields.put("exceptionOid", Object.class.getName());
    queryEntity.setFields(fields);
    Set<String> keyFields = new HashSet<>();
    keyFields.add("exceptionOid");
    queryEntity.setKeyFields(keyFields);
    dfltCacheCfg.setQueryEntities(F.asList(queryEntity));
    cfg.setCacheConfiguration(dfltCacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Example 94 with QueryEntity

use of org.apache.ignite.cache.QueryEntity in project ignite by apache.

the class BinarySerializationQuerySelfTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTest() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setLocalHost("127.0.0.1");
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    cfg.setDiscoverySpi(discoSpi);
    cfg.setMarshaller(new BinaryMarshaller());
    if (useReflectiveSerializer()) {
        BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(EntityPlain.class.getName());
        BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(EntitySerializable.class.getName());
        BinaryTypeConfiguration binTypCfg3 = new BinaryTypeConfiguration(EntityExternalizable.class.getName());
        BinaryTypeConfiguration binTypCfg4 = new BinaryTypeConfiguration(EntityBinarylizable.class.getName());
        BinaryTypeConfiguration binTypCfg5 = new BinaryTypeConfiguration(EntityWriteReadObject.class.getName());
        binTypCfg1.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg2.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg3.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg4.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg5.setSerializer(new BinaryReflectiveSerializer());
        List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();
        binTypCfgs.add(binTypCfg1);
        binTypCfgs.add(binTypCfg2);
        binTypCfgs.add(binTypCfg3);
        binTypCfgs.add(binTypCfg4);
        binTypCfgs.add(binTypCfg5);
        BinaryConfiguration binCfg = new BinaryConfiguration();
        binCfg.setTypeConfigurations(binTypCfgs);
        cfg.setBinaryConfiguration(binCfg);
    }
    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    List<QueryEntity> queryEntities = new ArrayList<>();
    queryEntities.add(entityForClass(EntityPlain.class));
    queryEntities.add(entityForClass(EntitySerializable.class));
    queryEntities.add(entityForClass(EntityExternalizable.class));
    queryEntities.add(entityForClass(EntityBinarylizable.class));
    queryEntities.add(entityForClass(EntityWriteReadObject.class));
    cacheCfg.setQueryEntities(queryEntities);
    cfg.setCacheConfiguration(cacheCfg);
    ignite = Ignition.start(cfg);
    cache = ignite.cache(DEFAULT_CACHE_NAME);
}
Also used : BinaryReflectiveSerializer(org.apache.ignite.binary.BinaryReflectiveSerializer) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 95 with QueryEntity

use of org.apache.ignite.cache.QueryEntity in project ignite by apache.

the class IgniteCachePrimitiveFieldsQuerySelfTest method cacheConfiguration.

/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, IndexedType> cacheConfiguration(String cacheName) {
    CacheConfiguration<Integer, IndexedType> ccfg = new CacheConfiguration<>(cacheName);
    QueryEntity entity = new QueryEntity(Integer.class.getName(), IndexedType.class.getName());
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    // Test will pass if we use java.lang.Integer instead of int.
    fields.put("iVal", "int");
    entity.setFields(fields);
    entity.setIndexes(F.asList(new QueryIndex("iVal")));
    ccfg.setQueryEntities(F.asList(entity));
    return ccfg;
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

QueryEntity (org.apache.ignite.cache.QueryEntity)97 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)59 QueryIndex (org.apache.ignite.cache.QueryIndex)46 LinkedHashMap (java.util.LinkedHashMap)38 ArrayList (java.util.ArrayList)33 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)17 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)12 HashSet (java.util.HashSet)8 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)8 HashMap (java.util.HashMap)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 BinaryObject (org.apache.ignite.binary.BinaryObject)5 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)4 List (java.util.List)3 Map (java.util.Map)3