Search in sources :

Example 91 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkCreateIndexOnColumnWithAlias.

/**
 * Check index creation on aliased column.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreateIndexOnColumnWithAlias(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_2_ESCAPED));
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, IgniteQueryErrorCode.COLUMN_NOT_FOUND);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
    QueryIndex idx = index(IDX_NAME_1, field(alias(FIELD_NAME_2_ESCAPED)));
    dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
    assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
    assertSimpleIndexOperations(SQL_SIMPLE_FIELD_2);
    assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_2, SQL_ARG_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 92 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkNoIndexIsCreatedForParallelism.

/**
 * Verifies that no index is created and an exception is thrown.
 *
 * @param parallel Parallelism level in the CREATE INDEX statement.
 * @param igniteQryErrorCode Expected error code in the thrown exception.
 * @throws Exception If failed for any other reason than the expected exception.
 */
private void checkNoIndexIsCreatedForParallelism(final int parallel, int igniteQryErrorCode) throws Exception {
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, parallel);
        }
    }, igniteQryErrorCode);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 93 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkCreateIndexNoColumn.

/**
 * Check create when table doesn't exist.
 *
 * @param mode Mode.
 * @param atomicityMode Atomicity mode.
 * @param near Near flag.
 * @throws Exception If failed.
 */
private void checkCreateIndexNoColumn(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
    initialize(mode, atomicityMode, near);
    final QueryIndex idx = index(IDX_NAME_1, field(randomString()));
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, IgniteQueryErrorCode.COLUMN_NOT_FOUND);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 94 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.

the class DynamicIndexAbstractBasicSelfTest method checkNoIndexIsCreatedForInlineSize.

/**
 * Verifies that no index is created and an exception is thrown.
 *
 * @param inlineSize Inline size value in the CREATE INDEX statement.
 * @param igniteQryErrorCode Expected error code in the thrown exception.
 * @throws Exception If failed for any other reason than the expected exception.
 */
private void checkNoIndexIsCreatedForInlineSize(final int inlineSize, int igniteQryErrorCode) throws Exception {
    assertIgniteSqlException(new RunnableX() {

        @Override
        public void runx() throws Exception {
            QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
            idx.setInlineSize(inlineSize);
            dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
        }
    }, igniteQryErrorCode);
    assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Also used : RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheException(javax.cache.CacheException) IgniteException(org.apache.ignite.IgniteException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Example 95 with RunnableX

use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project gridgain by gridgain.

the class DynamicColumnsAbstractConcurrentSelfTest method checkClientReconnect.

/**
 * Make sure that client receives schema changes made while it was disconnected, optionally with cache restart
 * in the interim.
 *
 * @param restartCache Whether cache needs to be recreated during client's absence.
 * @param dynamicCache Whether recreate, if needed, should be done on dynamic or static cache.
 * @throws Exception If failed.
 */
private void checkClientReconnect(final boolean restartCache, boolean dynamicCache) throws Exception {
    // Start complex topology.
    final IgniteEx srv = ignitionStart(serverConfiguration(1));
    ignitionStart(serverConfiguration(2));
    ignitionStart(serverConfiguration(3, true));
    final Ignite cli = ignitionStart(clientConfiguration(4));
    if (dynamicCache) {
        createSqlCache(cli);
        run(cli, createSql);
    }
    final String schemaName = dynamicCache ? QueryUtils.DFLT_SCHEMA : "idx";
    final QueryField[] cols = new QueryField[] { c("age", Integer.class.getName()), c("city", String.class.getName()) };
    // Check index create.
    reconnectClientNode(srv, cli, restartCache, dynamicCache, new RunnableX() {

        @Override
        public void runx() throws Exception {
            addCols(srv, schemaName, cols).get();
            dropCols(srv, schemaName, "NAME").get();
        }
    });
    checkTableState(srv, schemaName, TBL_NAME, cols);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueryField(org.apache.ignite.internal.processors.query.QueryField) IgniteEx(org.apache.ignite.internal.IgniteEx) RunnableX(org.apache.ignite.testframework.GridTestUtils.RunnableX) Ignite(org.apache.ignite.Ignite) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) QueryRetryException(org.apache.ignite.cache.query.QueryRetryException) SchemaOperationException(org.apache.ignite.internal.processors.query.schema.SchemaOperationException)

Aggregations

RunnableX (org.apache.ignite.testframework.GridTestUtils.RunnableX)126 SQLException (java.sql.SQLException)104 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)80 Test (org.junit.Test)78 Connection (java.sql.Connection)64 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)54 SQLClientInfoException (java.sql.SQLClientInfoException)50 JdbcThinConnection (org.apache.ignite.internal.jdbc.thin.JdbcThinConnection)50 IgniteException (org.apache.ignite.IgniteException)22 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)20 ResultSet (java.sql.ResultSet)18 Savepoint (java.sql.Savepoint)18 CacheException (javax.cache.CacheException)16 QueryIndex (org.apache.ignite.cache.QueryIndex)16 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)16 DatabaseMetaData (java.sql.DatabaseMetaData)10 PreparedStatement (java.sql.PreparedStatement)10 MalformedURLException (java.net.MalformedURLException)6 Statement (java.sql.Statement)6 Ignite (org.apache.ignite.Ignite)6