You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2021/06/25 03:25:41 UTC

[ignite-3] branch ignite-3.0.0-alpha2 updated (2ae6c60 -> a314651)

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

vkulichenko pushed a change to branch ignite-3.0.0-alpha2
in repository https://gitbox.apache.org/repos/asf/ignite-3.git.


    from 2ae6c60  Update version to 3.0.0-alpha2
     new dda1590  IGNITE-14992 - Temporarily commenting out the warning to avoid excessive output
     new 1f6acbb  IGNITE-14993 - Choose available port out of a range
     new 9b31400  IGNITE-14994 - Topology snapshot print out
     new d63d7a2  IGNITE-14995 - Updated NOTICE
     new 2090ad7  IGNITE-14996 - Added examples for Table and KeyValueBinaryView
     new d26631c  IGNITE-14993 - Choose available port out of a range
     new a314651  IGNITE-14996 - Updated examples structure

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 NOTICE                                             |   5 +
 assembly/NOTICE                                    |   0
 assembly/assembly.xml                              |  29 +++++-
 examples/README.md                                 |  21 ++++
 examples/config/ignite-config.json                 |  13 +++
 .../pom.xml => examples/pom-standalone.xml         |  21 ++--
 {modules/cli-common => examples}/pom.xml           |   9 +-
 .../example/table/KeyValueBinaryViewExample.java   | 113 +++++++++++++++++++++
 .../apache/ignite/example/table/TableExample.java  | 109 ++++++++++++++++++++
 .../org/apache/ignite/network/ClusterNode.java     |   2 +
 .../network/internal/netty/ConnectionManager.java  |   2 +
 .../ignite/network/internal/netty/NettyServer.java |  17 +++-
 .../scalecube/ScaleCubeTopologyService.java        |  16 +++
 .../ignite/raft/server/impl/RaftServerImpl.java    |   7 +-
 parent/pom.xml                                     |  12 ++-
 pom.xml                                            |   1 +
 16 files changed, 353 insertions(+), 24 deletions(-)
 create mode 100644 NOTICE
 delete mode 100644 assembly/NOTICE
 create mode 100644 examples/README.md
 create mode 100644 examples/config/ignite-config.json
 copy modules/cli-common/pom.xml => examples/pom-standalone.xml (76%)
 copy {modules/cli-common => examples}/pom.xml (85%)
 create mode 100644 examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
 create mode 100644 examples/src/main/java/org/apache/ignite/example/table/TableExample.java

[ignite-3] 07/07: IGNITE-14996 - Updated examples structure

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a3146514b18d3c7bf6522fb423d6cc262257531c
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 20:25:23 2021 -0700

    IGNITE-14996 - Updated examples structure
---
 assembly/assembly.xml                              |   1 +
 examples/README.md                                 |  21 ++++
 .../main/resources => config}/ignite-config.json   |   2 +-
 .../example/table/KeyValueBinaryViewExample.java   |  21 +++-
 .../apache/ignite/example/table/TableExample.java  | 124 ++++++++++++---------
 5 files changed, 110 insertions(+), 59 deletions(-)

diff --git a/assembly/assembly.xml b/assembly/assembly.xml
index d5d256b..04a7975 100644
--- a/assembly/assembly.xml
+++ b/assembly/assembly.xml
@@ -69,6 +69,7 @@
             <directory>examples</directory>
             <outputDirectory>/examples</outputDirectory>
             <includes>
+                <include>config/**</include>
                 <include>src/**</include>
             </includes>
         </fileSet>
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 0000000..8e1b30b
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,21 @@
+# Apache Ignite 3 Examples
+
+This project contains code examples for Apache Ignite 3.
+
+Examples are shipped as a separate Maven project, so to start running you simply need
+to import provided `pom.xml` file into your favourite IDE.
+
+The following examples are included:
+* `TableExample` - demonstrates the usage of the `org.apache.ignite.table.Table` API
+* `KeyValueBinaryViewExample` - demonstrates the usage of the `org.apache.ignite.table.KeyValueBinaryView` API
+
+To run an example, do the following:
+1. Import the examples project into you IDE.
+2. (optional) Run one or more standalone nodes using the CLI tool:
+    ```
+    ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-1
+    ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-2
+    ...
+    ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-n
+    ```
+3. Run the preferred example in the IDE.
diff --git a/examples/src/main/resources/ignite-config.json b/examples/config/ignite-config.json
similarity index 81%
rename from examples/src/main/resources/ignite-config.json
rename to examples/config/ignite-config.json
index 785d27c..d09db83 100644
--- a/examples/src/main/resources/ignite-config.json
+++ b/examples/config/ignite-config.json
@@ -1,7 +1,7 @@
 {
     "node": {
         "metastorageNodes": [
-            "node0"
+            "node-0", "node-1", "node-2"
         ]
     },
     "network": {
diff --git a/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
index b8e7610..28f6888 100644
--- a/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
+++ b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
@@ -25,11 +25,26 @@ import org.apache.ignite.table.KeyValueBinaryView;
 import org.apache.ignite.table.Table;
 import org.apache.ignite.table.Tuple;
 
+/**
+ * This example demonstrates the usage of the {@link KeyValueBinaryView} API.
+ * <p>
+ * To run the example, do the following:
+ * <ol>
+ *     <li>Import the examples project into you IDE.</li>
+ *     <li>
+ *         (optional) Run one or more standalone nodes using the CLI tool:<br>
+ *         {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-1}<br>
+ *         {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-2}<br>
+ *         {@code ...}<br>
+*          {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-n}<br>
+ *     </li>
+ *     <li>Run the example in the IDE.</li>
+ * </ol>
+ */
 public class KeyValueBinaryViewExample {
     public static void main(String[] args) throws Exception {
-        String config = Files.readString(Path.of(ClassLoader.getSystemResource("ignite-config.json").toURI()));
-
-        Ignite ignite = IgnitionManager.start("node0", config);
+        Ignite ignite = IgnitionManager.start("node-0",
+            Files.readString(Path.of("config/ignite-config.json")));
 
         //---------------------------------------------------------------------------------
         //
diff --git a/examples/src/main/java/org/apache/ignite/example/table/TableExample.java b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
index 222d772..e97c5fe 100644
--- a/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
+++ b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
@@ -24,72 +24,86 @@ import org.apache.ignite.app.IgnitionManager;
 import org.apache.ignite.table.Table;
 import org.apache.ignite.table.Tuple;
 
+/**
+ * This example demonstrates the usage of the {@link Table} API.
+ * <p>
+ * To run the example, do the following:
+ * <ol>
+ *     <li>Import the examples project into you IDE.</li>
+ *     <li>
+ *         (optional) Run one or more standalone nodes using the CLI tool:<br>
+ *         {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-1}<br>
+ *         {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-2}<br>
+ *         {@code ...}<br>
+*          {@code ignite node start --config=$IGNITE_HOME/examples/config/ignite-config.json node-n}<br>
+ *     </li>
+ *     <li>Run the example in the IDE.</li>
+ * </ol>
+ */
 public class TableExample {
     public static void main(String[] args) throws Exception {
-        String config = Files.readString(Path.of(ClassLoader.getSystemResource("ignite-config.json").toURI()));
-
-        try (Ignite ignite = IgnitionManager.start("node0", config)) {
+        Ignite ignite = IgnitionManager.start("node-0",
+            Files.readString(Path.of("config/ignite-config.json")));
 
-            //---------------------------------------------------------------------------------
-            //
-            // Creating a table. The API call below is the equivalent of the following DDL:
-            //
-            //     CREATE TABLE accounts (
-            //         accountNumber INT PRIMARY KEY,
-            //         firstName     VARCHAR,
-            //         lastName      VARCHAR,
-            //         balance       DOUBLE
-            //     )
-            //
-            //---------------------------------------------------------------------------------
+        //---------------------------------------------------------------------------------
+        //
+        // Creating a table. The API call below is the equivalent of the following DDL:
+        //
+        //     CREATE TABLE accounts (
+        //         accountNumber INT PRIMARY KEY,
+        //         firstName     VARCHAR,
+        //         lastName      VARCHAR,
+        //         balance       DOUBLE
+        //     )
+        //
+        //---------------------------------------------------------------------------------
 
-            Table accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
-                .changeName("PUBLIC.accounts")
-                .changeColumns(cols -> cols
-                    .create("0", c -> c.changeName("accountNumber").changeType(t -> t.changeType("int32")).changeNullable(false))
-                    .create("1", c -> c.changeName("firstName").changeType(t -> t.changeType("string")).changeNullable(true))
-                    .create("2", c -> c.changeName("lastName").changeType(t -> t.changeType("string")).changeNullable(true))
-                    .create("3", c -> c.changeName("balance").changeType(t -> t.changeType("double")).changeNullable(true))
-                )
-                .changeIndices(idxs -> idxs
-                    .create("PK", idx -> idx
-                        .changeName("PK")
-                        .changeType("PK")
-                        .changeColumns(cols -> cols.create("0", c -> c.changeName("accountNumber").changeAsc(true)))
-                    )
+        Table accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
+            .changeName("PUBLIC.accounts")
+            .changeColumns(cols -> cols
+                .create("0", c -> c.changeName("accountNumber").changeType(t -> t.changeType("int32")).changeNullable(false))
+                .create("1", c -> c.changeName("firstName").changeType(t -> t.changeType("string")).changeNullable(true))
+                .create("2", c -> c.changeName("lastName").changeType(t -> t.changeType("string")).changeNullable(true))
+                .create("3", c -> c.changeName("balance").changeType(t -> t.changeType("double")).changeNullable(true))
+            )
+            .changeIndices(idxs -> idxs
+                .create("PK", idx -> idx
+                    .changeName("PK")
+                    .changeType("PK")
+                    .changeColumns(cols -> cols.create("0", c -> c.changeName("accountNumber").changeAsc(true)))
                 )
-            );
+            )
+        );
 
-            //---------------------------------------------------------------------------------
-            //
-            // Tuple API: insert operation.
-            //
-            //---------------------------------------------------------------------------------
+        //---------------------------------------------------------------------------------
+        //
+        // Tuple API: insert operation.
+        //
+        //---------------------------------------------------------------------------------
 
-            Tuple newAccountTuple = accounts.tupleBuilder()
-                .set("accountNumber", 123456)
-                .set("firstName", "Val")
-                .set("lastName", "Kulichenko")
-                .set("balance", 100.00d)
-                .build();
+        Tuple newAccountTuple = accounts.tupleBuilder()
+            .set("accountNumber", 123456)
+            .set("firstName", "Val")
+            .set("lastName", "Kulichenko")
+            .set("balance", 100.00d)
+            .build();
 
-            accounts.insert(newAccountTuple);
+        accounts.insert(newAccountTuple);
 
-            //---------------------------------------------------------------------------------
-            //
-            // Tuple API: get operation.
-            //
-            //---------------------------------------------------------------------------------
+        //---------------------------------------------------------------------------------
+        //
+        // Tuple API: get operation.
+        //
+        //---------------------------------------------------------------------------------
 
-            Tuple accountNumberTuple = accounts.tupleBuilder().set("accountNumber", 123456).build();
+        Tuple accountNumberTuple = accounts.tupleBuilder().set("accountNumber", 123456).build();
 
-            Tuple accountTuple = accounts.get(accountNumberTuple);
+        Tuple accountTuple = accounts.get(accountNumberTuple);
 
-            System.out.println(
-                "Retrieved using Tuple API\n" +
-                    "  Account Number: " + accountTuple.intValue("accountNumber") + '\n' +
-                    "  Owner: " + accountTuple.stringValue("firstName") + " " + accountTuple.stringValue("lastName") + '\n' +
-                    "  Balance: $" + accountTuple.doubleValue("balance"));
-        }
+        System.out.println(
+            "Retrieved using Tuple API\n" +
+                "  Account Number: " + accountTuple.intValue("accountNumber") + '\n' +
+                "  Owner: " + accountTuple.stringValue("firstName") + " " + accountTuple.stringValue("lastName") + '\n' +
+                "  Balance: $" + accountTuple.doubleValue("balance"));
     }
 }

[ignite-3] 04/07: IGNITE-14995 - Updated NOTICE

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d63d7a2bd8ee5a1858e1df8f587e861d4590ebef
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:18:45 2021 -0700

    IGNITE-14995 - Updated NOTICE
---
 NOTICE                | 5 +++++
 assembly/NOTICE       | 0
 assembly/assembly.xml | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..1dd5ce4
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache Ignite
+Copyright 2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/assembly/NOTICE b/assembly/NOTICE
deleted file mode 100644
index e69de29..0000000
diff --git a/assembly/assembly.xml b/assembly/assembly.xml
index b78c2c6..7ecb499 100644
--- a/assembly/assembly.xml
+++ b/assembly/assembly.xml
@@ -31,7 +31,7 @@
             <outputDirectory/>
         </file>
         <file>
-            <source>assembly/NOTICE</source>
+            <source>NOTICE</source>
             <outputDirectory/>
         </file>
         <file>

[ignite-3] 06/07: IGNITE-14993 - Choose available port out of a range

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d26631c1602bc6198d4d03775c060a82eedb305f
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:29:36 2021 -0700

    IGNITE-14993 - Choose available port out of a range
---
 .../java/org/apache/ignite/network/internal/netty/NettyServer.java     | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
index 2a458a5..a229d41 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
@@ -43,6 +43,9 @@ import org.jetbrains.annotations.TestOnly;
  * Netty server channel wrapper.
  */
 public class NettyServer {
+    /** Port range. */
+    private static final int PORT_RANGE = 100;
+
     /** A lock for start and stop operations. */
     private final Object startStopLock = new Object();
 

[ignite-3] 01/07: IGNITE-14992 - Temporarily commenting out the warning to avoid excessive output

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dda15900c3031bf5e0966bd448ddb6313b367885
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:10:22 2021 -0700

    IGNITE-14992 - Temporarily commenting out the warning to avoid excessive output
---
 .../java/org/apache/ignite/raft/server/impl/RaftServerImpl.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/modules/raft/src/main/java/org/apache/ignite/raft/server/impl/RaftServerImpl.java b/modules/raft/src/main/java/org/apache/ignite/raft/server/impl/RaftServerImpl.java
index 004c819..ff81d90 100644
--- a/modules/raft/src/main/java/org/apache/ignite/raft/server/impl/RaftServerImpl.java
+++ b/modules/raft/src/main/java/org/apache/ignite/raft/server/impl/RaftServerImpl.java
@@ -125,9 +125,10 @@ public class RaftServerImpl implements RaftServer {
                     handleActionRequest(sender, req0, correlationId, writeQueue, lsnr);
                 }
             }
-            else {
-                LOG.warn("Unsupported message class " + message.getClass().getName());
-            }
+            // TODO: IGNITE-14992 - Temporarily commenting out for alpha2
+            // else {
+            //     LOG.warn("Unsupported message class " + message.getClass().getName());
+            // }
         });
 
         readWorker = new Thread(() -> processQueue(readQueue, RaftGroupCommandListener::onRead), "read-cmd-worker#" + id);

[ignite-3] 02/07: IGNITE-14993 - Choose available port out of a range

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1f6acbbf1612c32c702b32bbe0a0e03dba6168ef
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:15:00 2021 -0700

    IGNITE-14993 - Choose available port out of a range
---
 .../ignite/network/internal/netty/ConnectionManager.java   |  2 ++
 .../apache/ignite/network/internal/netty/NettyServer.java  | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/ConnectionManager.java b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/ConnectionManager.java
index 3b3f94c..b2f4a10 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/ConnectionManager.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/ConnectionManager.java
@@ -94,6 +94,8 @@ public class ConnectionManager {
     public void start() throws IgniteInternalException {
         try {
             server.start().join();
+
+            LOG.info("Connection created [address=" + server.address() + ']');
         }
         catch (CompletionException e) {
             Throwable cause = e.getCause();
diff --git a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
index feb99ed..2a458a5 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/internal/netty/NettyServer.java
@@ -25,6 +25,7 @@ import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 import java.util.function.Function;
 import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.Channel;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelOption;
 import io.netty.channel.ServerChannel;
@@ -171,7 +172,18 @@ public class NettyServer {
                  */
                 .childOption(ChannelOption.SO_KEEPALIVE, true);
 
-            serverStartFuture = NettyUtils.toChannelCompletableFuture(bootstrap.bind(port))
+            CompletableFuture<Channel> bindFuture = NettyUtils.toChannelCompletableFuture(bootstrap.bind(port));
+
+            for (int i = 1; i < PORT_RANGE; i++) {
+                int port0 = port + i;
+
+                bindFuture = bindFuture
+                    .thenApply(CompletableFuture::completedFuture)
+                    .exceptionally(err -> NettyUtils.toChannelCompletableFuture(bootstrap.bind(port0)))
+                    .thenCompose(Function.identity());
+            }
+
+            serverStartFuture = bindFuture
                 .handle((channel, err) -> {
                     synchronized (startStopLock) {
                         CompletableFuture<Void> workerCloseFuture = serverCloseFuture;

[ignite-3] 05/07: IGNITE-14996 - Added examples for Table and KeyValueBinaryView

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2090ad75866c837fb07fb5ffe9b93ad5da54a5bf
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:27:00 2021 -0700

    IGNITE-14996 - Added examples for Table and KeyValueBinaryView
---
 assembly/assembly.xml                              | 26 ++++++
 examples/pom-standalone.xml                        | 41 +++++++++
 examples/pom.xml                                   | 41 +++++++++
 .../example/table/KeyValueBinaryViewExample.java   | 98 ++++++++++++++++++++++
 .../apache/ignite/example/table/TableExample.java  | 95 +++++++++++++++++++++
 examples/src/main/resources/ignite-config.json     | 13 +++
 parent/pom.xml                                     | 12 ++-
 pom.xml                                            |  1 +
 8 files changed, 324 insertions(+), 3 deletions(-)

diff --git a/assembly/assembly.xml b/assembly/assembly.xml
index 7ecb499..d5d256b 100644
--- a/assembly/assembly.xml
+++ b/assembly/assembly.xml
@@ -25,26 +25,52 @@
     <formats>
         <format>zip</format>
     </formats>
+
     <files>
         <file>
             <source>LICENSE</source>
             <outputDirectory/>
         </file>
+
         <file>
             <source>NOTICE</source>
             <outputDirectory/>
         </file>
+
         <file>
             <source>assembly/README</source>
             <outputDirectory/>
         </file>
+
         <file>
             <source>modules/cli/target/ignite</source>
             <outputDirectory/>
         </file>
+
         <file>
             <source>modules/cli/target/ignite.exe</source>
             <outputDirectory/>
         </file>
+
+        <file>
+            <source>examples/pom-standalone.xml</source>
+            <outputDirectory>/examples</outputDirectory>
+            <destName>pom.xml</destName>
+        </file>
+
+        <file>
+            <source>examples/README.md</source>
+            <outputDirectory>/examples</outputDirectory>
+        </file>
     </files>
+
+    <fileSets>
+        <fileSet>
+            <directory>examples</directory>
+            <outputDirectory>/examples</outputDirectory>
+            <includes>
+                <include>src/**</include>
+            </includes>
+        </fileSet>
+    </fileSets>
 </assembly>
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
new file mode 100644
index 0000000..23da513
--- /dev/null
+++ b/examples/pom-standalone.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.ignite</groupId>
+    <artifactId>ignite-examples</artifactId>
+    <version>3.0.0-alpha2</version>
+
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-runner</artifactId>
+            <version>3.0.0-alpha2</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 0000000..fd5fee8
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ignite</groupId>
+        <artifactId>ignite-parent</artifactId>
+        <version>1</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>ignite-examples</artifactId>
+    <version>3.0.0-alpha2</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-runner</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
new file mode 100644
index 0000000..b8e7610
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/example/table/KeyValueBinaryViewExample.java
@@ -0,0 +1,98 @@
+/*
+ * 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.table;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.app.Ignite;
+import org.apache.ignite.app.IgnitionManager;
+import org.apache.ignite.table.KeyValueBinaryView;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+
+public class KeyValueBinaryViewExample {
+    public static void main(String[] args) throws Exception {
+        String config = Files.readString(Path.of(ClassLoader.getSystemResource("ignite-config.json").toURI()));
+
+        Ignite ignite = IgnitionManager.start("node0", config);
+
+        //---------------------------------------------------------------------------------
+        //
+        // Creating a table. The API call below is the equivalent of the following DDL:
+        //
+        //     CREATE TABLE accounts (
+        //         accountNumber INT PRIMARY KEY,
+        //         firstName     VARCHAR,
+        //         lastName      VARCHAR,
+        //         balance       DOUBLE
+        //     )
+        //
+        //---------------------------------------------------------------------------------
+
+        Table accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
+            .changeName("PUBLIC.accounts")
+            .changeColumns(cols -> cols
+                .create("0", c -> c.changeName("accountNumber").changeType(t -> t.changeType("int32")).changeNullable(false))
+                .create("1", c -> c.changeName("firstName").changeType(t -> t.changeType("string")).changeNullable(true))
+                .create("2", c -> c.changeName("lastName").changeType(t -> t.changeType("string")).changeNullable(true))
+                .create("3", c -> c.changeName("balance").changeType(t -> t.changeType("double")).changeNullable(true))
+            )
+            .changeIndices(idxs -> idxs
+                .create("PK", idx -> idx
+                    .changeName("PK")
+                    .changeType("PK")
+                    .changeColumns(cols -> cols.create("0", c -> c.changeName("accountNumber").changeAsc(true)))
+                )
+            )
+        );
+
+        KeyValueBinaryView kvView = accounts.kvView();
+
+        //---------------------------------------------------------------------------------
+        //
+        // Tuple API: insert operation.
+        //
+        //---------------------------------------------------------------------------------
+
+        Tuple key = accounts.tupleBuilder()
+            .set("accountNumber", 123456)
+            .build();
+
+        Tuple value = accounts.tupleBuilder()
+            .set("firstName", "Val")
+            .set("lastName", "Kulichenko")
+            .set("balance", 100.00d)
+            .build();
+
+        kvView.put(key, value);
+
+        //---------------------------------------------------------------------------------
+        //
+        // Tuple API: get operation.
+        //
+        //---------------------------------------------------------------------------------
+
+        value = accounts.get(key);
+
+        System.out.println(
+            "Retrieved using Key-Value API\n" +
+                "  Account Number: " + key.intValue("accountNumber") + '\n' +
+                "  Owner: " + value.stringValue("firstName") + " " + value.stringValue("lastName") + '\n' +
+                "  Balance: $" + value.doubleValue("balance"));
+    }
+}
diff --git a/examples/src/main/java/org/apache/ignite/example/table/TableExample.java b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
new file mode 100644
index 0000000..222d772
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/example/table/TableExample.java
@@ -0,0 +1,95 @@
+/*
+ * 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.table;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.app.Ignite;
+import org.apache.ignite.app.IgnitionManager;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+
+public class TableExample {
+    public static void main(String[] args) throws Exception {
+        String config = Files.readString(Path.of(ClassLoader.getSystemResource("ignite-config.json").toURI()));
+
+        try (Ignite ignite = IgnitionManager.start("node0", config)) {
+
+            //---------------------------------------------------------------------------------
+            //
+            // Creating a table. The API call below is the equivalent of the following DDL:
+            //
+            //     CREATE TABLE accounts (
+            //         accountNumber INT PRIMARY KEY,
+            //         firstName     VARCHAR,
+            //         lastName      VARCHAR,
+            //         balance       DOUBLE
+            //     )
+            //
+            //---------------------------------------------------------------------------------
+
+            Table accounts = ignite.tables().createTable("PUBLIC.accounts", tbl -> tbl
+                .changeName("PUBLIC.accounts")
+                .changeColumns(cols -> cols
+                    .create("0", c -> c.changeName("accountNumber").changeType(t -> t.changeType("int32")).changeNullable(false))
+                    .create("1", c -> c.changeName("firstName").changeType(t -> t.changeType("string")).changeNullable(true))
+                    .create("2", c -> c.changeName("lastName").changeType(t -> t.changeType("string")).changeNullable(true))
+                    .create("3", c -> c.changeName("balance").changeType(t -> t.changeType("double")).changeNullable(true))
+                )
+                .changeIndices(idxs -> idxs
+                    .create("PK", idx -> idx
+                        .changeName("PK")
+                        .changeType("PK")
+                        .changeColumns(cols -> cols.create("0", c -> c.changeName("accountNumber").changeAsc(true)))
+                    )
+                )
+            );
+
+            //---------------------------------------------------------------------------------
+            //
+            // Tuple API: insert operation.
+            //
+            //---------------------------------------------------------------------------------
+
+            Tuple newAccountTuple = accounts.tupleBuilder()
+                .set("accountNumber", 123456)
+                .set("firstName", "Val")
+                .set("lastName", "Kulichenko")
+                .set("balance", 100.00d)
+                .build();
+
+            accounts.insert(newAccountTuple);
+
+            //---------------------------------------------------------------------------------
+            //
+            // Tuple API: get operation.
+            //
+            //---------------------------------------------------------------------------------
+
+            Tuple accountNumberTuple = accounts.tupleBuilder().set("accountNumber", 123456).build();
+
+            Tuple accountTuple = accounts.get(accountNumberTuple);
+
+            System.out.println(
+                "Retrieved using Tuple API\n" +
+                    "  Account Number: " + accountTuple.intValue("accountNumber") + '\n' +
+                    "  Owner: " + accountTuple.stringValue("firstName") + " " + accountTuple.stringValue("lastName") + '\n' +
+                    "  Balance: $" + accountTuple.doubleValue("balance"));
+        }
+    }
+}
diff --git a/examples/src/main/resources/ignite-config.json b/examples/src/main/resources/ignite-config.json
new file mode 100644
index 0000000..785d27c
--- /dev/null
+++ b/examples/src/main/resources/ignite-config.json
@@ -0,0 +1,13 @@
+{
+    "node": {
+        "metastorageNodes": [
+            "node0"
+        ]
+    },
+    "network": {
+        "port": 3344,
+        "netClusterNodes": [
+            "localhost:3344"
+        ]
+    }
+}
diff --git a/parent/pom.xml b/parent/pom.xml
index 1e6440f..e620315 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -149,7 +149,7 @@
                 <artifactId>ignite-configuration-annotation-processor</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            
+
             <dependency>
                 <groupId>org.apache.ignite</groupId>
                 <artifactId>ignite-core</artifactId>
@@ -167,7 +167,7 @@
                 <artifactId>ignite-metastorage-client</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            
+
             <dependency>
                 <groupId>org.apache.ignite</groupId>
                 <artifactId>ignite-metastorage-common</artifactId>
@@ -234,6 +234,12 @@
                 <version>${project.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.ignite</groupId>
+                <artifactId>ignite-runner</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
             <!-- 3rd party dependencies -->
             <dependency>
                 <groupId>org.jetbrains</groupId>
@@ -508,7 +514,7 @@
                         </executions>
                     </plugin>
                 </plugins>
-            </build>    
+            </build>
         </profile>
     </profiles>
 
diff --git a/pom.xml b/pom.xml
index 5d3c97c..6cef3f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
         <module>modules/schema</module>
         <module>modules/table</module>
         <module>modules/vault</module>
+        <module>examples</module>
     </modules>
 
     <build>

[ignite-3] 03/07: IGNITE-14994 - Topology snapshot print out

Posted by vk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9b314004ae561f9f0b009907f9bcc2eb44b65e81
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Thu Jun 24 14:17:05 2021 -0700

    IGNITE-14994 - Topology snapshot print out
---
 .../main/java/org/apache/ignite/network/ClusterNode.java |  2 ++
 .../network/scalecube/ScaleCubeTopologyService.java      | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/modules/network-api/src/main/java/org/apache/ignite/network/ClusterNode.java b/modules/network-api/src/main/java/org/apache/ignite/network/ClusterNode.java
index 2573a08..4a48908 100644
--- a/modules/network-api/src/main/java/org/apache/ignite/network/ClusterNode.java
+++ b/modules/network-api/src/main/java/org/apache/ignite/network/ClusterNode.java
@@ -18,6 +18,7 @@ package org.apache.ignite.network;
 
 import java.io.Serializable;
 import java.util.Objects;
+import org.apache.ignite.internal.tostring.IgniteToStringExclude;
 import org.apache.ignite.internal.tostring.S;
 
 /**
@@ -37,6 +38,7 @@ public class ClusterNode implements Serializable {
     private final int port;
 
     /** Node address in host:port format (lazily evaluated) */
+    @IgniteToStringExclude
     private String address;
 
     /**
diff --git a/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeTopologyService.java b/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeTopologyService.java
index 4f41fd0..352469f 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeTopologyService.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeTopologyService.java
@@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import io.scalecube.cluster.Member;
 import io.scalecube.cluster.membership.MembershipEvent;
+import org.apache.ignite.lang.IgniteLogger;
 import org.apache.ignite.network.AbstractTopologyService;
 import org.apache.ignite.network.ClusterNode;
 import org.apache.ignite.network.TopologyEventHandler;
@@ -31,6 +32,9 @@ import org.apache.ignite.network.TopologyService;
  * Implementation of {@link TopologyService} based on ScaleCube.
  */
 final class ScaleCubeTopologyService extends AbstractTopologyService {
+    /** Logger. */
+    private static final IgniteLogger LOG = IgniteLogger.forClass(ScaleCubeTopologyService.class);
+
     /** Local member node. */
     private ClusterNode localMember;
 
@@ -56,14 +60,26 @@ final class ScaleCubeTopologyService extends AbstractTopologyService {
         if (event.isAdded()) {
             members.put(member.address(), member);
 
+            LOG.info("Node joined: " + member);
+
             fireAppearedEvent(member);
         }
         else if (event.isRemoved()) {
             members.compute(member.address(), // Ignore stale remove event.
                 (k, v) -> v.id().equals(member.id()) ? null : v);
 
+            LOG.info("Node left: " + member);
+
             fireDisappearedEvent(member);
         }
+
+        StringBuilder snapshotMsg = new StringBuilder("Topology snapshot [nodes=").append(members.size()).append("]\n");
+
+        for (ClusterNode node : members.values()) {
+            snapshotMsg.append("  ^-- ").append(node).append('\n');
+        }
+
+        LOG.info(snapshotMsg.toString().trim());
     }
 
     /**