Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setSqlFunctionClasses()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setSqlFunctionClasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteQueryDedicatedPoolTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName)
        .setGridLogger(testLog);

    CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setIndexedTypes(Integer.class, Integer.class);
    ccfg.setIndexedTypes(Byte.class, Byte.class);
    ccfg.setSqlFunctionClasses(IgniteQueryDedicatedPoolTest.class);
    ccfg.setName(CACHE_NAME);

    cfg.setCacheConfiguration(ccfg);
    cfg.setIndexingSpi(new TestIndexingSpi());

    if (nonNull(qryPoolSize))
        cfg.setQueryThreadPoolSize(qryPoolSize);

    return cfg;
}
 
Example 2
Source File: GridQueryParsingTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param name Cache name.
 * @param clsK Key class.
 * @param clsV Value class.
 * @return Cache configuration.
 */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfiguration(@NotNull String name, String sqlSchema, Class<?> clsK,
    Class<?> clsV) {
    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setName(name);
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cc.setNearConfiguration(null);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    cc.setRebalanceMode(SYNC);
    cc.setSqlSchema(sqlSchema);
    cc.setSqlFunctionClasses(GridQueryParsingTest.class);
    cc.setIndexedTypes(clsK, clsV);

    if (!QueryUtils.isSqlType(clsK))
        cc.setKeyConfiguration(new CacheKeyConfiguration(clsK));

    return cc;
}
 
Example 3
Source File: IgniteCacheDistributedQueryCancelSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
@Test
public void testQueryResponseFailCode() throws Exception {
    try (Ignite client = startClientGrid("client")) {

        CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
        cfg.setSqlFunctionClasses(Functions.class);
        cfg.setIndexedTypes(Integer.class, Integer.class);
        cfg.setName("test");

        IgniteCache<Integer, Integer> cache = client.getOrCreateCache(cfg);

        cache.put(1, 1);

        QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("select fail() from Integer"));

        try {
            qry.getAll();

            fail();
        }
        catch (Exception e) {
            assertTrue(e instanceof CacheException);
        }
    }
}
 
Example 4
Source File: JdbcThinStatementCancelSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setSqlFunctionClasses(TestSQLFunctions.class);
    cache.setIndexedTypes(Integer.class, Integer.class, Long.class, Long.class, String.class,
        JdbcThinAbstractDmlStatementSelfTest.Person.class);

    cfg.setCacheConfiguration(cache);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().
        setThreadPoolSize(SERVER_THREAD_POOL_SIZE));

    return cfg;
}
 
Example 5
Source File: SqlQueryHistorySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration<Integer, String> configureCache(String cacheName) {
    CacheConfiguration<Integer, String> ccfg = defaultCacheConfiguration();

    ccfg.setName(cacheName);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setIndexedTypes(Integer.class, String.class);
    ccfg.setSqlFunctionClasses(Functions.class);

    return ccfg;
}
 
Example 6
Source File: KillQueryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and populates a new cache that is used in distributed join scenario: We have table of Persons with some
 * autogenerated PK. Join filter should be based on Person.id column which is not collocated with the pk. Result
 * size of such join (with eq condition) is {@link #MAX_ROWS} rows.
 *
 * @param cacheName name of the created cache.
 * @param shift integer to avoid collocation, put different value for the different caches.
 */
private void createJoinCache(String cacheName, int shift) {
    CacheConfiguration<Long, Person> ccfg = GridAbstractTest.defaultCacheConfiguration();

    ccfg.setName(cacheName);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setSqlFunctionClasses(TestSQLFunctions.class);

    ccfg.setQueryEntities(Collections.singleton(
        new QueryEntity(Integer.class.getName(), Person.class.getName())
            .setTableName("PERSON")
            .setKeyFieldName("rec_id") // PK
            .addQueryField("rec_id", Integer.class.getName(), null)
            .addQueryField("id", Integer.class.getName(), null)
            .addQueryField("lastName", String.class.getName(), null)
            .setIndexes(Collections.singleton(new QueryIndex("id", true, "idx_" + cacheName)))
    ));

    grid(0).createCache(ccfg);

    try (IgniteDataStreamer<Object, Object> ds = grid(0).dataStreamer(cacheName)) {

        for (int recordId = 0; recordId < MAX_ROWS; recordId++) {
            // If two caches has the same PK, FK fields ("id") will be different.
            int intTabIdFK = (recordId + shift) % MAX_ROWS;

            ds.addData(recordId,
                new Person(intTabIdFK,
                    "Name_" + recordId,
                    "LastName_" + recordId,
                    42));
        }
    }
}
 
Example 7
Source File: QueryDataPageScanTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
@Ignore("https://issues.apache.org/jira/browse/IGNITE-11998")
public void testDataPageScan() throws Exception {
    final String cacheName = "test";

    GridQueryProcessor.idxCls = DirectPageScanIndexing.class;
    IgniteEx server = startGrid(0);
    server.cluster().active(true);

    IgniteEx client = startClientGrid(1);

    CacheConfiguration<Long,TestData> ccfg = new CacheConfiguration<>(cacheName);
    ccfg.setIndexedTypes(Long.class, TestData.class);
    ccfg.setSqlFunctionClasses(QueryDataPageScanTest.class);

    IgniteCache<Long,TestData> clientCache = client.createCache(ccfg);

    final int keysCnt = 1000;

    for (long i = 0; i < keysCnt; i++)
        clientCache.put(i, new TestData(i));

    IgniteCache<Long,TestData> serverCache = server.cache(cacheName);

    doTestScanQuery(clientCache, keysCnt);
    doTestScanQuery(serverCache, keysCnt);

    doTestSqlQuery(clientCache);
    doTestSqlQuery(serverCache);

    doTestDml(clientCache);
    doTestDml(serverCache);

    doTestLazySql(clientCache, keysCnt);
    doTestLazySql(serverCache, keysCnt);
}
 
Example 8
Source File: CacheSqlQueryValueCopySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<Integer, Value> cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cc.setCopyOnRead(true);
    cc.setIndexedTypes(Integer.class, Value.class);
    cc.setSqlFunctionClasses(TestSQLFunctions.class);

    cfg.setCacheConfiguration(cc);

    return cfg;
}
 
Example 9
Source File: DemoCachesLoadService.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Create base cache configuration.
 *
 * @param name cache name.
 * @return Cache configuration with basic properties set.
 */
private static CacheConfiguration cacheConfiguration(String name) {
    CacheConfiguration ccfg = new CacheConfiguration<>(name);

    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg.setQueryDetailMetricsSize(10);
    ccfg.setStatisticsEnabled(true);
    ccfg.setSqlFunctionClasses(SQLFunctions.class);
    ccfg.setDataRegionName("demo");

    return ccfg;
}
 
Example 10
Source File: KillQueryOnClientDisconnectTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<?, ?> cache = GridAbstractTest.defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setSqlFunctionClasses(TestSQLFunctions.class);
    cache.setIndexedTypes(Integer.class, Integer.class);

    cfg.setCacheConfiguration(cache);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    cfg.setCommunicationSpi(new TcpCommunicationSpi() {
        /** {@inheritDoc} */
        @Override public void sendMessage(ClusterNode node, Message msg,
            IgniteInClosure<IgniteException> ackC) {
            if (GridIoMessage.class.isAssignableFrom(msg.getClass())) {
                Message gridMsg = ((GridIoMessage)msg).message();

                //Don't send Kill response and disconnect client node.
                if (GridQueryKillResponse.class.isAssignableFrom(gridMsg.getClass())) {
                    grid(0).configuration().getDiscoverySpi().failNode(clientNode().cluster().localNode().id(), null);

                    return;
                }
            }

            super.sendMessage(node, msg, ackC);
        }
    });

    return cfg;
}
 
Example 11
Source File: JdbcThinConnectionTimeoutSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<?, ?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setSqlFunctionClasses(JdbcThinConnectionTimeoutSelfTest.class);
    cache.setIndexedTypes(Integer.class, Integer.class);

    cfg.setCacheConfiguration(cache);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setThreadPoolSize(SERVER_THREAD_POOL_SIZE));

    return cfg;
}
 
Example 12
Source File: JdbcThinStatementTimeoutSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setSqlFunctionClasses(TestSQLFunctions.class);
    cache.setIndexedTypes(Integer.class, Integer.class, Long.class, Long.class, String.class,
        JdbcThinAbstractDmlStatementSelfTest.Person.class);

    cfg.setCacheConfiguration(cache);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(disco);

    cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setThreadPoolSize(SERVER_THREAD_POOL_SIZE));

    return cfg;
}