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/09/04 14:52:31 UTC
[ignite] 01/03: add "Deploying User Code" section
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 f7807f1b6fa2fa2df6161ff65c6992cf0a7fe7aa
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Fri Sep 4 17:42:56 2020 +0300
add "Deploying User Code" section
---
docs/_data/toc.yaml | 16 +++++
.../apache/ignite/snippets/UserCodeDeployment.java | 50 +++++++++++++
docs/_docs/code-snippets/xml/deployment.xml | 39 +++++++++++
docs/_docs/deploying-user-code.adoc | 81 ++++++++++++++++++++++
4 files changed, 186 insertions(+)
diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
index 428e9bd..afc5036 100644
--- a/docs/_data/toc.yaml
+++ b/docs/_data/toc.yaml
@@ -115,6 +115,8 @@
url: /data-rebalancing
- title: Partition Loss Policy
url: /partition-loss-policy
+- title: Deploying User Code
+ url: /deploying-user-code
- title: Peer Class Loading
url: /peer-class-loading
- title: Data Streaming
@@ -183,6 +185,20 @@
url: /near-cache
- title: .NET Platform Cache
url: /platform-cache
+- title: Services
+ url: /services/services
+- title: Distributed Data Structures
+ items:
+ - title: Queue and Set
+ url: /data-structures/queue-and-set
+ - title: Atomic Types
+ url: /data-structures/atomic-types
+ - title: CountDownLatch
+ url: /data-structures/countdownlatch
+ - title: Atomic Sequence
+ url: /data-structures/atomic-sequence
+ - title: Semaphore
+ url: /data-structures/semaphore
- title: Monitoring
items:
- title: Introduction
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UserCodeDeployment.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UserCodeDeployment.java
new file mode 100644
index 0000000..438e548
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UserCodeDeployment.java
@@ -0,0 +1,50 @@
+package org.apache.ignite.snippets;
+
+import java.util.Arrays;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi;
+import org.junit.jupiter.api.Test;
+
+public class UserCodeDeployment {
+
+ @Test
+ void fromUrl() {
+ //tag::from-url[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ UriDeploymentSpi deploymentSpi = new UriDeploymentSpi();
+
+ deploymentSpi.setUriList(Arrays
+ .asList("http://username:password;freq=10000@www.mysite.com:110/ignite/user_libs"));
+
+ cfg.setDeploymentSpi(deploymentSpi);
+
+ try (Ignite ignite = Ignition.start(cfg)) {
+ //execute the task represented by a class located in the "user_libs" url
+ ignite.compute().execute("org.mycompany.HelloWorldTask", "My Args");
+ }
+ //end::from-url[]
+ }
+
+ @Test
+ void fromDirectory() {
+ //tag::from-local-dir[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ UriDeploymentSpi deploymentSpi = new UriDeploymentSpi();
+
+ deploymentSpi.setUriList(Arrays.asList("file://freq=2000@localhost/home/username/user_libs"));
+
+ cfg.setDeploymentSpi(deploymentSpi);
+
+ try (Ignite ignite = Ignition.start(cfg)) {
+ //execute the task represented by a class located in the "user_libs" directory
+ ignite.compute().execute("org.mycompany.HelloWorldTask", "My Args");
+ }
+ //end::from-local-dir[]
+ }
+
+}
diff --git a/docs/_docs/code-snippets/xml/deployment.xml b/docs/_docs/code-snippets/xml/deployment.xml
new file mode 100644
index 0000000..eb2fed4
--- /dev/null
+++ b/docs/_docs/code-snippets/xml/deployment.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+ <!-- tag::ignite-config[] -->
+ <bean class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="deploymentSpi">
+ <bean class="org.apache.ignite.spi.deployment.uri.UriDeploymentSpi">
+ <property name="temporaryDirectoryPath" value="/tmp/temp_ignite_libs"/>
+ <property name="uriList">
+ <list>
+ <!--tag::from-local-dir[] -->
+ <value>file://freq=2000@localhost/home/username/user_libs</value>
+ <!--end::from-local-dir[] -->
+ <!--tag::from-url[] -->
+ <value>http://username:password;freq=10000@www.mysite.com:110/ignite/user_libs</value>
+ <!--end::from-url[] -->
+ </list>
+ </property>
+ </bean>
+ </property>
+ <!-- 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">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <!-- end::discovery[] -->
+ </bean>
+ <!-- end::ignite-config[] -->
+</beans>
\ No newline at end of file
diff --git a/docs/_docs/deploying-user-code.adoc b/docs/_docs/deploying-user-code.adoc
new file mode 100644
index 0000000..9908c64
--- /dev/null
+++ b/docs/_docs/deploying-user-code.adoc
@@ -0,0 +1,81 @@
+= Deploying User Code
+:javaFile: {javaCodeDir}/UserCodeDeployment.java
+
+The approach is to specify the location of your libraries in the node configuration.
+Ignite scans the location periodically and redeploys the classes if they change.
+The location may be a file system directory or an HTTP(S) location.
+When Ignite detects that the libraries are removed from the location, the classes are undeployed from the cluster.
+
+You can specify multiple locations (of different types) by providing both directory paths and http(s) URLs.
+
+//TODO NOTE: peer class loading vs. URL deployment
+
+
+== Deploying from a Local Directory
+
+To deploy libraries from a file system directory, add the directory path to the list of URIs in the `UriDeploymentSpi` configuration.
+The directory must exist on all cluster nodes and contain jar files with the classes you want to deploy.
+Note that the path must be specified using the "file://" scheme.
+
+[tabs]
+--
+tab:XML[]
+[source, xml]
+----
+include::code-snippets/xml/deployment.xml[tags=!*;ignite-config;from-local-dir, indent=0]
+----
+tab:Java[]
+[source, java]
+----
+include::{javaFile}[tags=from-local-dir, indent=0]
+----
+tab:C#/.NET[]
+
+tab:C++[]
+--
+
+You can pass the following parameter in the URL:
+
+[cols="1,2,1",opts="header"]
+|===
+|Parameter | Description | Default Value
+| `freq` | Scanning frequency in milliseconds. | `5000`
+|===
+
+
+== Deploying from a URL
+
+To deploy libraries from an http(s) location, add the URL to the list of URIs in the `UriDeploymentSpi` configuration.
+
+Ignite parses the HTML file to find the HREF attributes of all `<a>` tags on the page.
+The references must point to the jar files you want to deploy.
+//It's important that only HTTP scanner uses the URLConnection.getLastModified() method to check if there were any changes since last iteration for each GAR-file before redeploying.
+
+[tabs]
+--
+tab:XML[]
+
+[source, xml]
+----
+include::code-snippets/xml/deployment.xml[tags=!*;ignite-config;from-url, indent=0]
+----
+
+tab:Java[]
+
+[source, java]
+----
+include::{javaFile}[tags=from-url, indent=0]
+----
+
+tab:C#/.NET[]
+tab:C++[]
+--
+
+You can pass the following parameter in the URL:
+
+[cols="1,2,1",opts="header"]
+|===
+|Parameter | Description | Default Value
+| `freq` | Scanning frequency in milliseconds. | `300000`
+|===
+