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/08/26 16:51:14 UTC

[ignite] branch IGNITE-7595 updated (5186d30 -> 530650a)

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

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


    from 5186d30  minor fixes
     new ec5d8a4  add cluster id page
     new 530650a  update Plugins page

The 2 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:
 docs/_data/toc.yaml                                |  2 +
 .../org/apache/ignite/snippets/ClusterAPI.java     | 16 ++++
 .../apache/ignite/snippets/plugin/MyPlugin.java    | 18 ++---
 .../ignite/snippets/plugin/MyPluginProvider.java   | 33 +++++---
 .../ignite/snippets/plugin/PluginExample.java      |  2 +-
 docs/_docs/code-snippets/xml/plugins.xml           |  2 +-
 docs/_docs/monitoring-metrics/cluster-id.adoc      | 48 ++++++++++++
 docs/_docs/plugins.adoc                            | 88 ++++++++++++++++------
 8 files changed, 166 insertions(+), 43 deletions(-)
 create mode 100644 docs/_docs/monitoring-metrics/cluster-id.adoc


[ignite] 01/02: add cluster id page

Posted by ab...@apache.org.
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

commit ec5d8a41e6d9d4f923a5c9a6153f65574f34ff58
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Wed Aug 26 19:50:23 2020 +0300

    add cluster id page
---
 .../org/apache/ignite/snippets/ClusterAPI.java     | 16 ++++++++
 docs/_docs/monitoring-metrics/cluster-id.adoc      | 48 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
index fd2eb9e..d56d8a0 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
@@ -1,6 +1,9 @@
 package org.apache.ignite.snippets;
 
+import java.util.UUID;
+
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.Ignition;
@@ -28,7 +31,20 @@ public class ClusterAPI {
         ignite.cluster().state(ClusterState.ACTIVE_READ_ONLY);
         //end::change-state[]
         ignite.close();
+    }
+
+    void changeClusterTag() throws IgniteCheckedException {
+        //tag::cluster-tag[]
+        Ignite ignite = Ignition.start();
+
+        // get the cluster id
+       java.util.UUID clusterId = ignite.cluster().id();
+       
+       // change the cluster tag
+       ignite.cluster().tag("new_tag");
 
+        //end::cluster-tag[]
+        ignite.close();
     }
 
     @Test
diff --git a/docs/_docs/monitoring-metrics/cluster-id.adoc b/docs/_docs/monitoring-metrics/cluster-id.adoc
new file mode 100644
index 0000000..0d2ec31
--- /dev/null
+++ b/docs/_docs/monitoring-metrics/cluster-id.adoc
@@ -0,0 +1,48 @@
+= Cluster ID and Tag
+
+A cluster ID is a unique identifier of the cluster that is generated automatically when the cluster starts for the first time.
+A cluster tag is a user friendly name that you can assign to your cluster.
+You can use these values to identify your cluster in the monitoring system you use.
+
+The default cluster tag is generated automatically, but you can change it using one of the available methods.
+The length of the tag is limited by 280 characters.
+
+You can use the following methods to view the cluster ID and view or change the cluster tag:
+
+* Via the link:control-script#cluster-id-and-tag[control script].
+* JMX Bean:
++
+--
+----
+group=IgniteCluster,name=IgniteClusterMXBeanImpl
+----
+[cols="3,2,8", opts="header"]
+|===
+| Attribute | Type | Description
+|Id| String | The cluster ID.
+|Tag | long | The cluster tag.
+|===
+
+[cols="4,9", opts="header"]
+|===
+| Operation | Description
+| Tag(String) | Set the new cluster tag.
+|===
+--
+* Programmatically:
++
+[tabs]
+--
+tab:Java[]
+[source, java]
+----
+include::{javaCodeDir}/ClusterAPI.java[tags=cluster-tag, indent=0]
+----
+
+tab:C#/.NET[]
+tab:C++[]
+--
+
+
+
+


[ignite] 02/02: update Plugins page

Posted by ab...@apache.org.
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

commit 530650ae796e22cfb70dd310e5410181171c5cf0
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Wed Aug 26 19:50:53 2020 +0300

    update Plugins page
---
 docs/_data/toc.yaml                                |  2 +
 .../apache/ignite/snippets/plugin/MyPlugin.java    | 18 ++---
 .../ignite/snippets/plugin/MyPluginProvider.java   | 33 +++++---
 .../ignite/snippets/plugin/PluginExample.java      |  2 +-
 docs/_docs/code-snippets/xml/plugins.xml           |  2 +-
 docs/_docs/plugins.adoc                            | 88 ++++++++++++++++------
 6 files changed, 102 insertions(+), 43 deletions(-)

diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
index 62c8aa0..95a0b08 100644
--- a/docs/_data/toc.yaml
+++ b/docs/_data/toc.yaml
@@ -185,6 +185,8 @@
   items:
     - title: Introduction
       url: /monitoring-metrics/intro
+    - title: Cluster ID and Tag
+      url: /monitoring-metrics/cluster-id
     - title: Metrics
       items: 
         - title: Configuring Metrics
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPlugin.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPlugin.java
index e441837..04b2683 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPlugin.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPlugin.java
@@ -9,24 +9,24 @@ import org.apache.ignite.plugin.IgnitePlugin;
 import org.apache.ignite.plugin.PluginContext;
 
 /**
+ * 
  * The plugin prints cache size information to console  
- * @author 
  *
  */
 public class MyPlugin implements IgnitePlugin, Runnable {
-    
+
     private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
 
     private PluginContext context;
 
-    private long period;
+    private long interval;
 
     /**
      * 
      * @param context 
      */
-    public MyPlugin(long period, PluginContext context) {
-        this.period = period;
+    public MyPlugin(long interval, PluginContext context) {
+        this.interval = interval;
         this.context = context;
     }
 
@@ -57,12 +57,12 @@ public class MyPlugin implements IgnitePlugin, Runnable {
     public void run() {
         print0();
     }
-    
+
     void start() {
-        scheduler.scheduleAtFixedRate(this, period, period, TimeUnit.SECONDS);
+        scheduler.scheduleAtFixedRate(this, interval, interval, TimeUnit.SECONDS);
     }
-    
+
     void stop() {
-       scheduler.shutdownNow(); 
+        scheduler.shutdownNow();
     }
 }
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPluginProvider.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPluginProvider.java
index 5702299..6003f8a 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPluginProvider.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/MyPluginProvider.java
@@ -16,7 +16,10 @@ import org.jetbrains.annotations.Nullable;
 
 public class MyPluginProvider implements PluginProvider<PluginConfiguration> {
 
-    private long period = 10;
+    /**
+     * The time interval in seconds for printing cache size information. 
+     */
+    private long interval = 10;
 
     private MyPlugin plugin;
 
@@ -25,14 +28,15 @@ public class MyPluginProvider implements PluginProvider<PluginConfiguration> {
 
     /**
      * 
-     * @param period period in seconds
+     * @param interval Time interval in seconds
      */
-    public MyPluginProvider(long period) {
-        this.period = period;
+    public MyPluginProvider(long interval) {
+        this.interval = interval;
     }
 
     @Override
     public String name() {
+        //the name of the plugin
         return "MyPlugin";
     }
 
@@ -54,31 +58,42 @@ public class MyPluginProvider implements PluginProvider<PluginConfiguration> {
     @Override
     public void initExtensions(PluginContext ctx, ExtensionRegistry registry)
             throws IgniteCheckedException {
-        plugin = new MyPlugin(period, ctx);
+        plugin = new MyPlugin(interval, ctx);
     }
 
     @Override
     public void onIgniteStart() throws IgniteCheckedException {
+        //start the plugin when Ignite is started
         plugin.start();
     }
 
     @Override
     public void onIgniteStop(boolean cancel) {
+        //stop the plugin
         plugin.stop();
     }
 
-    public long getPeriod() {
-        return period;
+    /**
+     * The time interval (in seconds) for printing cache size information 
+     * @return 
+     */
+    public long getInterval() {
+        return interval;
     }
 
-    public void setPeriod(long period) {
-        this.period = period;
+    /**
+     * Sets the time interval (in seconds) for printing cache size information
+     * @param interval 
+     */
+    public void setInterval(long interval) {
+        this.interval = interval;
     }
 
     // other no-op methods of PluginProvider 
     //tag::no-op-methods[]
     @Override
     public <T> @Nullable T createComponent(PluginContext ctx, Class<T> cls) {
+        System.out.println(cls);
         return null;
     }
 
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/PluginExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/PluginExample.java
index ffe8795..80a66c6 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/PluginExample.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/plugin/PluginExample.java
@@ -39,7 +39,7 @@ public class PluginExample {
         //print the cache size information
         p.printCacheInfo();
         //end::example[]
-       // ignite.close();
+        ignite.close();
     }
     
     public static void main(String[] args) {
diff --git a/docs/_docs/code-snippets/xml/plugins.xml b/docs/_docs/code-snippets/xml/plugins.xml
index 03544cf..c181ebc 100644
--- a/docs/_docs/code-snippets/xml/plugins.xml
+++ b/docs/_docs/code-snippets/xml/plugins.xml
@@ -5,7 +5,7 @@
 
         <property name="pluginProviders">
             <bean class="org.apache.ignite.snippets.plugin.MyPluginProvider">
-               <property name="period" value="100"/> 
+               <property name="interval" value="100"/> 
             </bean>
         </property>
 
diff --git a/docs/_docs/plugins.adoc b/docs/_docs/plugins.adoc
index 9e59e8e..b9d038b 100644
--- a/docs/_docs/plugins.adoc
+++ b/docs/_docs/plugins.adoc
@@ -2,49 +2,79 @@
 
 == Overview
 
+
+
 The Ignite plugin system allows you to extend the core functionality of Ignite.
+Plugins have access to different internal Ignite components, such as security processor and others, and can extend the programmatic API of Ignite.
 
-To add a custom plugin, implement the `PluginProvider` interface and register the implementation either via `IgniteConfiguration.setPluginProviders()` or service loader.
+To add a custom plugin, implement the `PluginProvider` interface and register the implementation in the node configuration.
+The following is an overview of the steps involved in creating a plugin:
 
-. Implement the `IgnitePlugin` interface. If your plugin adds functionality that is meant to be triggered by a user, you should add public methods to this class that trigger specific actions. An instance of this class is available at runtime via `Ignite.plugin(String pluginName)`.
+. Implement the `PluginProvider` interface. This is the main interface for creating plugins.
 
-. Implement the `PluginProvider` interface. The following methods must return non-null values. Other methods are optional.
-+
---
-* `name()` - returns the name of the plugin
-* `plugin()` - return the object of your plugin class.
+. Implement the `IgnitePlugin` interface. If your plugin adds functionality that is meant to be triggered by end users, you should add public methods to this class. An instance of this class is available to end users at runtime via `Ignite.plugin(String pluginName)`.
 
-Plugins have access to the Ignite API and node configuration via `PluginContext`. See the javadoc:org.apache.ignite.plugin.PluginContext[] javadoc for more information.
+. Register the plugin in `IgniteConfiguration.setPluginProviders(...)` either programmatically or via XML configuration.
 
+. If your plugin has a public API, call `MyPlugin plugin = Ignite.plugin(pluginName)` at runtime and execute specific actions.
 
---
+The following section gives an example of a plugin and goes into details about how plugins work in Ignite.
 
-. Register the plugin via `IgniteConfiguration.setPluginProviders(...)`.
+== Example Plugin
 
-. At runtime, call `MyPlugin plugin = Ignite.plugin(pluginName)`
+Let's create a simple Ignite plugin that prints information about the number of entries in every cache to the console periodically, on each node.
+In addition, it exposes a public method that the users can call programmatically from their application to print the cache size information on demand.
+The plugin has one configuration parameter: the time interval for printing the cache size information.
 
+=== {counter:step}. Implement PluginProvider
 
-== Plugin Example
+`PluginProvider` is the main interface for creating Ignite plugins.
+Ignite calls the methods of each registered plugin provider during initialization.
 
-Let's create a simple Ignite plugin that prints information about the number of entries in every cache to the console periodically, on each node.
-In addition, it exposes a public method that the users can call from their application to print the cache size information on demand.
+The following methods must return non-null values. Other methods are optional.
+
+* `name()` - returns the name of the plugin
+* `plugin()` - returns the object of your plugin class
 
-=== Implement IgnitePlugin
-.MyPlugin.java
+Below is an example implementation of a plugin provider.
+We create an object of `MyPlugin` class (see next step) in the `initExtensions()` method.
+Ignite passes a `PluginContext` object as an argument to this method.
+`PluginContext` provides access to the Ignite APIs and node configuration.
+See the javadoc:org.apache.ignite.plugin.PluginContext[] javadoc for more information.
+Here we simply pass the `PluginContext` and the time interval to the `MyPlugin` constructor.
+
+.MyPluginProvider.java:
 [source, java]
 ----
-include::{javaCodeDir}/plugin/MyPlugin.java[tags=, indent=0]
+include::{javaCodeDir}/plugin/MyPluginProvider.java[tags=!no-op-methods, indent=0]
 ----
 
-=== Implement PluginProvider
+The `onIgniteStart()` method is invoked when Ignite is started.
+We start the plugin by calling `MyPlugin.start()`, which simply schedules periodic execution of the task that prints cache size information.
+
+
+=== {counter:step}. Implement IgnitePlugin
+
+The implementation of the `IgnitePlugin` returned by the plugin provider is available to the users via `Ignite.plugin(String pluginName)`.
+If you want to provide public API to end users, the API should be exposed in the class that implements `IgnitePlugin`.
 
-.MyPluginProvider.java
+Strictly speaking, this step is not necessary if your plugin does not provide a public API.
+Your plugin functionality may be implemented and initialized in the `PluginProvider` implementation, and the `PluginProvider.plugin()` method may return an empty implementation of the `IgnitePlugin` interface.
+
+
+In our case, we encapsulate the plugin functionality in the `MyPlugin` class and provide one public method (`MyPlugin.printCacheInfo()`).
+The `MyPlugin.java` implements the `Runnable` interface.
+The `start()` and `stop()` methods schedule periodic printing of cache size information.
+
+
+.MyPlugin.java:
 [source, java]
 ----
-include::{javaCodeDir}/plugin/MyPluginProvider.java[tags=!no-op-methods, indent=0]
+include::{javaCodeDir}/plugin/MyPlugin.java[tags=, indent=0]
 ----
 
-=== Register your Plugin
+
+=== {counter:step}. Register your Plugin
 
 
 Programmatically:
@@ -65,11 +95,23 @@ Then, you can register the plugin as follows:
 include::code-snippets/xml/plugins.xml[tags=ignite-config;!discovery, indent=0]
 ----
 
-=== Access the Plugin at Runtime
+When you start the node, you should see the following message in the console:
+
+[source, text]
+----
+[11:00:49] Initial heap size is 248MB (should be no less than 512MB, use -Xms512m -Xmx512m).
+[11:00:49] Configured plugins:
+[11:00:49]   ^-- MyPlugin 1.0
+[11:00:49]   ^-- MyCompany
+[11:00:49]
+----
+
+=== {counter:step}. Access the Plugin at Runtime
+
+You can access the instance of the plugin by calling `Ignite.plugin(pluginName)`.
 
 [source, java]
 ----
 include::{javaCodeDir}/plugin/PluginExample.java[tags=access-plugin, indent=0]
-
 ----