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

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


The following commit(s) were added to refs/heads/main by this push:
     new 3acfe1c97e IGNITE-22264 Fix startup instructions in Ignite examples 
(#3967)
3acfe1c97e is described below

commit 3acfe1c97ecae87fd850af4d34a66641d62685ba
Author: Ivan Artiukhov <[email protected]>
AuthorDate: Thu Jun 27 21:08:06 2024 +0300

    IGNITE-22264 Fix startup instructions in Ignite examples (#3967)
---
 examples/README.md                                 | 78 +++++++++++++++++++++-
 examples/config/ignite-config.conf                 | 23 +++++--
 .../apache/ignite/example/sql/SqlApiExample.java   |  2 +
 .../ignite/example/sql/jdbc/SqlJdbcExample.java    | 22 +-----
 .../PersistentPageMemoryStorageExample.java        | 26 +-------
 .../example/storage/RocksDbStorageExample.java     | 26 +-------
 .../storage/VolatilePageMemoryStorageExample.java  | 26 +-------
 .../ignite/example/table/KeyValueViewExample.java  | 22 +-----
 .../example/table/KeyValueViewPojoExample.java     | 22 +-----
 .../ignite/example/table/RecordViewExample.java    | 22 +-----
 .../example/table/RecordViewPojoExample.java       | 22 +-----
 .../ignite/example/tx/TransactionsExample.java     | 22 +-----
 12 files changed, 102 insertions(+), 211 deletions(-)

diff --git a/examples/README.md b/examples/README.md
index 39f9004d80..1d94277909 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,9 +1,11 @@
 # Apache Ignite 3 Examples
 
+## Overview
+
 This project contains code examples for Apache Ignite 3.
 
 Examples are shipped as a separate Gradle module, so to start running you 
simply need
-to import provided `build.gradle` file into your favourite IDE.
+to import the provided `build.gradle` file into your favourite IDE.
 
 The following examples are included:
 * `RecordViewExample` - demonstrates the usage of the 
`org.apache.ignite.table.RecordView` API
@@ -14,6 +16,76 @@ The following examples are included:
 * `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-beta/ignite-cli-tool).
+## Running examples with an Ignite node within a Docker container
+
+1. Open the Ignite project in your IDE of choice.
+
+2. Prepare an environment variable:
+```shell
+IGNITE_SOURCES=/path/to/ignite3-sources-dir
+```
+
+3. Build the Ignite Docker image. As a result the `apacheignite/ignite3` image 
will be built and loaded into the Docker Engine:
+```shell
+cd $IGNITE_SOURCES; ./gradlew clean docker
+```
+
+4. Start an Ignite node:
+```shell
+docker run --name ignite3-node -d --rm -p 10300:10300 -p 10800:10800 \
+  -v 
$IGNITE_SOURCES/examples/config/ignite-config.conf:/opt/ignite/etc/ignite-config.conf
 apacheignite/ignite3
+```
+
+5. Get the IP address of the node:
+```shell
+NODE_IP_ADDRESS=$(docker inspect --format='{{range 
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ignite3-node)
+```
+
+6. Initialize the node:
+```shell
+docker run -it apacheignite/ignite3 cli cluster init --url 
http://$NODE_IP_ADDRESS:10300 --name myCluster1 \
+  --cluster-management-group defaultNode --metastorage-group defaultNode
+```
+
+7. Run the example via IDE.
+
+8. Stop the Ignite node:
+```shell
+docker stop ignite3-node
+```
+
+## Running examples with an Ignite node started natively
+
+1. Open the Ignite project in your IDE of choice.
+
+2. Download the Ignite ZIP package including the database and CLI parts. 
Alternatively, build these parts from the Ignite sources 
+(see [DEVNOTES.md](../DEVNOTES.md)). Unpack.
+
+3. Prepare the environment variables. `IGNITE_HOME` is used in the Ignite 
startup. Therefore, you need to export it:
+```shell
+export IGNITE_HOME=/path/to/ignite3-db-dir
+IGNITE_CLI_HOME=/path/to/ignite3-cli-dir
+IGNITE_SOURCES=/path/to/ignite3-sources-dir
+```
+
+4. Override the default configuration file:
+```shell
+echo "CONFIG_FILE=$IGNITE_SOURCES/examples/config/ignite-config.conf" >> 
$IGNITE_HOME/etc/vars.env
+```
+
+5. Start an Ignite node using the startup script from the database part:
+```shell
+$IGNITE_HOME/bin/ignite3db start
+```
+
+6. Initialize the cluster using Ignite CLI from the CLI part:
+```shell
+$IGNITE_CLI_HOME/bin/ignite3 cluster init --name myCluster1 
--metastorage-group defaultNode --cluster-management-group defaultNode
+```
+
+7. Run the example from the IDE.
 
-To run the examples, refer to their JavaDoc for instructions.
+8. Stop the Ignite node using the startup script:
+```shell
+$IGNITE_HOME/bin/ignite3db stop
+```
\ No newline at end of file
diff --git a/examples/config/ignite-config.conf 
b/examples/config/ignite-config.conf
index 90440e9ed9..15381e1d52 100644
--- a/examples/config/ignite-config.conf
+++ b/examples/config/ignite-config.conf
@@ -7,13 +7,22 @@ network {
     port=3344
 }
 storage {
-    profiles {
-        "in-memory" {engine: "aimem"}
-        "persistent" {engine: "aipersist"}
-        "rocksdb-example" : {engine: "rocksdb"}
-    }
+    profiles=[
+        {
+            name=persistent
+            engine=aipersist
+        }
+        {
+            name=rocksdb-example
+            engine=rocksdb
+        }
+        {
+            name=in-memory
+            engine=aimem
+        }
+    ]
 }
 nodeAttributes.nodeAttributes {
-      region.attribute = "US"
-      storage.attribute = "SSD"
+      region.attribute=US
+      storage.attribute=SSD
 }
diff --git 
a/examples/src/main/java/org/apache/ignite/example/sql/SqlApiExample.java 
b/examples/src/main/java/org/apache/ignite/example/sql/SqlApiExample.java
index e94b4ea7b9..b9a762ce48 100644
--- a/examples/src/main/java/org/apache/ignite/example/sql/SqlApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/example/sql/SqlApiExample.java
@@ -32,6 +32,8 @@ import org.apache.ignite.tx.TransactionOptions;
 
 /**
  * Examples of using SQL API.
+ *
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class SqlApiExample {
     /**
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 bb7bec9bbe..6d351553f8 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
@@ -26,27 +26,7 @@ import java.sql.Statement;
 /**
  * This example demonstrates the usage of the Apache Ignite JDBC driver.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class SqlJdbcExample {
     /**
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 3de2a5c7aa..2117bbb219 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
@@ -20,31 +20,7 @@ package org.apache.ignite.example.storage;
 /**
  * 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 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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </li>
- *     <li>
- *         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 "aipersist.regions.persistent"}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class PersistentPageMemoryStorageExample {
     /**
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
index a7fbf9514f..34a8c9e943 100644
--- 
a/examples/src/main/java/org/apache/ignite/example/storage/RocksDbStorageExample.java
+++ 
b/examples/src/main/java/org/apache/ignite/example/storage/RocksDbStorageExample.java
@@ -20,31 +20,7 @@ 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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class RocksDbStorageExample {
     /**
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 c720efdb34..1cd54dcf80 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
@@ -20,31 +20,7 @@ package org.apache.ignite.example.storage;
 /**
  * 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 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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </li>
- *     <li>
- *         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 "aimem.regions.in-memory"}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class VolatilePageMemoryStorageExample {
     /**
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 4ba1d62e27..c6c7743fe6 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
@@ -27,27 +27,7 @@ import org.apache.ignite.table.Tuple;
 /**
  * This example demonstrates the usage of the {@link KeyValueView} API.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class KeyValueViewExample {
     /**
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 501291182f..ec470876e3 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
@@ -26,27 +26,7 @@ import org.apache.ignite.table.KeyValueView;
 /**
  * This example demonstrates the usage of the {@link KeyValueView} API with 
user-defined POJOs.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class KeyValueViewPojoExample {
     /**
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 81113cdfee..af1d275e7e 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
@@ -27,27 +27,7 @@ import org.apache.ignite.table.Tuple;
 /**
  * This example demonstrates the usage of the {@link RecordView} API.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class RecordViewExample {
     /**
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 e810fbc4ec..5d5a1d95cc 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
@@ -26,27 +26,7 @@ import org.apache.ignite.table.RecordView;
 /**
  * This example demonstrates the usage of the {@link RecordView} API with 
user-defined POJOs.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class RecordViewPojoExample {
     /**
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 87150ce4d0..0b6768c598 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
@@ -28,27 +28,7 @@ import org.apache.ignite.tx.IgniteTransactions;
 /**
  * This example demonstrates the usage of the {@link IgniteTransactions} API.
  *
- * <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.conf my-first-node}
- *     </li>
- *     <li>
- *         Cluster initialization using the CLI tool (if not done yet):<br>
- *         {@code ignite cluster init --name=ignite-cluster 
--node-endpoint=localhost:10300 --meta-storage-node=my-first-node}
- *     </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>
+ * <p>Find instructions on how to run the example in the README.md file 
located in the "examples" directory root.
  */
 public class TransactionsExample {
     /**

Reply via email to