This is an automated email from the ASF dual-hosted git repository.

sdanilov pushed a commit to branch ignite-3.0.0-alpha5
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-3.0.0-alpha5 by this 
push:
     new 61649d294 IGNITE-17139 Fix creation of new RocksDB data regions and 
add examples
61649d294 is described below

commit 61649d2942bbeb99ef29e615b42d83d548d9b242
Author: Aleksandr Polovtsev <[email protected]>
AuthorDate: Wed Jun 8 20:29:59 2022 +0300

    IGNITE-17139 Fix creation of new RocksDB data regions and add examples
---
 assembly/README.md                                 |   2 +-
 docs/_docs/quick-start/getting-started-guide.adoc  |   8 +-
 docs/_docs/sql/jdbc-driver.adoc                    |   2 +-
 examples/README.md                                 |   1 +
 .../storage/ItRocksdbStorageExampleTest.java       |  50 +++++++++
 .../ignite/example/sql/jdbc/SqlJdbcExample.java    |   2 +-
 .../PersistentPageMemoryStorageExample.java        | 105 +-----------------
 .../example/storage/RocksDbStorageExample.java     |  59 ++++++++++
 ...orageExample.java => StorageEngineExample.java} |  59 ++++------
 .../storage/VolatilePageMemoryStorageExample.java  | 105 +-----------------
 .../ignite/example/table/KeyValueViewExample.java  |   2 +-
 .../example/table/KeyValueViewPojoExample.java     |   2 +-
 .../ignite/example/table/RecordViewExample.java    |   2 +-
 .../example/table/RecordViewPojoExample.java       |   2 +-
 .../ignite/example/tx/TransactionsExample.java     |   2 +-
 .../sql/engine/exec/MockedStructuresTest.java      |   7 +-
 .../storage/rocksdb/RocksDbStorageEngine.java      |  31 ++++--
 .../storage/rocksdb/RocksDbStorageEngineTest.java  | 123 +++++++++++++++++++++
 18 files changed, 297 insertions(+), 267 deletions(-)

diff --git a/assembly/README.md b/assembly/README.md
index d8ced5c6a..cfe10191d 100644
--- a/assembly/README.md
+++ b/assembly/README.md
@@ -47,7 +47,7 @@ The following examples are included:
 * `PersistentPageMemoryStorageExample` - demonstrates the usage of the 
PageMemory storage engine configured with a persistent data region.
 
 To run any other example, do the following:
-1. Import the examples project into you IDE.
+1. Import the examples project into your IDE.
 2. Start a server node using the CLI tool:
    ```
    ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json 
my-first-node
diff --git a/docs/_docs/quick-start/getting-started-guide.adoc 
b/docs/_docs/quick-start/getting-started-guide.adoc
index 5ffee3ecc..656b999d2 100644
--- a/docs/_docs/quick-start/getting-started-guide.adoc
+++ b/docs/_docs/quick-start/getting-started-guide.adoc
@@ -194,7 +194,7 @@ The project includes the following examples:
 
 To run any example, perform the following steps:
 
-. Import the examples project into you IDE.
+. Import the examples project into your IDE.
 
 . Start a server node using the CLI tool:
 +
@@ -225,9 +225,3 @@ From here, you may want to:
 //
 //Apache Ignite uses HOCON configuration format.
 //For more detail, please see the 
link:https://github.com/lightbend/config/blob/master/HOCON.md[HOCON 
documentation,window=_blank].
-
-
-
-
-
-
diff --git a/docs/_docs/sql/jdbc-driver.adoc b/docs/_docs/sql/jdbc-driver.adoc
index a4c9b501b..1d3a5d561 100644
--- a/docs/_docs/sql/jdbc-driver.adoc
+++ b/docs/_docs/sql/jdbc-driver.adoc
@@ -68,7 +68,7 @@ Examples are shipped as a separate Maven project, which is 
located in the `examp
 
 To run `SqlJdbcExample`, perform the following steps:
 
-. Import the examples project into you IDE;
+. Import the examples project into your IDE;
 . Start a server node using the CLI tool:
 +
 [source, shell]
diff --git a/examples/README.md b/examples/README.md
index 1a85dbcc6..7f92f9da1 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -12,6 +12,7 @@ The following examples are included:
 * `SqlApiExample` - demonstrates the usage of the Java API for SQL.
 * `VolatilePageMemoryStorageExample` - demonstrates the usage of the 
PageMemory storage engine configured with an in-memory data region.
 * `PersistentPageMemoryStorageExample` - demonstrates the usage of the 
PageMemory storage engine configured with a persistent data region.
+* `RocksDbStorageExample` - demonstrates the usage of the RocksDB storage 
engine.
 
 Before running the examples, read about 
[cli](https://ignite.apache.org/docs/3.0.0-alpha/ignite-cli-tool).
 
diff --git 
a/examples/src/integrationTest/java/org/apache/ignite/example/storage/ItRocksdbStorageExampleTest.java
 
b/examples/src/integrationTest/java/org/apache/ignite/example/storage/ItRocksdbStorageExampleTest.java
new file mode 100644
index 000000000..ffc1f483e
--- /dev/null
+++ 
b/examples/src/integrationTest/java/org/apache/ignite/example/storage/ItRocksdbStorageExampleTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.example.storage;
+
+import static 
org.apache.ignite.example.ExampleTestUtils.assertConsoleOutputContains;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.example.AbstractExamplesTest;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbStorageEngineConfiguration;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for {@link RocksDbStorageExample}.
+ */
+public class ItRocksdbStorageExampleTest extends AbstractExamplesTest {
+    @Test
+    public void testExample() throws Exception {
+        addDataRegionConfig("rocksdb-example");
+
+        assertConsoleOutputContains(RocksDbStorageExample::main, EMPTY_ARGS,
+                "\nAll accounts:\n"
+                        + "    1, John, Doe, 1000.0\n"
+                        + "    2, Jane, Roe, 2000.0\n"
+                        + "    3, Mary, Major, 1500.0\n"
+                        + "    4, Richard, Miles, 1450.0\n"
+        );
+    }
+
+    private void addDataRegionConfig(String name) throws Exception {
+        
ignite.clusterConfiguration().getConfiguration(RocksDbStorageEngineConfiguration.KEY)
+                .regions()
+                .change(regionsChange -> regionsChange.create(name, 
regionChange -> {}))
+                .get(1, TimeUnit.SECONDS);
+    }
+}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/sql/jdbc/SqlJdbcExample.java 
b/examples/src/main/java/org/apache/ignite/example/sql/jdbc/SqlJdbcExample.java
index ed6e4f622..efbd9886e 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/sql/jdbc/SqlJdbcExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/sql/jdbc/SqlJdbcExample.java
@@ -28,7 +28,7 @@ import java.sql.Statement;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/storage/PersistentPageMemoryStorageExample.java
 
b/examples/src/main/java/org/apache/ignite/example/storage/PersistentPageMemoryStorageExample.java
index 649397512..db5ccb09b 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/storage/PersistentPageMemoryStorageExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/storage/PersistentPageMemoryStorageExample.java
@@ -17,18 +17,12 @@
 
 package org.apache.ignite.example.storage;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
 /**
  * This example demonstrates a usage of the PageMemory storage engine 
configured with a persistent data region.
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
@@ -42,7 +36,7 @@ import java.sql.Statement;
  *         {@code ignite cluster init --cluster-name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
  *     </li>
  *     <li>
- *         Add configuration for persistent data region of of the PageMemory 
storage engine using the CLI tool (if not done yet):<br>
+ *         Add configuration for a persistent data region of the PageMemory 
storage engine using the CLI tool (if not done yet):<br>
  *         {@code ignite cluster config update 
"pageMemory.regions.persistent:{persistent=true}"}
  *     </li>
  *     <li>Run the example in the IDE.</li>
@@ -60,99 +54,6 @@ public class PersistentPageMemoryStorageExample {
      * @throws Exception If failed.
      */
     public static void main(String[] args) throws Exception {
-        
//--------------------------------------------------------------------------------------
-        //
-        // Creating a JDBC connection to connect to the cluster.
-        //
-        
//--------------------------------------------------------------------------------------
-
-        System.out.println("\nConnecting to server...");
-
-        try (Connection conn = 
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800/")) {
-            
//--------------------------------------------------------------------------------------
-            //
-            // Creating table.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            try (Statement stmt = conn.createStatement()) {
-                stmt.executeUpdate(
-                        "CREATE TABLE ACCOUNTS ( "
-                                + "ACCOUNT_ID INT PRIMARY KEY,"
-                                + "FIRST_NAME VARCHAR, "
-                                + "LAST_NAME  VARCHAR, "
-                                + "BALANCE    DOUBLE) "
-                                + "ENGINE pagememory "
-                                + "WITH dataRegion='persistent'"
-                );
-            }
-
-            
//--------------------------------------------------------------------------------------
-            //
-            // Populating 'ACCOUNTS' table.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            System.out.println("\nPopulating 'ACCOUNTS' table...");
-
-            try (PreparedStatement stmt = conn.prepareStatement(
-                    "INSERT INTO ACCOUNTS (ACCOUNT_ID, FIRST_NAME, LAST_NAME, 
BALANCE) values (?, ?, ?, ?)"
-            )) {
-                stmt.setInt(1, 1);
-                stmt.setString(2, "John");
-                stmt.setString(3, "Doe");
-                stmt.setDouble(4, 1000.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 2);
-                stmt.setString(2, "Jane");
-                stmt.setString(3, "Roe");
-                stmt.setDouble(4, 2000.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 3);
-                stmt.setString(2, "Mary");
-                stmt.setString(3, "Major");
-                stmt.setDouble(4, 1500.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 4);
-                stmt.setString(2, "Richard");
-                stmt.setString(3, "Miles");
-                stmt.setDouble(4, 1450.0d);
-                stmt.executeUpdate();
-            }
-
-            
//--------------------------------------------------------------------------------------
-            //
-            // Requesting information about all account owners.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            System.out.println("\nAll accounts:");
-
-            try (Statement stmt = conn.createStatement()) {
-                try (ResultSet rs = stmt.executeQuery(
-                        "SELECT ACCOUNT_ID, FIRST_NAME, LAST_NAME, BALANCE 
FROM ACCOUNTS ORDER BY ACCOUNT_ID"
-                )) {
-                    while (rs.next()) {
-                        System.out.println("    "
-                                + rs.getString(1) + ", "
-                                + rs.getString(2) + ", "
-                                + rs.getString(3) + ", "
-                                + rs.getString(4));
-                    }
-                }
-            }
-        } finally {
-            System.out.println("\nDropping the table...");
-
-            try (
-                    Connection conn = 
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800/");
-                    Statement stmt = conn.createStatement()
-            ) {
-                stmt.executeUpdate("DROP TABLE ACCOUNTS");
-            }
-        }
+        new StorageEngineExample("pagememory", "persistent").run();
     }
 }
diff --git 
a/examples/src/main/java/org/apache/ignite/example/storage/RocksDbStorageExample.java
 
b/examples/src/main/java/org/apache/ignite/example/storage/RocksDbStorageExample.java
new file mode 100644
index 000000000..892285583
--- /dev/null
+++ 
b/examples/src/main/java/org/apache/ignite/example/storage/RocksDbStorageExample.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.example.storage;
+
+/**
+ * This example demonstrates a usage of the RocksDB storage engine.
+ *
+ * <p>To run the example, do the following:
+ * <ol>
+ *     <li>Import the examples project into your IDE.</li>
+ *     <li>
+ *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
+ *         {@code ignite bootstrap}
+ *     </li>
+ *     <li>
+ *         Start an Ignite node using the CLI tool:<br>
+ *         {@code ignite node start 
--config=$IGNITE_HOME/examples/config/ignite-config.json my-first-node}
+ *     </li>
+ *     <li>
+ *         Cluster initialization using the CLI tool (if not done yet):<br>
+ *         {@code ignite cluster init --cluster-name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
+ *     </li>
+ *     <li>
+ *         Add configuration for a data region of the RocksDB storage engine 
using the CLI tool (if not done yet):<br>
+ *         {@code ignite cluster config update 
"rocksDb.regions.rocksdb-example{}"}
+ *     </li>
+ *     <li>Run the example in the IDE.</li>
+ *     <li>
+ *         Stop the Ignite node using the CLI tool:<br>
+ *         {@code ignite node stop my-first-node}
+ *     </li>
+ * </ol>
+ */
+public class RocksDbStorageExample {
+    /**
+     * Main method of the example.
+     *
+     * @param args The command line arguments.
+     * @throws Exception If failed.
+     */
+    public static void main(String[] args) throws Exception {
+        new StorageEngineExample("rocksdb", "rocksdb-example").run();
+    }
+}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
 
b/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
similarity index 73%
copy from 
examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
copy to 
examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
index 329864061..51c0639f8 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
@@ -1,6 +1,6 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
@@ -21,45 +21,34 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.sql.Statement;
 
 /**
- * This example demonstrates a usage of the PageMemory storage engine 
configured with an in-memory data region.
- *
- * <p>To run the example, do the following:
- * <ol>
- *     <li>Import the examples project into you IDE.</li>
- *     <li>
- *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
- *         {@code ignite bootstrap}
- *     </li>
- *     <li>
- *         Start an Ignite node using the CLI tool:<br>
- *         {@code ignite node start 
--config=$IGNITE_HOME/examples/config/ignite-config.json my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --cluster-name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </li>
- *     <li>
- *         Add configuration for in-memory data region of of the PageMemory 
storage engine using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster config update 
"pageMemory.regions.in-memory:{persistent=false}"}
- *     </li>
- *     <li>Run the example in the IDE.</li>
- *     <li>
- *         Stop the Ignite node using the CLI tool:<br>
- *         {@code ignite node stop my-first-node}
- *     </li>
- * </ol>
+ * Class for executing examples that demonstrate working with different 
storage engines.
  */
-public class VolatilePageMemoryStorageExample {
+class StorageEngineExample {
+    private final String engineName;
+
+    private final String dataRegionName;
+
+    /**
+     * Creates an instance of the example runner.
+     *
+     * @param engineName Name of the storage engine, that created SQL tables 
will use.
+     * @param dataRegionName Name of the data region, that created SQL tables 
will use.
+     */
+    StorageEngineExample(String engineName, String dataRegionName) {
+        this.engineName = engineName;
+        this.dataRegionName = dataRegionName;
+    }
+
     /**
-     * Main method of the example.
+     * Executes the example.
      *
-     * @param args The command line arguments.
-     * @throws Exception If failed.
+     * @throws SQLException In any of the SQL statements fail.
      */
-    public static void main(String[] args) throws Exception {
+    void run() throws SQLException {
         
//--------------------------------------------------------------------------------------
         //
         // Creating a JDBC connection to connect to the cluster.
@@ -82,8 +71,8 @@ public class VolatilePageMemoryStorageExample {
                                 + "FIRST_NAME VARCHAR, "
                                 + "LAST_NAME  VARCHAR, "
                                 + "BALANCE    DOUBLE) "
-                                + "ENGINE pagememory "
-                                + "WITH dataRegion='in-memory'"
+                                + " ENGINE " + engineName
+                                + " WITH dataRegion='" + dataRegionName + "'"
                 );
             }
 
diff --git 
a/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
 
b/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
index 329864061..96cbb93ef 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/storage/VolatilePageMemoryStorageExample.java
@@ -17,18 +17,12 @@
 
 package org.apache.ignite.example.storage;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
 /**
  * This example demonstrates a usage of the PageMemory storage engine 
configured with an in-memory data region.
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
@@ -42,7 +36,7 @@ import java.sql.Statement;
  *         {@code ignite cluster init --cluster-name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
  *     </li>
  *     <li>
- *         Add configuration for in-memory data region of of the PageMemory 
storage engine using the CLI tool (if not done yet):<br>
+ *         Add configuration for an in-memory data region of the PageMemory 
storage engine using the CLI tool (if not done yet):<br>
  *         {@code ignite cluster config update 
"pageMemory.regions.in-memory:{persistent=false}"}
  *     </li>
  *     <li>Run the example in the IDE.</li>
@@ -60,99 +54,6 @@ public class VolatilePageMemoryStorageExample {
      * @throws Exception If failed.
      */
     public static void main(String[] args) throws Exception {
-        
//--------------------------------------------------------------------------------------
-        //
-        // Creating a JDBC connection to connect to the cluster.
-        //
-        
//--------------------------------------------------------------------------------------
-
-        System.out.println("\nConnecting to server...");
-
-        try (Connection conn = 
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800/")) {
-            
//--------------------------------------------------------------------------------------
-            //
-            // Creating table.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            try (Statement stmt = conn.createStatement()) {
-                stmt.executeUpdate(
-                        "CREATE TABLE ACCOUNTS ( "
-                                + "ACCOUNT_ID INT PRIMARY KEY,"
-                                + "FIRST_NAME VARCHAR, "
-                                + "LAST_NAME  VARCHAR, "
-                                + "BALANCE    DOUBLE) "
-                                + "ENGINE pagememory "
-                                + "WITH dataRegion='in-memory'"
-                );
-            }
-
-            
//--------------------------------------------------------------------------------------
-            //
-            // Populating 'ACCOUNTS' table.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            System.out.println("\nPopulating 'ACCOUNTS' table...");
-
-            try (PreparedStatement stmt = conn.prepareStatement(
-                    "INSERT INTO ACCOUNTS (ACCOUNT_ID, FIRST_NAME, LAST_NAME, 
BALANCE) values (?, ?, ?, ?)"
-            )) {
-                stmt.setInt(1, 1);
-                stmt.setString(2, "John");
-                stmt.setString(3, "Doe");
-                stmt.setDouble(4, 1000.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 2);
-                stmt.setString(2, "Jane");
-                stmt.setString(3, "Roe");
-                stmt.setDouble(4, 2000.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 3);
-                stmt.setString(2, "Mary");
-                stmt.setString(3, "Major");
-                stmt.setDouble(4, 1500.0d);
-                stmt.executeUpdate();
-
-                stmt.setInt(1, 4);
-                stmt.setString(2, "Richard");
-                stmt.setString(3, "Miles");
-                stmt.setDouble(4, 1450.0d);
-                stmt.executeUpdate();
-            }
-
-            
//--------------------------------------------------------------------------------------
-            //
-            // Requesting information about all account owners.
-            //
-            
//--------------------------------------------------------------------------------------
-
-            System.out.println("\nAll accounts:");
-
-            try (Statement stmt = conn.createStatement()) {
-                try (ResultSet rs = stmt.executeQuery(
-                        "SELECT ACCOUNT_ID, FIRST_NAME, LAST_NAME, BALANCE 
FROM ACCOUNTS ORDER BY ACCOUNT_ID"
-                )) {
-                    while (rs.next()) {
-                        System.out.println("    "
-                                + rs.getString(1) + ", "
-                                + rs.getString(2) + ", "
-                                + rs.getString(3) + ", "
-                                + rs.getString(4));
-                    }
-                }
-            }
-        } finally {
-            System.out.println("\nDropping the table...");
-
-            try (
-                    Connection conn = 
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800/");
-                    Statement stmt = conn.createStatement()
-            ) {
-                stmt.executeUpdate("DROP TABLE ACCOUNTS");
-            }
-        }
+        new StorageEngineExample("pagememory", "in-memory").run();
     }
 }
diff --git 
a/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewExample.java
 
b/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewExample.java
index 508f37457..b91766319 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewExample.java
@@ -29,7 +29,7 @@ import org.apache.ignite.table.Tuple;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewPojoExample.java
 
b/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewPojoExample.java
index 497218535..d67886d28 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewPojoExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/table/KeyValueViewPojoExample.java
@@ -28,7 +28,7 @@ import org.apache.ignite.table.KeyValueView;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/table/RecordViewExample.java 
b/examples/src/main/java/org/apache/ignite/example/table/RecordViewExample.java
index eb1926dd6..1ca087d74 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/table/RecordViewExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/table/RecordViewExample.java
@@ -29,7 +29,7 @@ import org.apache.ignite.table.Tuple;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/table/RecordViewPojoExample.java
 
b/examples/src/main/java/org/apache/ignite/example/table/RecordViewPojoExample.java
index df43264e4..c6942ff96 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/table/RecordViewPojoExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/table/RecordViewPojoExample.java
@@ -28,7 +28,7 @@ import org.apache.ignite.table.RecordView;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/examples/src/main/java/org/apache/ignite/example/tx/TransactionsExample.java 
b/examples/src/main/java/org/apache/ignite/example/tx/TransactionsExample.java
index f032b2c04..f79463bb3 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/tx/TransactionsExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/tx/TransactionsExample.java
@@ -30,7 +30,7 @@ import org.apache.ignite.tx.IgniteTransactions;
  *
  * <p>To run the example, do the following:
  * <ol>
- *     <li>Import the examples project into you IDE.</li>
+ *     <li>Import the examples project into your IDE.</li>
  *     <li>
  *         Download and prepare artifacts for running an Ignite node using the 
CLI tool (if not done yet):<br>
  *         {@code ignite bootstrap}
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/MockedStructuresTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/MockedStructuresTest.java
index 5cab8e634..f57f3a6a4 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/MockedStructuresTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/MockedStructuresTest.java
@@ -227,9 +227,6 @@ public class MockedStructuresTest extends 
IgniteAbstractTest {
                 new TestConcurrentHashMapDataStorageModule()
         ));
 
-        rocksDbEngineConfig.regions().change(c -> c.create("test_region", 
rocksDbDataRegionChange -> {
-        })).get(1, TimeUnit.SECONDS);
-
         dataStorageManager = new DataStorageManager(
                 tblsCfg,
                 dataStorageModules.createStorageEngines(NODE_NAME, 
configRegistry, workDir, null)
@@ -253,6 +250,10 @@ public class MockedStructuresTest extends 
IgniteAbstractTest {
         queryProc.start();
 
         tblsCfg.defaultDataStorage().update(ENGINE_NAME).get(1, 
TimeUnit.SECONDS);
+
+        rocksDbEngineConfig.regions()
+                .change(c -> c.create("test_region", rocksDbDataRegionChange 
-> {}))
+                .get(1, TimeUnit.SECONDS);
     }
 
     /**
diff --git 
a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngine.java
 
b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngine.java
index 701effbac..f4f46fce8 100644
--- 
a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngine.java
+++ 
b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngine.java
@@ -17,22 +17,25 @@
 
 package org.apache.ignite.internal.storage.rocksdb;
 
-import static 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbStorageEngineConfigurationSchema.DEFAULT_DATA_REGION_NAME;
-
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+import 
org.apache.ignite.configuration.notifications.ConfigurationNamedListListener;
+import 
org.apache.ignite.configuration.notifications.ConfigurationNotificationEvent;
 import org.apache.ignite.configuration.schemas.table.TableConfiguration;
 import org.apache.ignite.configuration.schemas.table.TableView;
 import org.apache.ignite.internal.storage.StorageException;
 import org.apache.ignite.internal.storage.engine.MvTableStorage;
 import org.apache.ignite.internal.storage.engine.StorageEngine;
 import org.apache.ignite.internal.storage.engine.TableStorage;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbDataRegionConfiguration;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbDataRegionView;
 import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbDataStorageView;
 import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbStorageEngineConfiguration;
 import org.apache.ignite.internal.thread.NamedThreadFactory;
@@ -75,19 +78,27 @@ public class RocksDbStorageEngine implements StorageEngine {
     /** {@inheritDoc} */
     @Override
     public void start() throws StorageException {
-        RocksDbDataRegion defaultRegion = new 
RocksDbDataRegion(engineConfig.defaultRegion());
+        registerDataRegion(engineConfig.defaultRegion());
+
+        // TODO: IGNITE-17066 Add handling deleting/updating data regions 
configuration
+        engineConfig.regions().listenElements(new 
ConfigurationNamedListListener<>() {
+            @Override
+            public CompletableFuture<?> 
onCreate(ConfigurationNotificationEvent<RocksDbDataRegionView> ctx) {
+                
registerDataRegion(ctx.config(RocksDbDataRegionConfiguration.class));
 
-        defaultRegion.start();
+                return CompletableFuture.completedFuture(null);
+            }
+        });
+    }
 
-        regions.put(DEFAULT_DATA_REGION_NAME, defaultRegion);
+    private void registerDataRegion(RocksDbDataRegionConfiguration 
dataRegionConfig) {
+        var region = new RocksDbDataRegion(dataRegionConfig);
 
-        for (String regionName : 
engineConfig.regions().value().namedListKeys()) {
-            RocksDbDataRegion region = new 
RocksDbDataRegion(engineConfig.regions().get(regionName));
+        region.start();
 
-            region.start();
+        RocksDbDataRegion previousRegion = 
regions.put(dataRegionConfig.name().value(), region);
 
-            regions.put(regionName, region);
-        }
+        assert previousRegion == null : dataRegionConfig.name().value();
     }
 
     /** {@inheritDoc} */
diff --git 
a/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngineTest.java
 
b/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngineTest.java
new file mode 100644
index 000000000..021be17d8
--- /dev/null
+++ 
b/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/RocksDbStorageEngineTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.storage.rocksdb;
+
+import static 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbStorageEngineConfigurationSchema.DEFAULT_DATA_REGION_NAME;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import java.nio.file.Path;
+import java.util.concurrent.CompletableFuture;
+import 
org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema;
+import org.apache.ignite.configuration.schemas.table.TableConfiguration;
+import 
org.apache.ignite.internal.configuration.testframework.ConfigurationExtension;
+import 
org.apache.ignite.internal.configuration.testframework.InjectConfiguration;
+import org.apache.ignite.internal.storage.engine.TableStorage;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbDataStorageConfiguration;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbDataStorageConfigurationSchema;
+import 
org.apache.ignite.internal.storage.rocksdb.configuration.schema.RocksDbStorageEngineConfiguration;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * Tests for {@link RocksDbStorageEngine}.
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+@ExtendWith(ConfigurationExtension.class)
+public class RocksDbStorageEngineTest {
+    private RocksDbStorageEngine engine;
+
+    @InjectConfiguration
+    private RocksDbStorageEngineConfiguration engineConfig;
+
+    @BeforeEach
+    void setUp(@WorkDirectory Path workDir) {
+        engine = new RocksDbStorageEngine(engineConfig, workDir);
+
+        engine.start();
+    }
+
+    @AfterEach
+    void tearDown() {
+        engine.stop();
+    }
+
+    @Test
+    void testCreateTableWithDefaultDataRegion(
+            @InjectConfiguration(
+                    value = "mock.dataStorage.name=rocksdb",
+                    name = "table",
+                    polymorphicExtensions = {
+                            HashIndexConfigurationSchema.class,
+                            RocksDbDataStorageConfigurationSchema.class
+                    }
+            ) TableConfiguration tableCfg
+    ) {
+        TableStorage table = engine.createTable(tableCfg);
+
+        table.start();
+
+        try {
+            RocksDbDataStorageConfiguration dataStorageConfig = 
(RocksDbDataStorageConfiguration) table.configuration().dataStorage();
+
+            assertThat(dataStorageConfig.dataRegion().value(), 
is(DEFAULT_DATA_REGION_NAME));
+
+            table.getOrCreatePartition(1);
+        } finally {
+            table.stop();
+        }
+    }
+
+    @Test
+    void testCreateTableWithDynamicCustomDataRegion(
+            @InjectConfiguration(
+                    value = "mock.dataStorage{name=rocksdb, 
dataRegion=foobar}",
+                    name = "table",
+                    polymorphicExtensions = {
+                            HashIndexConfigurationSchema.class,
+                            RocksDbDataStorageConfigurationSchema.class
+                    }
+            ) TableConfiguration tableCfg
+    ) {
+        String customRegionName = "foobar";
+
+        CompletableFuture<Void> engineConfigChangeFuture = 
engineConfig.regions()
+                .change(c -> c.create(customRegionName, 
rocksDbDataRegionChange -> {}));
+
+        assertThat(engineConfigChangeFuture, willCompleteSuccessfully());
+
+        TableStorage table = engine.createTable(tableCfg);
+
+        table.start();
+
+        try {
+            RocksDbDataStorageConfiguration dataStorageConfig = 
(RocksDbDataStorageConfiguration) table.configuration().dataStorage();
+
+            assertThat(dataStorageConfig.dataRegion().value(), 
is(customRegionName));
+
+            table.getOrCreatePartition(1);
+        } finally {
+            table.stop();
+        }
+    }
+}

Reply via email to