You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ab...@apache.org on 2020/07/28 14:46:13 UTC

[ignite] branch IGNITE-7595 updated: more pages

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

abudnikov pushed a commit to branch IGNITE-7595
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/IGNITE-7595 by this push:
     new 6afe367  more pages
6afe367 is described below

commit 6afe36718ad3cabd004a8a524859534c0f171ab7
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Tue Jul 28 17:45:39 2020 +0300

    more pages
---
 docs/_config.yml                                   |  1 +
 docs/_data/toc.yaml                                |  2 +
 docs/_docs/code-snippets/dotnet/IgniteLifecycle.cs | 37 +++++++++
 .../org/apache/ignite/snippets/ClientNodes.java    | 65 +++++++++++++++
 .../apache/ignite/snippets/ClusteringOverview.java |  2 +-
 .../apache/ignite/snippets/IgniteLifecycle.java    | 22 +++++-
 .../apache/ignite/snippets/MyLifecycleBean.java    | 23 ++++++
 docs/_docs/code-snippets/xml/client-node.xml       | 11 ++-
 .../developers-guide/clustering/clustering.adoc    |  5 +-
 .../clustering/connect-client-nodes.adoc           | 92 ++++++++++++++++++++++
 docs/_docs/developers-guide/starting-nodes.adoc    |  2 +-
 docs/_docs/installation-guide/deb-rpm.adoc         |  9 ++-
 .../installing-using-docker.adoc                   | 32 ++++++--
 13 files changed, 287 insertions(+), 16 deletions(-)

diff --git a/docs/_config.yml b/docs/_config.yml
index 8a2263d..f0411db 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -8,6 +8,7 @@ attrs: &asciidoc_attributes
   table-stripes: even
   javadoc_base_url: https://ignite.apache.org/releases/{version}/javadoc
   javaCodeDir: code-snippets/java/src/main/java/org/apache/ignite/snippets
+  csharpCodeDir: code-snippets/dotnet
   githubUrl: https://github.com/apache/ignite/tree/master
 collections:
   docs:
diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
index b1fca4d..1228759 100644
--- a/docs/_data/toc.yaml
+++ b/docs/_data/toc.yaml
@@ -72,6 +72,8 @@
           url: /developers-guide/clustering/zookeeper-discovery
         - title: Discovery in the Cloud
           url: /developers-guide/clustering/discovery-in-the-cloud
+        - title: Connecting Client Nodes 
+          url: /developers-guide/clustering/connect-client-nodes
     - title: Data Modeling 
       items: 
         - title: Introduction
diff --git a/docs/_docs/code-snippets/dotnet/IgniteLifecycle.cs b/docs/_docs/code-snippets/dotnet/IgniteLifecycle.cs
new file mode 100644
index 0000000..002703d
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/IgniteLifecycle.cs
@@ -0,0 +1,37 @@
+using Apache.Ignite.Core;
+
+namespace dotnet_helloworld
+{
+    public static class IgniteLifecycle
+    {
+        public static void Start()
+        {
+            // tag::start[]
+            var cfg = new IgniteConfiguration();
+            IIgnite ignite = Ignition.Start(cfg);
+            // end::start[]
+        }
+
+        public static void StartClient()
+        {
+            // tag::start-client[]
+            var cfg = new IgniteConfiguration
+            {
+                ClientMode = true
+            };
+            IIgnite ignite = Ignition.Start(cfg);
+            // end::start-client[]
+        }
+
+        public static void StartDispose()
+        {
+            // tag::disposable[]
+            var cfg = new IgniteConfiguration();
+            using (IIgnite ignite = Ignition.Start(cfg))
+            {
+                //
+            }
+            // end::disposable[]
+        }
+    }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClientNodes.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClientNodes.java
new file mode 100644
index 0000000..018bd16
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClientNodes.java
@@ -0,0 +1,65 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.junit.jupiter.api.Test;
+
+public class ClientNodes {
+
+    @Test
+    void disableReconnection() {
+
+        //tag::disable-reconnection[]
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
+        discoverySpi.setClientReconnectDisabled(true);
+
+        cfg.setDiscoverySpi(discoverySpi);
+        //end::disable-reconnection[]
+
+        try (Ignite ignite = Ignition.start(cfg)) {
+
+        }
+    }
+
+    void slowClient() {
+        //tag::slow-clients[]
+        IgniteConfiguration cfg = new IgniteConfiguration();
+        cfg.setClientMode(true);
+
+        TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
+        commSpi.setSlowClientQueueLimit(1000);
+
+        cfg.setCommunicationSpi(commSpi);
+        //end::slow-clients[]
+    }
+
+    void reconnect() {
+        Ignite ignite = Ignition.start();
+
+        //tag::reconnect[]
+
+        IgniteCache cache = ignite.getOrCreateCache(new CacheConfiguration<>("myCache"));
+
+        try {
+            cache.put(1, "value");
+        } catch (IgniteClientDisconnectedException e) {
+            if (e.getCause() instanceof IgniteClientDisconnectedException) {
+                IgniteClientDisconnectedException cause = (IgniteClientDisconnectedException) e.getCause();
+
+                cause.reconnectFuture().get(); // Wait until the client is reconnected. 
+                // proceed
+            }
+        }
+        //end::reconnect[]
+
+        ignite.close();
+    }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusteringOverview.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusteringOverview.java
index ced0d06..d048f9e 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusteringOverview.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusteringOverview.java
@@ -32,7 +32,7 @@ public class ClusteringOverview {
         // tag::clientModeIgnition[]
         Ignition.setClientMode(true);
 
-        // Start the node in the client mode.
+        // Start the node in client mode.
         Ignite ignite = Ignition.start();
         // end::clientModeIgnition[]
         
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteLifecycle.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteLifecycle.java
index 475203e..83bca3a 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteLifecycle.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteLifecycle.java
@@ -4,12 +4,12 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.junit.jupiter.api.Test;
 
 public class IgniteLifecycle {
-    
-    void test() {
-    }
 
     @Test
     void startNode() {
@@ -17,6 +17,7 @@ public class IgniteLifecycle {
         IgniteConfiguration cfg = new IgniteConfiguration();
         Ignite ignite = Ignition.start(cfg);
         //end::start[]
+        ignite.close();
     }
 
     @Test
@@ -32,7 +33,6 @@ public class IgniteLifecycle {
         //end::autoclose[]
     }
 
-    @Test
     void startClientNode() {
         //tag::client-node[]
         IgniteConfiguration cfg = new IgniteConfiguration();
@@ -47,4 +47,18 @@ public class IgniteLifecycle {
         ignite.close();
     }
 
+    @Test
+    void lifecycleEvents() {
+        //tag::lifecycle[]
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        // Specify a lifecycle bean in the node configuration.
+        cfg.setLifecycleBeans(new MyLifecycleBean());
+
+        // Start the node.
+        Ignite ignite = Ignition.start(cfg);
+        //end::lifecycle[]
+
+        ignite.close();
+    }
 }
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyLifecycleBean.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyLifecycleBean.java
new file mode 100644
index 0000000..8b7d5ad
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyLifecycleBean.java
@@ -0,0 +1,23 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+//tag::bean[]
+public class MyLifecycleBean implements LifecycleBean {
+    @IgniteInstanceResource
+    public Ignite ignite;
+
+    @Override
+    public void onLifecycleEvent(LifecycleEventType evt) {
+        if (evt == LifecycleEventType.AFTER_NODE_START) {
+
+            System.out.format("After the node (consistentId = %s) starts.\n", ignite.cluster().node().consistentId());
+
+        }
+    }
+}
+
+//end::bean[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/xml/client-node.xml b/docs/_docs/code-snippets/xml/client-node.xml
index e1e629c..f857a3a 100644
--- a/docs/_docs/code-snippets/xml/client-node.xml
+++ b/docs/_docs/code-snippets/xml/client-node.xml
@@ -3,10 +3,12 @@
     <!-- tag::ignite-config[] -->
     <bean class="org.apache.ignite.configuration.IgniteConfiguration">
         <property name="clientMode" value="true"/>
-        <!-- other properties -->
+      
         <!-- tag::discovery[] -->
         <property name="discoverySpi">
             <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <!-- prevent this client from reconnecting on connection loss -->
+                <property name="clientReconnectDisabled" value="true"/>
                 <property name="ipFinder">
 
                     <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
@@ -20,6 +22,13 @@
             </bean>
         </property>
         <!-- end::discovery[] -->
+        <!-- tag::slow-client[] -->
+        <property name="communicationSpi">
+            <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
+                <property name="slowClientQueueLimit" value="1000"/>
+            </bean>
+        </property>
+        <!-- end::slow-client[] -->
     </bean>
     <!-- end::ignite-config[] -->
 </beans>
diff --git a/docs/_docs/developers-guide/clustering/clustering.adoc b/docs/_docs/developers-guide/clustering/clustering.adoc
index 950e860..3b72a5f 100644
--- a/docs/_docs/developers-guide/clustering/clustering.adoc
+++ b/docs/_docs/developers-guide/clustering/clustering.adoc
@@ -2,9 +2,10 @@
 
 == Overview
 
-In this chapter, we discuss different roles nodes can play in a cluster and the different ways nodes can discover each other to form a cluster.
+In this chapter, we discuss different ways nodes can discover each other to form a cluster.
 
-On start-up, a node is assigned either one of the two roles: _server node_ or _client node_. Server nodes are the workhorses of the cluster; they cache data, execute compute tasks, etc.
+On start-up, a node is assigned either one of the two roles: _server node_ or _client node_.
+Server nodes are the workhorses of the cluster; they cache data, execute compute tasks, etc.
 Client nodes join the topology as regular nodes but they do not store data. Client nodes are used to stream data into the cluster and execute user queries.
 
 To form a cluster, each node must be able to connect to all other nodes. To ensure that, a proper <<Discovery Mechanisms,discovery mechanism>> must be configured.
diff --git a/docs/_docs/developers-guide/clustering/connect-client-nodes.adoc b/docs/_docs/developers-guide/clustering/connect-client-nodes.adoc
new file mode 100644
index 0000000..38e74de
--- /dev/null
+++ b/docs/_docs/developers-guide/clustering/connect-client-nodes.adoc
@@ -0,0 +1,92 @@
+= Connecting Client Nodes
+:javaFile: {javaCodeDir}/ClientNodes.java
+
+
+== Reconnecting a Client Node
+
+A client node can get disconnected from the cluster in several cases:
+
+* The client node cannot re-establish the connection with the server node due to network issues.
+* Connection with the server node was broken for some time; the client node is able to re-establish the connection with the cluster, but the server already dropped the client node since the server did not receive client heartbeats.
+* Slow clients can be kicked out by the cluster.
+
+
+When a client determines that it is disconnected from the cluster, it assigns a new node ID to itself and tries to reconnect to the cluster.
+Note that this has a side effect: the ID property of the local `ClusterNode` changes in the case of a client reconnection.
+This means that any application logic that relied on the ID may be affected.
+
+You can disable client reconnection in the node configuration:
+
+[tabs]
+--
+tab:XML[]
+[source, xml]
+----
+include::code-snippets/xml/client-node.xml[tags=ignite-config, indent=0]
+----
+tab:Java[]
+[source, java]
+----
+include::{javaFile}[tags=disable-reconnection, indent=0]
+----
+tab:C#/.NET[]
+tab:C++[unsupported]
+--
+
+
+While a client is in a disconnected state and an attempt to reconnect is in progress, the Ignite API throws a `IgniteClientDisconnectedException`.
+The exception contains a `future` that represents a re-connection operation.
+You can use the `future` to wait until the operation is complete.
+//This future can also be obtained using the `IgniteCluster.clientReconnectFuture()` method.
+
+[tabs]
+--
+tab:Java[]
+[source, java]
+----
+include::{javaFile}[tags=reconnect, indent=0]
+----
+tab:C#/.NET[]
+tab:C++[]
+--
+
+//When the client node reconnects to the cluster,
+//This future can also be obtained using the `IgniteCluster.clientReconnectFuture()` method.
+
+
+== Client Disconnected/Reconnected Events
+
+There are two discovery events that are triggered on the client node when it is disconnected from or reconnected to the cluster:
+
+* `EVT_CLIENT_NODE_DISCONNECTED`
+* `EVT_CLIENT_NODE_RECONNECTED`
+
+You can listen to these events and execute custom actions in response.
+Refer to the link:developers-guide/events/listening-to-events[Listening to events] section for a code example.
+
+== Managing Slow Client Nodes
+
+In many deployments, client nodes are launched on slower machines with lower network throughput.
+In these scenarios, it is possible that the servers will generate the load (such as continuous queries notification, for example) that the clients cannot to handle.
+This can result in a growing queue of outbound messages on the servers, which may eventually cause either an out-of-memory situation on the server or block the whole cluster.
+
+To handle these situations, you can configure the maximum number of outgoing messages for client nodes.
+If the size of the outbound queue exceeds this value, the client node is disconnected from the cluster.
+
+The examples below show how to configure a slow client queue limit.
+
+[tabs]
+--
+tab:XML[]
+[source, xml]
+----
+include::code-snippets/xml/client-node.xml[tags=!*;ignite-config;slow-client, indent=0]
+----
+tab:Java[]
+[source, java]
+----
+include::{javaFile}[tags=slow-clients, indent=0]
+----
+tab:C#/.NET[]
+tab:C++[unsupported]
+--
diff --git a/docs/_docs/developers-guide/starting-nodes.adoc b/docs/_docs/developers-guide/starting-nodes.adoc
index 40c6d74..14331cb 100644
--- a/docs/_docs/developers-guide/starting-nodes.adoc
+++ b/docs/_docs/developers-guide/starting-nodes.adoc
@@ -222,7 +222,7 @@ The interface has the `onLifecycleEvent()` method, which is called for any lifec
 +
 [source, java]
 ----
-include::{javaFile}[tags=bean, indent=0]
+include::{javaCodeDir}/MyLifecycleBean.java[tags=bean, indent=0]
 ----
 
 . Register the implementation in the node configuration.
diff --git a/docs/_docs/installation-guide/deb-rpm.adoc b/docs/_docs/installation-guide/deb-rpm.adoc
index 5981551..883a2b6 100644
--- a/docs/_docs/installation-guide/deb-rpm.adoc
+++ b/docs/_docs/installation-guide/deb-rpm.adoc
@@ -1,4 +1,4 @@
-= Installing using DEP and RPM package
+= Installing Using DEP and RPM Package
 
 Apache Ignite can be installed from the official link:https://www.apache.org/dist/ignite/rpm[RPM] or link:https://www.apache.org/dist/ignite/deb[DEB] repositories.
 
@@ -15,3 +15,10 @@ sudo apt update
 sudo apt install dirmngr --no-install-recommends
 ----
 
+[tabs]
+--
+tab:DEB[]
+
+tab:RPM[]
+--
+
diff --git a/docs/_docs/installation-guide/installing-using-docker.adoc b/docs/_docs/installation-guide/installing-using-docker.adoc
index e0e0de4..f1e6c92 100644
--- a/docs/_docs/installation-guide/installing-using-docker.adoc
+++ b/docs/_docs/installation-guide/installing-using-docker.adoc
@@ -13,7 +13,7 @@ It means that the data will be erased when you remove the container. To save the
 *Networking*::
 +
 --
-By default, Ignite docker image exposes the following ports: 11211, 47100, 47500, 49112.
+By default, Ignite Docker image exposes the following ports: 11211, 47100, 47500, 49112.
 You can expose more ports as needed by adding `-p <port>` to the `docker run` command.
 For example, to connect a thin client to the node running inside a docker container, open port 10800:
 
@@ -140,6 +140,26 @@ docker run -d \
   apacheignite/ignite
 ----
 
+== Deploying User Libraries
+
+When starting, a node adds all libraries found in the `{IGNITE_HOME}/libs` directory to the classpath (ignoring the "optional" directory).
+If you want to deploy user libraries, you can mount a directory from your local machine to a path in the `/opt/ignite/apache-ignite/libs/` in the container by using the `-v` option.
+
+The following command mounts a directory on your machine to `libs/user_libs` in the container.
+All files located in the directory are added to the classpath of the node.
+
+[source, shell]
+----
+docker run -v /local_path/to/dir_with_libs/:/opt/ignite/apache-ignite/libs/user_libs apacheignite/ignite
+----
+
+Another option is to use the `EXTERNAL_LIBS` variable if your libraries are available via an URL.
+
+[source, shell]
+----
+docker run -e "EXTERNAL_LIBS=http://url_to_your_jar" apacheignite/ignite
+----
+
 
 == Enabling Modules
 
@@ -165,14 +185,14 @@ The following parameters can be passed as environment variables in the docker co
 [cols="1,2,1", options="header"]
 |===
 | Parameter Name |Description |Default
-| CONFIG_URI | URL to the Ignite configuration file (can also be relative to the META-INF folder on the class path).
-The downloaded config file will be saved to ./ignite-config.xml | N/A
+| `CONFIG_URI` | URL to the Ignite configuration file (can also be relative to the META-INF folder on the class path).
+The downloaded config file is saved to ./ignite-config.xml | N/A
 
-| OPTION_LIBS | A list of link:developers-guide/setup#enabling-modules[modules] that will be enabled for the node. | ignite-log4j, ignite-spring, ignite-indexing
+| `OPTION_LIBS` | A list of link:developers-guide/setup#enabling-modules[modules] that will be enabled for the node. | ignite-log4j, ignite-spring, ignite-indexing
 
-| JVM_OPTS | JVM arguments passed to the Ignite instance.| N/A
+| `JVM_OPTS` | JVM arguments passed to the Ignite instance.| N/A
 
-| EXTERNAL_LIBS | A list of URL's to external libs. | N/A
+| `EXTERNAL_LIBS` | A list of URL's to external libraries. Refer to <<Deploying User Libraries>>.| N/A
 
 |===