ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [22/50] [abbrv] ignite git commit: IGNITE-6689: SQL: Added DATA_REGION option for CREATE TABLE.
Date Wed, 25 Oct 2017 09:59:14 GMT
IGNITE-6689: SQL: Added DATA_REGION option for CREATE TABLE.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/026254c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/026254c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/026254c5

Branch: refs/heads/ignite-5937
Commit: 026254c5173b681de9f1605d1697d80d614fe482
Parents: 3b18170
Author: devozerov <ppozerov@gmail.com>
Authored: Sat Oct 21 18:47:04 2017 +0300
Committer: devozerov <ppozerov@gmail.com>
Committed: Sat Oct 21 18:47:04 2017 +0300

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  1 +
 .../processors/query/GridQueryProcessor.java    |  6 ++-
 .../query/h2/ddl/DdlStatementsProcessor.java    |  2 +-
 .../query/h2/sql/GridSqlCreateTable.java        | 17 +++++++++
 .../query/h2/sql/GridSqlQueryParser.java        | 10 +++++
 .../cache/index/H2DynamicTableSelfTest.java     | 40 +++++++++++++++++++-
 6 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 25007c7..27c5767 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -39,6 +39,7 @@ SQL:
 * CREATE TABLE: Added NOT NULL support.
 * CREATE TABLE: Ability to specify cache, key type and value type names.
 * CREATE TABLE: Added "WRAP_KEY" and "WRAP_VALUE" options to CREATE TABLE command.
+* CREATE TABLE: Added DATA_REGION option.
 * CREATE TABLE: Added WRITE_SYNCHRONIZATION_MODE option.
 * ALTER TABLE: ADD COLUMN support.
 * Added lazy query execution mode (SqlFieldsQuery.setLazy).

http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 98428b6..4886b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1360,6 +1360,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param templateName Template name.
      * @param cacheName Cache name.
      * @param cacheGroup Cache group name.
+     * @param dataRegion Data region name.
      * @param affinityKey Affinity key column name.
      * @param atomicityMode Atomicity mode.
      * @param writeSyncMode Write synchronization mode.
@@ -1369,7 +1370,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      */
     @SuppressWarnings("unchecked")
     public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateName,
String cacheName,
-        String cacheGroup, String affinityKey, @Nullable CacheAtomicityMode atomicityMode,
+        String cacheGroup, @Nullable String dataRegion, String affinityKey, @Nullable CacheAtomicityMode
atomicityMode,
         @Nullable CacheWriteSynchronizationMode writeSyncMode, int backups, boolean ifNotExists)
         throws IgniteCheckedException {
         assert !F.isEmpty(templateName);
@@ -1403,6 +1404,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         if (!F.isEmpty(cacheGroup))
             ccfg.setGroupName(cacheGroup);
 
+        if (!F.isEmpty(dataRegion))
+            ccfg.setDataRegionName(dataRegion);
+
         if (atomicityMode != null)
             ccfg.setAtomicityMode(atomicityMode);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index f39e587..d29a063 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -184,7 +184,7 @@ public class DdlStatementsProcessor {
                         throw err;
 
                     ctx.query().dynamicTableCreate(cmd.schemaName(), e, cmd.templateName(),
cmd.cacheName(),
-                        cmd.cacheGroup(),cmd.affinityKey(), cmd.atomicityMode(),
+                        cmd.cacheGroup(), cmd.dataRegionName(), cmd.affinityKey(), cmd.atomicityMode(),
                         cmd.writeSynchronizationMode(), cmd.backups(), cmd.ifNotExists());
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
index de10826..3608aed 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
@@ -77,6 +77,9 @@ public class GridSqlCreateTable extends GridSqlStatement {
     /** Forcefully turn single column value into an Object. */
     private Boolean wrapVal;
 
+    /** Data region. */
+    private String dataRegionName;
+
     /** Extra WITH-params. */
     private List<String> params;
 
@@ -305,6 +308,20 @@ public class GridSqlCreateTable extends GridSqlStatement {
     }
 
     /**
+     * @return Data region name.
+     */
+    public String dataRegionName() {
+        return dataRegionName;
+    }
+
+    /**
+     * @param dataRegionName Data region name.
+     */
+    public void dataRegionName(String dataRegionName) {
+        this.dataRegionName = dataRegionName;
+    }
+
+    /**
      * @return Extra WITH-params.
      */
     public List<String> params() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index 280fb2d..46b2aee 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -480,6 +480,9 @@ public class GridSqlQueryParser {
     /** */
     public static final String PARAM_WRAP_VALUE = "WRAP_VALUE";
 
+    /** Data region name. */
+    public static final String PARAM_DATA_REGION = "DATA_REGION";
+
     /** */
     private final IdentityHashMap<Object, Object> h2ObjToGridObj = new IdentityHashMap<>();
 
@@ -1392,6 +1395,13 @@ public class GridSqlQueryParser {
 
                 break;
 
+            case PARAM_DATA_REGION:
+                ensureNotEmpty(name, val);
+
+                res.dataRegionName(val);
+
+                break;
+
             default:
                 throw new IgniteSQLException("Unsupported parameter: " + name, IgniteQueryErrorCode.PARSING);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/026254c5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index c56db84..ef59a62 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -44,6 +44,8 @@ import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
@@ -80,6 +82,12 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     /** */
     private final static String INDEXED_CACHE_NAME_2 = INDEXED_CACHE_NAME + "_2";
 
+    /** Data region name. */
+    public static final String DATA_REGION_NAME = "my_data_region";
+
+    /** Bad data region name. */
+    public static final String DATA_REGION_NAME_BAD = "my_data_region_bad";
+
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
@@ -779,7 +787,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
                 e.setKeyType("CityKey");
                 e.setValueType("City");
 
-                queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(),
null, null,
+                queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(),
null, null, null,
                     null, CacheAtomicityMode.ATOMIC, null, 10, false);
 
                 return null;
@@ -863,6 +871,33 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Test data region.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"ThrowableNotThrown", "unchecked"})
+    public void testDataRegion() throws Exception {
+        // Empty region name.
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int)
WITH \"data_region=\"");
+
+                return null;
+            }
+        }, IgniteSQLException.class, "Parameter value cannot be empty: DATA_REGION");
+
+        // Valid region name.
+        execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int) WITH
\"data_region=" +
+            DATA_REGION_NAME + "\"");
+
+        CacheConfiguration ccfg =
+            client().cache("SQL_PUBLIC_TEST_DATA_REGION").getConfiguration(CacheConfiguration.class);
+
+        assertEquals(DATA_REGION_NAME, ccfg.getDataRegionName());
+    }
+
+
+    /**
      * Test various cases of affinity key column specification.
      */
     @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@@ -1461,7 +1496,10 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest
{
     private IgniteConfiguration commonConfiguration(int idx) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(getTestIgniteInstanceName(idx));
 
+        DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration().setName(DATA_REGION_NAME);
+
         cfg.setMarshaller(new BinaryMarshaller());
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(dataRegionCfg));
 
         return optimize(cfg);
     }


Mime
View raw message