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/17 12:14:46 UTC
[ignite] 01/01: add docs directory with initial documentation
source files
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 a9ccf709e2ebc9ed38bdbff3a02b3ae94f447d89
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Fri Jul 17 15:14:07 2020 +0300
add docs directory with initial documentation source files
---
docs/.gitignore | 5 +
docs/Gemfile | 14 +
docs/README.adoc | 61 +++
docs/_config.yml | 30 ++
docs/_data/toc.yaml | 312 +++++++++++
docs/_docs/code-snippets/cpp/src/affinity_run.cpp | 132 +++++
.../cpp/src/cache_asynchronous_execution.cpp | 112 ++++
.../cpp/src/cache_atomic_operations.cpp | 38 ++
.../cpp/src/cache_creating_dynamically.cpp | 21 +
docs/_docs/code-snippets/cpp/src/cache_get_put.cpp | 42 ++
.../cpp/src/cache_getting_instance.cpp | 22 +
docs/_docs/code-snippets/cpp/src/city.h | 53 ++
docs/_docs/code-snippets/cpp/src/city_key.h | 60 +++
.../cpp/src/compute_acessing_data.cpp | 118 +++++
.../code-snippets/cpp/src/compute_broadcast.cpp | 137 +++++
docs/_docs/code-snippets/cpp/src/compute_call.cpp | 135 +++++
.../code-snippets/cpp/src/compute_call_async.cpp | 149 ++++++
docs/_docs/code-snippets/cpp/src/compute_get.cpp | 22 +
docs/_docs/code-snippets/cpp/src/compute_run.cpp | 131 +++++
.../code-snippets/cpp/src/concurrent_updates.cpp | 44 ++
.../code-snippets/cpp/src/continuous_query.cpp | 71 +++
.../cpp/src/continuous_query_filter.cpp | 151 ++++++
.../cpp/src/continuous_query_listener.cpp | 60 +++
docs/_docs/code-snippets/cpp/src/country.h | 58 +++
docs/_docs/code-snippets/cpp/src/invoke.cpp | 140 +++++
.../cpp/src/key_value_execute_sql.cpp | 39 ++
.../code-snippets/cpp/src/key_value_object_key.cpp | 36 ++
docs/_docs/code-snippets/cpp/src/person.h | 78 +++
docs/_docs/code-snippets/cpp/src/scan_query.cpp | 37 ++
.../cpp/src/setting_work_directory.cpp | 16 +
docs/_docs/code-snippets/cpp/src/sql.cpp | 40 ++
docs/_docs/code-snippets/cpp/src/sql_create.cpp | 24 +
.../_docs/code-snippets/cpp/src/sql_join_order.cpp | 17 +
.../code-snippets/cpp/src/start_stop_nodes.cpp | 29 ++
.../code-snippets/cpp/src/thin_authentication.cpp | 28 +
.../code-snippets/cpp/src/thin_client_cache.cpp | 30 ++
.../code-snippets/cpp/src/thin_client_ssl.cpp | 23 +
.../cpp/src/thin_creating_client_instance.cpp | 26 +
.../cpp/src/thin_partition_awareness.cpp | 30 ++
docs/_docs/code-snippets/cpp/src/transactions.cpp | 62 +++
.../cpp/src/transactions_pessimistic.cpp | 36 ++
.../code-snippets/dotnet/AffinityCollocation.cs | 124 +++++
.../code-snippets/dotnet/BasicCacheOperations.cs | 76 +++
docs/_docs/code-snippets/dotnet/ClusterGroups.cs | 72 +++
.../code-snippets/dotnet/ClusteringOverview.cs | 41 ++
.../dotnet/ClusteringTcpIpDiscovery.cs | 115 +++++
.../code-snippets/dotnet/ContiniuosQueries.cs | 99 ++++
.../dotnet/DataModellingConfiguringCaches.cs | 86 ++++
.../dotnet/DataModellingDataPartitioning.cs | 36 ++
docs/_docs/code-snippets/dotnet/DataRebalancing.cs | 50 ++
docs/_docs/code-snippets/dotnet/DataStreaming.cs | 208 ++++++++
.../dotnet/DistributedComputingApi.cs | 267 ++++++++++
.../_docs/code-snippets/dotnet/EvictionPolicies.cs | 97 ++++
docs/_docs/code-snippets/dotnet/ExpiryPolicies.cs | 43 ++
docs/_docs/code-snippets/dotnet/MapReduceApi.cs | 142 +++++
docs/_docs/code-snippets/dotnet/NearCaches.cs | 102 ++++
docs/_docs/code-snippets/dotnet/OnHeapCaching.cs | 19 +
.../_docs/code-snippets/dotnet/PeerClassLoading.cs | 36 ++
.../code-snippets/dotnet/PerformingTransactions.cs | 136 +++++
.../dotnet/PersistenceIgnitePersistence.cs | 66 +++
.../dotnet/UnderstandingConfiguration.cs | 34 ++
.../_docs/code-snippets/dotnet/UsingScanQueries.cs | 65 +++
.../dotnet/WorkingWithBinaryObjects.cs | 126 +++++
docs/_docs/code-snippets/java/pom.xml | 117 +++++
.../snippets/AffinityCollocationExample.java | 134 +++++
.../org/apache/ignite/snippets/BackupFilter.java | 23 +
.../apache/ignite/snippets/BaselineTopology.java | 32 ++
.../ignite/snippets/BasicCacheOperations.java | 111 ++++
.../ignite/snippets/CacheJdbcPersonStore.java | 105 ++++
.../org/apache/ignite/snippets/ClusterGroups.java | 43 ++
.../apache/ignite/snippets/ClusteringOverview.java | 67 +++
.../ignite/snippets/CollocatedComputations.java | 168 ++++++
.../apache/ignite/snippets/ComputeTaskExample.java | 65 +++
.../apache/ignite/snippets/ConfiguringCaches.java | 88 ++++
.../apache/ignite/snippets/DataPartitioning.java | 51 ++
.../snippets/DataRegionConfigurationExample.java | 55 ++
.../org/apache/ignite/snippets/DataStreaming.java | 163 ++++++
.../ignite/snippets/DiscoveryInTheCloud.java | 135 +++++
.../ignite/snippets/DistributedComputing.java | 181 +++++++
.../java/org/apache/ignite/snippets/Events.java | 172 +++++++
.../apache/ignite/snippets/EvictionPolicies.java | 148 ++++++
.../org/apache/ignite/snippets/ExpiryPolicies.java | 52 ++
.../apache/ignite/snippets/ExternalStorage.java | 153 ++++++
.../org/apache/ignite/snippets/FaultTolerance.java | 49 ++
.../ignite/snippets/IgniteExecutorService.java | 40 ++
.../apache/ignite/snippets/IgniteLifecycle.java | 50 ++
.../apache/ignite/snippets/IgnitePersistence.java | 80 +++
.../org/apache/ignite/snippets/JobScheduling.java | 106 ++++
.../org/apache/ignite/snippets/LoadBalancing.java | 103 ++++
.../java/org/apache/ignite/snippets/Logging.java | 78 +++
.../java/org/apache/ignite/snippets/MapReduce.java | 154 ++++++
.../org/apache/ignite/snippets/MyNodeFilter.java | 24 +
.../java/org/apache/ignite/snippets/NearCache.java | 53 ++
.../org/apache/ignite/snippets/NodeFilter.java | 59 +++
.../org/apache/ignite/snippets/OnHeapCaching.java | 15 +
.../snippets/PartitionLossPolicyExample.java | 97 ++++
.../apache/ignite/snippets/PeerClassLoading.java | 26 +
.../ignite/snippets/PerformingTransactions.java | 162 ++++++
.../java/org/apache/ignite/snippets/Person.java | 59 +++
.../QueryEntitiesExampleWithAnnotation.java | 42 ++
.../apache/ignite/snippets/QueryEntityExample.java | 43 ++
.../ignite/snippets/RebalancingConfiguration.java | 46 ++
.../main/java/org/apache/ignite/snippets/Swap.java | 39 ++
.../org/apache/ignite/snippets/TcpIpDiscovery.java | 319 ++++++++++++
.../snippets/UnderstandingConfiguration.java | 26 +
.../ignite/snippets/UsingContinuousQueries.java | 142 +++++
.../apache/ignite/snippets/UsingScanQueries.java | 71 +++
.../ignite/snippets/WorkingWithBinaryObjects.java | 167 ++++++
.../apache/ignite/snippets/ZookeeperDiscovery.java | 30 ++
.../java/src/main/resources/config/ignite-jdbc.xml | 21 +
.../java/src/main/resources/keystore/node.jks | Bin 0 -> 3230 bytes
.../java/src/main/resources/keystore/trust.jks | Bin 0 -> 2432 bytes
.../code-snippets/xml/affinity-backup-filter.xml | 49 ++
.../code-snippets/xml/attribute-node-filter.xml | 42 ++
.../code-snippets/xml/cache-configuration.xml | 33 ++
docs/_docs/code-snippets/xml/cache-groups.xml | 40 ++
.../code-snippets/xml/cache-jdbc-pojo-store.xml | 98 ++++
docs/_docs/code-snippets/xml/cache-template.xml | 33 ++
docs/_docs/code-snippets/xml/client-node.xml | 25 +
docs/_docs/code-snippets/xml/configure-backups.xml | 38 ++
.../xml/data-regions-configuration.xml | 74 +++
docs/_docs/code-snippets/xml/events.xml | 38 ++
docs/_docs/code-snippets/xml/expiry.xml | 40 ++
docs/_docs/code-snippets/xml/failover-always.xml | 29 ++
docs/_docs/code-snippets/xml/failover-never.xml | 27 +
docs/_docs/code-snippets/xml/jcl.xml | 57 +++
.../code-snippets/xml/job-scheduling-fifo.xml | 30 ++
.../code-snippets/xml/job-scheduling-priority.xml | 31 ++
docs/_docs/code-snippets/xml/job-stealing.xml | 50 ++
docs/_docs/code-snippets/xml/log4j-config.xml | 92 ++++
docs/_docs/code-snippets/xml/log4j.xml | 59 +++
docs/_docs/code-snippets/xml/log4j2-config.xml | 64 +++
docs/_docs/code-snippets/xml/log4j2.xml | 59 +++
docs/_docs/code-snippets/xml/near-cache-config.xml | 36 ++
docs/_docs/code-snippets/xml/on-heap-cache.xml | 28 +
.../code-snippets/xml/partition-loss-policy.xml | 33 ++
.../_docs/code-snippets/xml/peer-class-loading.xml | 28 +
docs/_docs/code-snippets/xml/persistence.xml | 34 ++
.../_docs/code-snippets/xml/rebalancing-config.xml | 49 ++
.../xml/round-robin-load-balancing.xml | 53 ++
docs/_docs/code-snippets/xml/slf4j.xml | 57 +++
docs/_docs/code-snippets/xml/swap.xml | 31 ++
docs/_docs/code-snippets/xml/tcp-ip-discovery.xml | 29 ++
docs/_docs/code-snippets/xml/transactions.xml | 41 ++
docs/_docs/code-snippets/xml/wal.xml | 41 ++
.../code-snippets/xml/weighted-load-balancing.xml | 43 ++
docs/_docs/developers-guide/baseline-topology.adoc | 133 +++++
.../developers-guide/clustering/clustering.adoc | 155 ++++++
.../clustering/discovery-in-the-cloud.adoc | 256 +++++++++
.../clustering/tcp-ip-discovery.adoc | 504 ++++++++++++++++++
.../clustering/zookeeper-discovery.adoc | 179 +++++++
.../configuring-caches/atomicity-modes.adoc | 99 ++++
.../configuring-caches/cache-groups.adoc | 66 +++
.../configuring-caches/configuration-overview.adoc | 135 +++++
.../configuring-caches/configuring-backups.adoc | 78 +++
.../configuring-caches/expiry-policies.adoc | 76 +++
.../configuring-caches/on-heap-caching.adoc | 168 ++++++
.../data-modeling/affinity-collocation.adoc | 109 ++++
.../data-modeling/data-modeling.adoc | 61 +++
.../data-modeling/data-partitioning.adoc | 126 +++++
docs/_docs/developers-guide/data-rebalancing.adoc | 137 +++++
docs/_docs/developers-guide/data-streaming.adoc | 176 +++++++
.../distributed-computing/cluster-groups.adoc | 48 ++
.../distributed-computing.adoc | 371 ++++++++++++++
.../distributed-computing/executor-service.adoc | 25 +
.../distributed-computing/fault-tolerance.adoc | 51 ++
.../distributed-computing/job-scheduling.adoc | 64 +++
.../distributed-computing/load-balancing.adoc | 111 ++++
.../distributed-computing/map-reduce.adoc | 126 +++++
docs/_docs/developers-guide/index.adoc | 4 +
.../key-value-api/basic-cache-operations.adoc | 407 +++++++++++++++
.../key-value-api/binary-objects.adoc | 222 ++++++++
.../key-value-api/continuous-queries.adoc | 148 ++++++
.../key-value-api/transactions.adoc | 314 ++++++++++++
.../key-value-api/using-scan-queries.adoc | 105 ++++
.../key-value-api/with-expiry-policy.adoc | 29 ++
docs/_docs/developers-guide/logging.adoc | 170 ++++++
.../developers-guide/memory-architecture.adoc | 79 +++
docs/_docs/developers-guide/near-cache.adoc | 88 ++++
.../developers-guide/partition-loss-policy.adoc | 182 +++++++
.../_docs/developers-guide/peer-class-loading.adoc | 144 ++++++
.../persistence/custom-cache-store.adoc | 89 ++++
.../persistence/external-storage.adoc | 210 ++++++++
.../persistence/native-persistence.adoc | 322 ++++++++++++
docs/_docs/developers-guide/persistence/swap.adoc | 52 ++
docs/_docs/developers-guide/preface.adoc | 6 +
docs/_docs/developers-guide/setup.adoc | 223 ++++++++
docs/_docs/developers-guide/starting-nodes.adoc | 160 ++++++
.../understanding-configuration.adoc | 88 ++++
docs/_docs/includes/intro-languages.adoc | 31 ++
docs/_docs/includes/java9.adoc | 28 +
docs/_docs/includes/nodes-and-clustering.adoc | 19 +
docs/_docs/includes/note-on-deactivation.adoc | 5 +
docs/_docs/includes/partition-awareness.adoc | 32 ++
docs/_docs/includes/prereqs.adoc | 9 +
docs/_docs/includes/thick-and-thin-clients.adoc | 28 +
docs/_docs/index.adoc | 5 +
docs/_includes/footer.html | 4 +
docs/_includes/header.html | 19 +
docs/_includes/left-nav.html | 64 +++
docs/_includes/right-nav.html | 4 +
docs/_includes/section-toc.html | 14 +
docs/_includes/toc.html | 45 ++
docs/_layouts/default.html | 57 +++
docs/_layouts/doc.html | 15 +
docs/_layouts/toc.html | 16 +
docs/_plugins/asciidoctor-extensions.rb | 123 +++++
docs/_sass/callouts.scss | 61 +++
docs/_sass/code.scss | 95 ++++
docs/_sass/docs.scss | 196 +++++++
docs/_sass/footer.scss | 34 ++
docs/_sass/github.scss | 209 ++++++++
docs/_sass/header.scss | 360 +++++++++++++
docs/_sass/layout.scss | 31 ++
docs/_sass/left-nav.scss | 95 ++++
docs/_sass/right-nav.scss | 59 +++
docs/_sass/rouge-base16-solarized.scss | 77 +++
docs/_sass/text.scss | 48 ++
docs/_sass/variables.scss | 19 +
docs/assets/css/asciidoc-pygments.css | 38 ++
docs/assets/css/docs.scss | 5 +
docs/assets/css/styles.scss | 14 +
docs/assets/images/apple-blob.svg | 16 +
docs/assets/images/arrow-down-white.svg | 3 +
docs/assets/images/arrow-down.svg | 3 +
docs/assets/images/background-lines.svg | 54 ++
docs/assets/images/cancel.svg | 11 +
docs/assets/images/checkmark-green.svg | 3 +
docs/assets/images/copy-icon.svg | 6 +
docs/assets/images/cpp.svg | 9 +
docs/assets/images/dev-internal-bg.jpg | Bin 0 -> 23014 bytes
docs/assets/images/dotnet.svg | 9 +
docs/assets/images/edition-ce.svg | 16 +
docs/assets/images/edition-ee.svg | 25 +
docs/assets/images/edition-ue.svg | 28 +
docs/assets/images/events-nav-arrow.svg | 3 +
docs/assets/images/feature-easy-installation.svg | 28 +
docs/assets/images/feature-fast.svg | 16 +
docs/assets/images/feature-reliable.svg | 25 +
docs/assets/images/github-gray.svg | 3 +
docs/assets/images/github-white.svg | 3 +
docs/assets/images/glowing-box.svg | 170 ++++++
docs/assets/images/integrations/hibernate.svg | 6 +
docs/assets/images/integrations/kafka.svg | 3 +
docs/assets/images/integrations/more.svg | 18 +
docs/assets/images/integrations/oracle.svg | 3 +
docs/assets/images/integrations/osgi.svg | 17 +
docs/assets/images/integrations/spark.svg | 7 +
docs/assets/images/integrations/spring.svg | 3 +
docs/assets/images/java.svg | 9 +
docs/assets/images/left-nav-arrow.svg | 3 +
docs/assets/images/lines-bg-1.svg | 54 ++
docs/assets/images/lines-bg-2.svg | 54 ++
docs/assets/images/lines-bg-3.svg | 54 ++
docs/assets/images/lines-bg-4.svg | 54 ++
docs/assets/images/menu-icon.svg | 3 +
docs/assets/images/mousepad-blob.svg | 9 +
...piece-of-paper-with-folded-top-right-corner.svg | 117 +++++
docs/assets/images/scala.svg | 31 ++
docs/assets/images/search.svg | 15 +
docs/assets/images/violent-blob.svg | 28 +
docs/assets/images/watermelon-blob.svg | 9 +
docs/assets/js/anchor.min.js | 9 +
docs/assets/js/code-copy-to-clipboard.js | 55 ++
docs/assets/js/code-tabs.js | 140 +++++
docs/assets/js/docs-menu.js | 49 ++
docs/assets/js/index.js | 36 ++
docs/assets/js/jquery.swiftype.autocomplete.js | 570 +++++++++++++++++++++
docs/assets/js/page-nav.js | 22 +
docs/assets/js/top-navigation.js | 77 +++
docs/favicon.ico | Bin 0 -> 9780 bytes
docs/run.sh | 8 +
272 files changed, 20433 insertions(+)
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000..a01b89a
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1,5 @@
+.jekyll-cache/
+_site/
+Gemfile.lock
+.jekyll-metadata
+
diff --git a/docs/Gemfile b/docs/Gemfile
new file mode 100644
index 0000000..f471d02
--- /dev/null
+++ b/docs/Gemfile
@@ -0,0 +1,14 @@
+source "https://rubygems.org"
+
+# git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
+
+gem 'asciidoctor'
+gem 'jekyll', group: :jekyll_plugins
+gem 'wdm', '~> 0.1.1' if Gem.win_platform?
+group :jekyll_plugins do
+ gem 'jekyll-asciidoc'
+end
+#gem 'pygments.rb', '~> 1.2.1'
+gem 'thread_safe', '~> 0.3.6'
+gem 'slim', '~> 4.0.1'
+gem 'tilt', '~> 2.0.9'
diff --git a/docs/README.adoc b/docs/README.adoc
new file mode 100644
index 0000000..1b4a562
--- /dev/null
+++ b/docs/README.adoc
@@ -0,0 +1,61 @@
+= Apache Ignite Documentation
+:toc:
+:toc-title:
+
+== Overview
+The Apache Ignite documentation is maintained in the repository with the code base, in the "/docs" subdirectory. The directory contains the source files, HTML templates and css styles.
+
+
+The Apache Ignite documentation is written in link:https://asciidoctor.org/docs/what-is-asciidoc/[asciidoc].
+The Asciidoc files are compiled into HTML pages and published to https://ignite.apache.org/docs.
+
+
+
+.Content of the “docs” directory
+[cols="1,4",opts="stretch"]
+|===
+| _docs | The directory with .adoc files and code-snippets.
+| _config.yml | Jekyll configuration file.
+|===
+
+
+== Building the Docs Locally
+
+To build the docs locally, you can install `jekyll` and other dependencies on your machine, or you can use Jekyll docker image.
+
+=== Install Jekyll and Asciidoctor
+
+. Install Jekyll by following this instruction: https://jekyllrb.com/docs/installation/[window=_blank]
+. In the “/docs” directory, run the following command:
++
+[source, shell]
+----
+$ bundle
+----
++
+This should install all dependencies, including `asciidoctor`.
+. Start jekyll:
++
+[source, shell]
+----
+$ bundle exec jekyll s
+----
+The command compiles the Asciidoc files into HTML pages and starts a local webserver.
+
+Open `http://localhost:4000/docs[window=_blank]` in your browser.
+
+=== Run with Docker
+
+The following command starts jekyll in a container and downloads all dependencies. Run the command in the “/docs” directory.
+
+[source, shell]
+----
+$ docker run -v "$PWD:/srv/jekyll" -p 4000:4000 jekyll/jekyll:latest jekyll s
+----
+
+Open `http://localhost:4000/docs[window=_blank]` in your browser.
+
+
+== How to Contribute
+
+TBD
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000..d37b794
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1,30 @@
+exclude: [guidelines.md, "Gemfile", "Gemfile.lock", README.adoc, "_docs/code-snippets", "_docs/includes", '*.sh']
+base_url: /docs
+collections:
+ docs:
+ # permalink: /docs/{version}/:path:output_ext
+ output: true
+defaults:
+ -
+ scope:
+ path: ''
+ values:
+ layout: 'doc'
+ -
+ scope:
+ path: '_docs'
+ values:
+ toc: ignite
+asciidoctor:
+ base_dir: _docs/
+ attributes:
+ source-highlighter: rouge
+ stylesdir: assets/css
+ version: "latest"
+ base_url: /docs
+ imagesdir: /docs
+ table-stripes: even
+ javadoc_base_url: https://ignite.apache.org/releases/{version}/javadoc
+ javaCodeDir: code-snippets/java/src/main/java/org/apache/ignite/snippets
+ githubUrl: https://github.com/apache/ignite/tree/master
+
diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
new file mode 100644
index 0000000..50f1f99
--- /dev/null
+++ b/docs/_data/toc.yaml
@@ -0,0 +1,312 @@
+#- title: Quick Start Guide
+# items:
+# - title: Quick Start Overview
+# url: /getting-started/quickstart
+# - title: Java
+# url: /getting-started/quick-start/java
+# - title: .NET/C#
+# url: /getting-started/quick-start/dotnet
+# - title: C++
+# url: /getting-started/quick-start/cpp
+# - title: Python
+# url: /getting-started/quick-start/python
+# - title: Node.JS
+# url: /getting-started/quick-start/nodejs
+# - title: SQL
+# url: /getting-started/quick-start/sql
+# - title: PHP
+# url: /getting-started/quick-start/php
+# - title: REST API
+# url: /getting-started/quick-start/restapi
+#- title: Installation and Upgrade
+# url: /installation-guide
+# items:
+# - title: Deployment Modes
+# url: /installation-guide/deployment-modes
+# - title: Installing Using ZIP Archive
+# url: /installation-guide/installing-using-zip
+# - title: Installing Using Docker
+# url: /installation-guide/installing-using-docker
+# - title: AWS
+# items:
+# - title: Manual Install on Amazon EC2
+# url: /installation-guide/aws/manual-install-on-ec2
+# - title: Amazon EKS Deployment
+# url: /installation-guide/kubernetes/amazon-eks-deployment
+# - title: Microsoft Azure
+# items:
+# - title: Azure Kubernetes Service Deployment
+# url: /installation-guide/kubernetes/azure-deployment
+# - title: Google Kubernetes Engine
+# url: /installation-guide/kubernetes/gke-deployment
+- title: Developer's Guide
+ url: /developers-guide
+ items:
+ - title: Preface
+ url: /developers-guide/preface
+ - title: Setting Up
+ url: /developers-guide/setup
+ - title: Understanding Configuration
+ url: /developers-guide/understanding-configuration
+ - title: Configuring Logging
+ url: /developers-guide/logging
+ - title: Starting and Stopping Nodes
+ url: /developers-guide/starting-nodes
+ - title: Clustering
+ items:
+ - title: Overview
+ url: /developers-guide/clustering/clustering
+ - title: TCP/IP Discovery
+ url: /developers-guide/clustering/tcp-ip-discovery
+ - title: ZooKeeper Discovery
+ url: /developers-guide/clustering/zookeeper-discovery
+ - title: Discovery in the Cloud
+ url: /developers-guide/clustering/discovery-in-the-cloud
+ - title: Data Modeling
+ items:
+ - title: Introduction
+ url: /developers-guide/data-modeling/data-modeling
+ - title: Data Partitioning
+ url: /developers-guide/data-modeling/data-partitioning
+ - title: Affinity Colocation
+ url: /developers-guide/data-modeling/affinity-collocation
+ - title: Configuring Memory
+ items:
+ - title: Memory Architecture
+ url: /developers-guide/memory-architecture
+ - title: Configuring Data Regions
+ url: /developers-guide/memory-configuration/data-regions
+ - title: Eviction Policies
+ url: /developers-guide/memory-configuration/eviction-policies
+ - title: Configuring Caches
+ items:
+ - title: Cache Configuration
+ url: /developers-guide/configuring-caches/configuration-overview
+ - title: Configuring Partition Backups
+ url: /developers-guide/configuring-caches/configuring-backups
+ - title: Atomicity Modes
+ url: /developers-guide/configuring-caches/atomicity-modes
+ - title: Expiry Policy
+ url: /developers-guide/configuring-caches/expiry-policies
+ - title: On-Heap Caching
+ url: /developers-guide/configuring-caches/on-heap-caching
+ - title: Cache Groups
+ url: /developers-guide/configuring-caches/cache-groups
+ - title: Persistence
+ items:
+ - title: Ignite Persistence
+ url: /developers-guide/persistence/native-persistence
+ - title: External Storage
+ url: /developers-guide/persistence/external-storage
+ - title: Swapping
+ url: /developers-guide/persistence/swap
+ - title: Implementing Custom Cache Store
+ url: /developers-guide/persistence/custom-cache-store
+ - title: Baseline Topology
+ url: /developers-guide/baseline-topology
+ - title: Data Rebalancing
+ url: /developers-guide/data-rebalancing
+ - title: Partition Loss Policy
+ url: /developers-guide/partition-loss-policy
+ - title: Data Streaming
+ url: /developers-guide/data-streaming
+ - title: Using Key-Value Cache API
+ items:
+ - title: Basic Cache Operations
+ url: /developers-guide/key-value-api/basic-cache-operations
+ - title: Working with Binary Objects
+ url: /developers-guide/key-value-api/binary-objects
+ - title: Using Scan Queries
+ url: /developers-guide/key-value-api/using-scan-queries
+ - title: Using Continuous Queries
+ url: /developers-guide/key-value-api/continuous-queries
+ - title: Performing Transactions
+ url: /developers-guide/key-value-api/transactions
+ - title: Working with SQL
+# items:
+# - title: Introduction
+# url: /developers-guide/SQL/sql-introduction
+# - title: Understanding Schemas
+# url: /developers-guide/SQL/schemas
+# - title: Defining Indexes
+# url: /developers-guide/SQL/indexes
+# - title: Using SQL API
+# url: /developers-guide/SQL/sql-api
+# - title: Distributed Joins
+# url: /developers-guide/SQL/distributed-joins
+# - title: SQL Transactions
+# url: /developers-guide/SQL/sql-transactions
+# - title: Custom SQL Functions
+# url: /developers-guide/SQL/custom-sql-func
+# - title: JDBC Driver
+# url: /developers-guide/SQL/JDBC/jdbc-driver
+# - title: JDBC Client Driver
+# url: /developers-guide/SQL/JDBC/jdbc-client-driver
+# - title: Multiversion Concurrency Control
+# url: /developers-guide/transactions/mvcc
+ - title: SQL and Key-Value Usage
+ url: /developers-guide/SQL/sql-key-value-storage
+ - title: Distributed Computing
+ items:
+ - title: Distributed Computing API
+ url: /developers-guide/distributed-computing/distributed-computing
+ - title: Cluster Groups
+ url: /developers-guide/distributed-computing/cluster-groups
+ - title: Executor Service
+ url: /developers-guide/distributed-computing/executor-service
+ - title: MapReduce API
+ url: /developers-guide/distributed-computing/map-reduce
+ - title: Load Balancing
+ url: /developers-guide/distributed-computing/load-balancing
+ - title: Fault Tolerance
+ url: /developers-guide/distributed-computing/fault-tolerance
+ - title: Job Scheduling
+ url: /developers-guide/distributed-computing/job-scheduling
+ - title: Colocating Computations with Data
+ url: /developers-guide/collocated-computations
+ - title: Working with Events
+ items:
+ - title: Enabling and Listenting to Events
+ url: /developers-guide/events/listening-to-events
+# - title: Events
+# url: /developers-guide/events/events
+ - title: Near Caches
+ url: /developers-guide/near-cache
+# - title: .NET Platform Cache
+# url: /developers-guide/platform-cache
+ - title: Peer Class Loading
+ url: /developers-guide/peer-class-loading
+# - title: Handling Exceptions
+# url: /developers-guide/handling-exceptions
+#
+# - title: Thin Clients
+# items:
+# - title: Thin Clients Overview
+# url: /developers-guide/thin-clients/getting-started-with-thin-clients
+# - title: Java Thin Client
+# url: /developers-guide/thin-clients/java-thin-client
+# - title: .NET Thin Client
+# url: /developers-guide/thin-clients/dotnet-thin-client
+# - title: C++ Thin Client
+# url: /developers-guide/thin-clients/cpp-thin-client
+# - title: Python Thin Client
+# url: /developers-guide/thin-clients/python-thin-client
+# - title: PHP Thin Client
+# url: /developers-guide/thin-clients/php-thin-client
+# - title: Node.js Thin Client
+# url: /developers-guide/thin-clients/nodejs-thin-client
+# - title: ODBC Driver
+# items:
+# - title: ODBC Driver
+# url: /developers-guide/SQL/ODBC/odbc-driver
+# - title: Connection String and DSN
+# url: /developers-guide/SQL/ODBC/connection-string-dsn
+# - title: Querying and Modifying Data
+# url: /developers-guide/SQL/ODBC/querying-modifying-data
+# - title: Specification
+# url: /developers-guide/SQL/ODBC/specification
+# - title: Data Types
+# url: /developers-guide/SQL/ODBC/data-types
+# - title: Error Codes
+# url: /developers-guide/SQL/ODBC/error-codes
+# - title: REST API
+# url: /developers-guide/restapi
+#
+# - title: Machine Learning
+# items:
+# - title: Machine Learning
+# url: /developers-guide/machine-learning/ml
+# - title: Preprocessing
+# url: /developers-guide/machine-learning/preprocessing
+# - title: Partition Based Dataset
+# url: /developers-guide/machine-learning/part-based-dataset
+# - title: Linear Regression
+# url: /developers-guide/machine-learning/line-reg
+# - title: K-Means Clustering
+# url: /developers-guide/machine-learning/k-means
+# - title: Genetic Algorithms
+# url: /developers-guide/machine-learning/genetic-alg
+# - title: Multilayer Perceptron
+# url: /developers-guide/machine-learning/ml-percep
+# - title: Decision Trees
+# url: /developers-guide/machine-learning/decision-trees
+# - title: k-NN Classification
+# url: /developers-guide/machine-learning/knn-class
+# - title: k-NN Regression
+# url: /developers-guide/machine-learning/knn-reg
+# - title: SVM Binary Classification
+# url: /developers-guide/machine-learning/svm-binary
+# - title: SVM Multi-class Classification
+# url: /developers-guide/machine-learning/svm-multi
+# - title: Model Cross Validation
+# url: /developers-guide/machine-learning/model-cross
+# - title: Logistic Regression
+# url: /developers-guide/machine-learning/log-reg
+# - title: Random Forest
+# url: /developers-guide/machine-learning/random-forest
+# - title: Gradient Boosting
+# url: /developers-guide/machine-learning/grad-boost
+# - title: ANN (Approximate Nearest Neighbor)
+# url: /developers-guide/machine-learning/ann
+# - title: Model updating
+# url: /developers-guide/machine-learning/model-updating
+# - title: Model Importing
+# url: /developers-guide/machine-learning/model-importing
+# - title: Metrics and Monitoring
+# items:
+# - title: Introduction
+# url: /administrators-guide/monitoring-metrics/intro
+# - title: Configuring Metrics
+# url: /administrators-guide/monitoring-metrics/configuring-metrics
+# - title: JMX Metrics
+# url: /administrators-guide/monitoring-metrics/metrics
+# - title: System Views
+# url: /administrators-guide/monitoring-metrics/system-views
+# - title: Capacity Planning
+# url: /administrators-guide/capacity-planning
+# - title: Control Script
+# url: /administrators-guide/control-script
+# - title: Performance and Troubleshooting Guide
+# url: /perf-troubleshooting-guide/general-perf-tips
+# items:
+# - title: General Performance Tips
+# url: /perf-troubleshooting-guide/general-perf-tips
+# - title: Memory and JVM Tuning
+# url: /perf-troubleshooting-guide/memory-tuning
+# - title: Persistence Tuning
+# url: /perf-troubleshooting-guide/persistence-tuning
+# - title: SQL Tuning
+# url: /perf-troubleshooting-guide/sql-tuning
+# - title: Thread Pools Tuning
+# url: /perf-troubleshooting-guide/thread-pools-tuning
+# - title: Troubleshooting and Debugging
+# url: /perf-troubleshooting-guide/troubleshooting
+#
+#- title: SQL Reference
+# url: /sql-reference/sql-reference-overview
+# descripiton: SQL reference information
+# items:
+# - title: SQL Reference Overview
+# url: /sql-reference/sql-reference-overview
+# - title: SQL Conformance
+# url: /sql-reference/sql-conformance
+# - title: Data Definition Language (DDL)
+# url: /sql-reference/ddl
+# - title: Data Manipulation Language (DML)
+# url: /sql-reference/dml
+# - title: Transactions
+# url: /sql-reference/transactions
+# - title: Operational Commands
+# url: /sql-reference/operational-commands
+# - title: Aggregate functions
+# url: /sql-reference/aggregate-functions
+# - title: Numeric Functions
+# url: /sql-reference/numeric-functions
+# - title: String Functions
+# url: /sql-reference/string-functions
+# - title: Data and Time Functions
+# url: /sql-reference/date-time-functions
+# - title: System Functions
+# url: /sql-reference/system-functions
+# - title: Data Types
+# url: /sql-reference/data-types
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/affinity_run.cpp b/docs/_docs/code-snippets/cpp/src/affinity_run.cpp
new file mode 100644
index 0000000..37df6ad
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/affinity_run.cpp
@@ -0,0 +1,132 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+using namespace cache;
+
+//tag::affinity-run[]
+/*
+ * Function class.
+ */
+struct FuncAffinityRun : compute::ComputeFunc<void>
+{
+ /*
+ * Default constructor.
+ */
+ FuncAffinityRun()
+ {
+ // No-op.
+ }
+
+ /*
+ * Parameterized constructor.
+ */
+ FuncAffinityRun(std::string cacheName, int32_t key) :
+ cacheName(cacheName), key(key)
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ */
+ virtual void Call()
+ {
+ Ignite& node = GetIgnite();
+
+ Cache<int32_t, std::string> cache = node.GetCache<int32_t, std::string>(cacheName.c_str());
+
+ // Peek is a local memory lookup.
+ std::cout << "Co-located [key= " << key << ", value= " << cache.LocalPeek(key, CachePeekMode::ALL) << "]" << std::endl;
+ }
+
+ std::string cacheName;
+ int32_t key;
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<FuncAffinityRun>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("FuncAffinityRun");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "FuncAffinityRun";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const FuncAffinityRun& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const FuncAffinityRun& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(FuncAffinityRun& dst)
+ {
+ dst = FuncAffinityRun();
+ }
+
+ static void Write(BinaryWriter& writer, const FuncAffinityRun& obj)
+ {
+ writer.WriteString("cacheName", obj.cacheName);
+ writer.WriteInt32("key", obj.key);
+ }
+
+ static void Read(BinaryReader& reader, FuncAffinityRun& dst)
+ {
+ dst.cacheName = reader.ReadString("cacheName");
+ dst.key = reader.ReadInt32("key");
+ }
+ };
+ }
+}
+
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get cache instance.
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>("myCache");
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<FuncAffinityRun>();
+
+ // Get compute instance.
+ compute::Compute compute = ignite.GetCompute();
+
+ int key = 1;
+
+ // This closure will execute on the remote node where
+ // data for the given 'key' is located.
+ compute.AffinityRun(cache.GetName(), key, FuncAffinityRun(cache.GetName(), key));
+}
+//end::affinity-run[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/cache_asynchronous_execution.cpp b/docs/_docs/code-snippets/cpp/src/cache_asynchronous_execution.cpp
new file mode 100644
index 0000000..f64f348
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/cache_asynchronous_execution.cpp
@@ -0,0 +1,112 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+using namespace cache;
+
+//tag::cache-asynchronous-execution[]
+/*
+ * Function class.
+ */
+class HelloWorld : public compute::ComputeFunc<void>
+{
+ friend struct ignite::binary::BinaryType<HelloWorld>;
+public:
+ /*
+ * Default constructor.
+ */
+ HelloWorld()
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ */
+ virtual void Call()
+ {
+ std::cout << "Job Result: Hello World" << std::endl;
+ }
+
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<HelloWorld>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("HelloWorld");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "HelloWorld";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const HelloWorld& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const HelloWorld& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(HelloWorld& dst)
+ {
+ dst = HelloWorld();
+ }
+
+ static void Write(BinaryWriter& writer, const HelloWorld& obj)
+ {
+ // No-op.
+ }
+
+ static void Read(BinaryReader& reader, HelloWorld& dst)
+ {
+ // No-op.
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<HelloWorld>();
+
+ // Get compute instance.
+ compute::Compute compute = ignite.GetCompute();
+
+ // Declaring function instance.
+ HelloWorld helloWorld;
+
+ // Making asynchronous call.
+ compute.RunAsync(helloWorld);
+}
+//end::cache-asynchronous-execution[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/cache_atomic_operations.cpp b/docs/_docs/code-snippets/cpp/src/cache_atomic_operations.cpp
new file mode 100644
index 0000000..50244fc
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/cache_atomic_operations.cpp
@@ -0,0 +1,38 @@
+#include <iostream>
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+int main()
+{
+ //tag::cache-atomic-operations[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<std::string, int32_t> cache = ignite.GetOrCreateCache<std::string, int32_t>("myNewCache");
+
+ // Put-if-absent which returns previous value.
+ int32_t oldVal = cache.GetAndPutIfAbsent("Hello", 11);
+
+ // Put-if-absent which returns boolean success flag.
+ boolean success = cache.PutIfAbsent("World", 22);
+
+ // Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous value.
+ oldVal = cache.GetAndReplace("Hello", 11);
+
+ // Replace-if-exists operation (opposite of putIfAbsent), returns boolean success flag.
+ success = cache.Replace("World", 22);
+
+ // Replace-if-matches operation.
+ success = cache.Replace("World", 2, 22);
+
+ // Remove-if-matches operation.
+ success = cache.Remove("Hello", 1);
+ //end::cache-atomic-operations[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/cache_creating_dynamically.cpp b/docs/_docs/code-snippets/cpp/src/cache_creating_dynamically.cpp
new file mode 100644
index 0000000..2757184
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/cache_creating_dynamically.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+int main()
+{
+ //tag::cache-creating-dynamically[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Create a cache with the given name, if it does not exist.
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>("myNewCache");
+ //end::cache-creating-dynamically[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/cache_get_put.cpp b/docs/_docs/code-snippets/cpp/src/cache_get_put.cpp
new file mode 100644
index 0000000..96699b0
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/cache_get_put.cpp
@@ -0,0 +1,42 @@
+#include <iostream>
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+/** Cache name. */
+const char* CACHE_NAME = "cacheName";
+
+int main()
+{
+ //tag::cache-get-put[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ try
+ {
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>(CACHE_NAME);
+
+ // Store keys in the cache (the values will end up on different cache nodes).
+ for (int32_t i = 0; i < 10; i++)
+ {
+ cache.Put(i, std::to_string(i));
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ std::cout << "Got [key=" << i << ", val=" + cache.Get(i) << "]" << std::endl;
+ }
+ }
+ catch (IgniteError& err)
+ {
+ std::cout << "An error occurred: " << err.GetText() << std::endl;
+ return err.GetCode();
+ }
+ //end::cache-get-put[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/cache_getting_instance.cpp b/docs/_docs/code-snippets/cpp/src/cache_getting_instance.cpp
new file mode 100644
index 0000000..6d485b4
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/cache_getting_instance.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+int main()
+{
+ //tag::cache-getting-instance[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Obtain instance of cache named "myCache".
+ // Note that different caches may have different generics.
+ Cache<int32_t, std::string> cache = ignite.GetCache<int32_t, std::string>("myCache");
+ //end::cache-getting-instance[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/city.h b/docs/_docs/code-snippets/cpp/src/city.h
new file mode 100644
index 0000000..e485cc4
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/city.h
@@ -0,0 +1,53 @@
+namespace ignite
+{
+ struct City
+ {
+ City() : population(0)
+ {
+ // No-op.
+ }
+
+ City(const int32_t population) :
+ population(population)
+ {
+ // No-op.
+ }
+
+ std::string ToString() const
+ {
+ std::ostringstream oss;
+ oss << "City [population=" << population << ']';
+ return oss.str();
+ }
+
+ int32_t population;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::City)
+
+ typedef ignite::City City;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(City)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(City)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_IS_NULL_FALSE(City)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(City)
+
+ static void Write(BinaryWriter& writer, const ignite::City& obj)
+ {
+ writer.WriteInt32("population", obj.population);
+ }
+
+ static void Read(BinaryReader& reader, ignite::City& dst)
+ {
+ dst.population = reader.ReadInt32("population");
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/city_key.h b/docs/_docs/code-snippets/cpp/src/city_key.h
new file mode 100644
index 0000000..bd735d9
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/city_key.h
@@ -0,0 +1,60 @@
+namespace ignite
+{
+ struct CityKey
+ {
+ CityKey() : id(0)
+ {
+ // No-op.
+ }
+
+ CityKey(int32_t id, const std::string& name) :
+ id(id),
+ name(name)
+ {
+ // No-op.
+ }
+
+ std::string ToString() const
+ {
+ std::ostringstream oss;
+
+ oss << "CityKey [id=" << id
+ << ", name=" << name << ']';
+
+ return oss.str();
+ }
+
+ int32_t id;
+ std::string name;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::CityKey)
+
+ typedef ignite::CityKey CityKey;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(CityKey)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(CityKey)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_IS_NULL_FALSE(CityKey)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CityKey)
+
+ static void Write(BinaryWriter& writer, const ignite::CityKey& obj)
+ {
+ writer.WriteInt64("id", obj.id);
+ writer.WriteString("name", obj.name);
+ }
+
+ static void Read(BinaryReader& reader, ignite::CityKey& dst)
+ {
+ dst.id = reader.ReadInt32("id");
+ dst.name = reader.ReadString("name");
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_acessing_data.cpp b/docs/_docs/code-snippets/cpp/src/compute_acessing_data.cpp
new file mode 100644
index 0000000..60ea5ff
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_acessing_data.cpp
@@ -0,0 +1,118 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+#include "person.h"
+
+using namespace ignite;
+using namespace cache;
+
+//tag::compute-acessing-data[]
+/*
+ * Function class.
+ */
+class GetValue : public compute::ComputeFunc<void>
+{
+ friend struct ignite::binary::BinaryType<GetValue>;
+public:
+ /*
+ * Default constructor.
+ */
+ GetValue()
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ */
+ virtual void Call()
+ {
+ Ignite& node = GetIgnite();
+
+ // Get the data you need
+ Cache<int64_t, Person> cache = node.GetCache<int64_t, Person>("person");
+
+ // do with the data what you need to do
+ Person person = cache.Get(1);
+ }
+};
+//end::compute-acessing-data[]
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<GetValue>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("GetValue");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "GetValue";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const GetValue& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const GetValue& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(GetValue& dst)
+ {
+ dst = GetValue();
+ }
+
+ static void Write(BinaryWriter& writer, const GetValue& obj)
+ {
+ // No-op.
+ }
+
+ static void Read(BinaryReader& reader, GetValue& dst)
+ {
+ // No-op.
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<int64_t, Person> cache = ignite.GetOrCreateCache<int64_t, Person>("person");
+ cache.Put(1, Person(1, "first", "last", "resume", 100.00));
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<GetValue>();
+
+ // Get compute instance.
+ compute::Compute compute = ignite.GetCompute();
+
+ // Run compute task.
+ compute.Run(GetValue());
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_broadcast.cpp b/docs/_docs/code-snippets/cpp/src/compute_broadcast.cpp
new file mode 100644
index 0000000..1e2d873
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_broadcast.cpp
@@ -0,0 +1,137 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+
+/*
+ * 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.
+ */
+
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+
+//tag::compute-broadcast[]
+/*
+ * Function class.
+ */
+class Hello : public compute::ComputeFunc<void>
+{
+ friend struct ignite::binary::BinaryType<Hello>;
+public:
+ /*
+ * Default constructor.
+ */
+ Hello()
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ */
+ virtual void Call()
+ {
+ std::cout << "Hello" << std::endl;
+ }
+
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<Hello>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("Hello");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "Hello";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const Hello& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const Hello& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(Hello& dst)
+ {
+ dst = Hello();
+ }
+
+ static void Write(BinaryWriter& writer, const Hello& obj)
+ {
+ // No-op.
+ }
+
+ static void Read(BinaryReader& reader, Hello& dst)
+ {
+ // No-op.
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<Hello>();
+
+ // Broadcast to all nodes.
+ compute::Compute compute = ignite.GetCompute();
+
+ // Declaring function instance.
+ Hello hello;
+
+ // Print out hello message on nodes in the cluster group.
+ compute.Broadcast(hello);
+}
+//end::compute-broadcast[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_call.cpp b/docs/_docs/code-snippets/cpp/src/compute_call.cpp
new file mode 100644
index 0000000..f7e006e
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_call.cpp
@@ -0,0 +1,135 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+
+//tag::compute-call[]
+/*
+ * Function class.
+ */
+class CountLength : public compute::ComputeFunc<int32_t>
+{
+ friend struct ignite::binary::BinaryType<CountLength>;
+public:
+ /*
+ * Default constructor.
+ */
+ CountLength()
+ {
+ // No-op.
+ }
+
+ /*
+ * Constructor.
+ *
+ * @param text Text.
+ */
+ CountLength(const std::string& word) :
+ word(word)
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ * Counts number of characters in provided word.
+ *
+ * @return Word's length.
+ */
+ virtual int32_t Call()
+ {
+ return word.length();
+ }
+
+ /** Word to print. */
+ std::string word;
+
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<CountLength>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("CountLength");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "CountLength";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const CountLength& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const CountLength& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(CountLength& dst)
+ {
+ dst = CountLength("");
+ }
+
+ static void Write(BinaryWriter& writer, const CountLength& obj)
+ {
+ writer.RawWriter().WriteString(obj.word);
+ }
+
+ static void Read(BinaryReader& reader, CountLength& dst)
+ {
+ dst.word = reader.RawReader().ReadString();
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<CountLength>();
+
+ // Get compute instance.
+ compute::Compute compute = ignite.GetCompute();
+
+ std::istringstream iss("How many characters");
+ std::vector<std::string> words((std::istream_iterator<std::string>(iss)),
+ std::istream_iterator<std::string>());
+
+ int32_t total = 0;
+
+ // Iterate through all words in the sentence, create and call jobs.
+ for (std::string word : words)
+ {
+ // Add word length received from cluster node.
+ total += compute.Call<int32_t>(CountLength(word));
+ }
+}
+//end::compute-call[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_call_async.cpp b/docs/_docs/code-snippets/cpp/src/compute_call_async.cpp
new file mode 100644
index 0000000..63a5415
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_call_async.cpp
@@ -0,0 +1,149 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+
+//tag::compute-call-async[]
+/*
+ * Function class.
+ */
+class CountLength : public compute::ComputeFunc<int32_t>
+{
+ friend struct ignite::binary::BinaryType<CountLength>;
+public:
+ /*
+ * Default constructor.
+ */
+ CountLength()
+ {
+ // No-op.
+ }
+
+ /*
+ * Constructor.
+ *
+ * @param text Text.
+ */
+ CountLength(const std::string& word) :
+ word(word)
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ * Counts number of characters in provided word.
+ *
+ * @return Word's length.
+ */
+ virtual int32_t Call()
+ {
+ return word.length();
+ }
+
+ /** Word to print. */
+ std::string word;
+
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<CountLength>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("CountLength");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "CountLength";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const CountLength& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const CountLength& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(CountLength& dst)
+ {
+ dst = CountLength("");
+ }
+
+ static void Write(BinaryWriter& writer, const CountLength& obj)
+ {
+ writer.RawWriter().WriteString(obj.word);
+ }
+
+ static void Read(BinaryReader& reader, CountLength& dst)
+ {
+ dst.word = reader.RawReader().ReadString();
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<CountLength>();
+
+ // Get compute instance.
+ compute::Compute asyncCompute = ignite.GetCompute();
+
+ std::istringstream iss("Count characters using callable");
+ std::vector<std::string> words((std::istream_iterator<std::string>(iss)),
+ std::istream_iterator<std::string>());
+
+ std::vector<Future<int32_t>> futures;
+
+ // Iterate through all words in the sentence, create and call jobs.
+ for (std::string word : words)
+ {
+ // Counting number of characters remotely.
+ futures.push_back(asyncCompute.CallAsync<int32_t>(CountLength(word)));
+ }
+
+ int32_t total = 0;
+
+ // Counting total number of characters.
+ for (Future<int32_t> future : futures)
+ {
+ // Waiting for results.
+ future.Wait();
+
+ total += future.GetValue();
+ }
+
+ // Printing result.
+ std::cout << "Total number of characters: " << total << std::endl;
+}
+//end::compute-call-async[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_get.cpp b/docs/_docs/code-snippets/cpp/src/compute_get.cpp
new file mode 100644
index 0000000..1442b07
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_get.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+const char* CONFIG_DEFAULT = "/path/to/configuration.xml";
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = CONFIG_DEFAULT;
+
+ //tag::compute-get[]
+ Ignite ignite = Ignition::Start(cfg);
+
+ Compute compute = ignite.GetCompute();
+ //end::compute-get[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/compute_run.cpp b/docs/_docs/code-snippets/cpp/src/compute_run.cpp
new file mode 100644
index 0000000..b357a80
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/compute_run.cpp
@@ -0,0 +1,131 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+
+using namespace ignite;
+
+//tag::compute-run[]
+/*
+ * Function class.
+ */
+class PrintWord : public compute::ComputeFunc<void>
+{
+ friend struct ignite::binary::BinaryType<PrintWord>;
+public:
+ /*
+ * Default constructor.
+ */
+ PrintWord()
+ {
+ // No-op.
+ }
+
+ /*
+ * Constructor.
+ *
+ * @param text Text.
+ */
+ PrintWord(const std::string& word) :
+ word(word)
+ {
+ // No-op.
+ }
+
+ /**
+ * Callback.
+ */
+ virtual void Call()
+ {
+ std::cout << word << std::endl;
+ }
+
+ /** Word to print. */
+ std::string word;
+
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<PrintWord>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("PrintWord");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "PrintWord";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const PrintWord& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const PrintWord& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(PrintWord& dst)
+ {
+ dst = PrintWord("");
+ }
+
+ static void Write(BinaryWriter& writer, const PrintWord& obj)
+ {
+ writer.RawWriter().WriteString(obj.word);
+ }
+
+ static void Read(BinaryReader& reader, PrintWord& dst)
+ {
+ dst.word = reader.RawReader().ReadString();
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a compute function.
+ binding.RegisterComputeFunc<PrintWord>();
+
+ // Get compute instance.
+ compute::Compute compute = ignite.GetCompute();
+
+ std::istringstream iss("Print words on different cluster nodes");
+ std::vector<std::string> words((std::istream_iterator<std::string>(iss)),
+ std::istream_iterator<std::string>());
+
+ // Iterate through all words and print
+ // each word on a different cluster node.
+ for (std::string word : words)
+ {
+ // Run compute task.
+ compute.Run(PrintWord(word));
+ }
+}
+//end::compute-run[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/concurrent_updates.cpp b/docs/_docs/code-snippets/cpp/src/concurrent_updates.cpp
new file mode 100644
index 0000000..0cb124e
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/concurrent_updates.cpp
@@ -0,0 +1,44 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace transactions;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignition::Start(cfg);
+
+ Ignite ignite = Ignition::Get();
+
+ Cache<std::int32_t, std::string> cache = ignite.GetOrCreateCache<std::int32_t, std::string>("myCache");
+
+ //tag::concurrent-updates[]
+ for (int i = 1; i <= 5; i++)
+ {
+ Transaction tx = ignite.GetTransactions().TxStart();
+ std::cout << "attempt #" << i << ", value: " << cache.Get(1) << std::endl;
+ try {
+ cache.Put(1, "new value");
+ tx.Commit();
+ std::cout << "attempt #" << i << " succeeded" << std::endl;
+ break;
+ }
+ catch (IgniteError e)
+ {
+ if (!tx.IsRollbackOnly())
+ {
+ // Transaction was not marked as "rollback only",
+ // so it's not a concurrent update issue.
+ // Process the exception here.
+ break;
+ }
+ }
+ }
+ //end::concurrent-updates[]
+}
diff --git a/docs/_docs/code-snippets/cpp/src/continuous_query.cpp b/docs/_docs/code-snippets/cpp/src/continuous_query.cpp
new file mode 100644
index 0000000..737bdc4
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/continuous_query.cpp
@@ -0,0 +1,71 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+/**
+ * Listener class.
+ */
+template<typename K, typename V>
+class Listener : public event::CacheEntryEventListener<K, V>
+{
+public:
+ /**
+ * Default constructor.
+ */
+ Listener()
+ {
+ // No-op.
+ }
+
+ /**
+ * Event callback.
+ *
+ * @param evts Events.
+ * @param num Events number.
+ */
+ virtual void OnEvent(const CacheEntryEvent<K, V>* evts, uint32_t num)
+ {
+ for (uint32_t i = 0; i < num; ++i)
+ {
+ std::cout << "Queried entry [key=" << (evts[i].HasValue() ? evts[i].GetKey() : K())
+ << ", val=" << (evts[i].HasValue() ? evts[i].GetValue() : V()) << ']'
+ << std::endl;
+ }
+ }
+};
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ //tag::continuous-query[]
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>("myCache");
+
+ // Custom listener
+ Listener<int32_t, std::string> listener;
+
+ // Declaring continuous query.
+ continuous::ContinuousQuery<int32_t, std::string> query(MakeReference(listener));
+
+ // Declaring optional initial query
+ ScanQuery initialQuery = ScanQuery();
+
+ continuous::ContinuousQueryHandle<int32_t, std::string> handle = cache.QueryContinuous(query, initialQuery);
+
+ // Iterating over existing data stored in the cache.
+ QueryCursor<int32_t, std::string> cursor = handle.GetInitialQueryCursor();
+
+ while (cursor.HasNext())
+ {
+ std::cout << cursor.GetNext().GetKey() << std::endl;
+ }
+ //end::continuous-query[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/continuous_query_filter.cpp b/docs/_docs/code-snippets/cpp/src/continuous_query_filter.cpp
new file mode 100644
index 0000000..d87c7f0
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/continuous_query_filter.cpp
@@ -0,0 +1,151 @@
+#include <stdint.h>
+#include <iostream>
+
+#include <ignite/ignition.h>
+#include <ignite/cache/query/continuous/continuous_query.h>
+
+#include "ignite/examples/person.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+/**
+ * Listener class.
+ */
+template<typename K, typename V>
+class Listener : public event::CacheEntryEventListener<K, V>
+{
+public:
+ /**
+ * Default constructor.
+ */
+ Listener()
+ {
+ // No-op.
+ }
+
+ /**
+ * Event callback.
+ *
+ * @param evts Events.
+ * @param num Events number.
+ */
+ virtual void OnEvent(const CacheEntryEvent<K, V>* evts, uint32_t num)
+ {
+ for (uint32_t i = 0; i < num; ++i)
+ {
+ std::cout << "Queried entry [key=" << (evts[i].HasValue() ? evts[i].GetKey() : K())
+ << ", val=" << (evts[i].HasValue() ? evts[i].GetValue() : V()) << ']'
+ << std::endl;
+ }
+ }
+};
+
+//tag::continuous-query-filter[]
+template<typename K, typename V>
+struct RemoteFilter : event::CacheEntryEventFilter<int32_t, std::string>
+{
+ /**
+ * Default constructor.
+ */
+ RemoteFilter()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ virtual ~RemoteFilter()
+ {
+ // No-op.
+ }
+
+ /**
+ * Event callback.
+ *
+ * @param event Event.
+ * @return True if the event passes filter.
+ */
+ virtual bool Process(const CacheEntryEvent<K, V>& event)
+ {
+ std::cout << "The value for key " << event.GetKey() <<
+ " was updated from " << event.GetOldValue() << " to " << event.GetValue() << std::endl;
+ return true;
+ }
+};
+
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType< RemoteFilter<int32_t, std::string> >
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("RemoteFilter<int32_t,std::string>");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "RemoteFilter<int32_t,std::string>";
+
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static bool IsNull(const RemoteFilter<int32_t, std::string>&)
+ {
+ return false;
+ }
+
+ static void GetNull(RemoteFilter<int32_t, std::string>& dst)
+ {
+ dst = RemoteFilter<int32_t, std::string>();
+ }
+
+ static void Write(BinaryWriter& writer, const RemoteFilter<int32_t, std::string>& obj)
+ {
+ // No-op.
+ }
+
+ static void Read(BinaryReader& reader, RemoteFilter<int32_t, std::string>& dst)
+ {
+ // No-op.
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ // Start a node.
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get binding.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering remote filter.
+ binding.RegisterCacheEntryEventFilter<RemoteFilter<int32_t, std::string>>();
+
+ // Get cache instance.
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>("myCache");
+
+ // Declaring custom listener.
+ Listener<int32_t, std::string> listener;
+
+ // Declaring filter.
+ RemoteFilter<int32_t, std::string> filter;
+
+ // Declaring continuous query.
+ continuous::ContinuousQuery<int32_t, std::string> qry(MakeReference(listener), MakeReference(filter));
+}
+//end::continuous-query-filter[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/continuous_query_listener.cpp b/docs/_docs/code-snippets/cpp/src/continuous_query_listener.cpp
new file mode 100644
index 0000000..d04aa6f
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/continuous_query_listener.cpp
@@ -0,0 +1,60 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+//tag::continuous-query-listener[]
+/**
+ * Listener class.
+ */
+template<typename K, typename V>
+class Listener : public event::CacheEntryEventListener<K, V>
+{
+public:
+ /**
+ * Default constructor.
+ */
+ Listener()
+ {
+ // No-op.
+ }
+
+ /**
+ * Event callback.
+ *
+ * @param evts Events.
+ * @param num Events number.
+ */
+ virtual void OnEvent(const CacheEntryEvent<K, V>* evts, uint32_t num)
+ {
+ for (uint32_t i = 0; i < num; ++i)
+ {
+ std::cout << "Queried entry [key=" << (evts[i].HasValue() ? evts[i].GetKey() : K())
+ << ", val=" << (evts[i].HasValue() ? evts[i].GetValue() : V()) << ']'
+ << std::endl;
+ }
+ }
+};
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<int32_t, std::string> cache = ignite.GetOrCreateCache<int32_t, std::string>("myCache");
+
+ // Declaring custom listener.
+ Listener<int32_t, std::string> listener;
+
+ // Declaring continuous query.
+ continuous::ContinuousQuery<int32_t, std::string> query(MakeReference(listener));
+
+ continuous::ContinuousQueryHandle<int32_t, std::string> handle = cache.QueryContinuous(query);
+}
+//end::continuous-query-listener[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/country.h b/docs/_docs/code-snippets/cpp/src/country.h
new file mode 100644
index 0000000..19126fa
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/country.h
@@ -0,0 +1,58 @@
+namespace ignite
+{
+ struct Country
+ {
+ Country() : population(0)
+ {
+ // No-op.
+ }
+
+ Country(const int32_t population, const std::string& name) :
+ population(population),
+ name(name)
+ {
+ // No-op.
+ }
+
+ std::string ToString() const
+ {
+ std::ostringstream oss;
+ oss << "Country [population=" << population
+ << ", name=" << name << ']';
+ return oss.str();
+ }
+
+ int32_t population;
+ std::string name;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::Country)
+
+ typedef ignite::Country Country;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Country)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Country)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_IS_NULL_FALSE(Country)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Country)
+
+ static void Write(BinaryWriter& writer, const ignite::Country& obj)
+ {
+ writer.WriteInt32("population", obj.population);
+ writer.WriteString("name", obj.name);
+ }
+
+ static void Read(BinaryReader& reader, ignite::Country& dst)
+ {
+ dst.population = reader.ReadInt32("population");
+ dst.name = reader.ReadString("name");
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/invoke.cpp b/docs/_docs/code-snippets/cpp/src/invoke.cpp
new file mode 100644
index 0000000..d01d73e
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/invoke.cpp
@@ -0,0 +1,140 @@
+#include <stdint.h>
+#include <iostream>
+#include <sstream>
+
+#include <ignite/ignition.h>
+#include <ignite/compute/compute.h>
+#include "ignite/cache/cache_entry_processor.h"
+
+using namespace ignite;
+using namespace cache;
+
+//tag::invoke[]
+/**
+ * Processor for invoke method.
+ */
+class IncrementProcessor : public cache::CacheEntryProcessor<std::string, int32_t, int32_t, int32_t>
+{
+public:
+ /**
+ * Constructor.
+ */
+ IncrementProcessor()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ IncrementProcessor(const IncrementProcessor& other)
+ {
+ // No-op.
+ }
+
+ /**
+ * Assignment operator.
+ *
+ * @param other Other instance.
+ * @return This instance.
+ */
+ IncrementProcessor& operator=(const IncrementProcessor& other)
+ {
+ return *this;
+ }
+
+ /**
+ * Call instance.
+ */
+ virtual int32_t Process(MutableCacheEntry<std::string, int32_t>& entry, const int& arg)
+ {
+ // Increment the value for a specific key by 1.
+ // The operation will be performed on the node where the key is stored.
+ // Note that if the cache does not contain an entry for the given key, it will
+ // be created.
+ if (!entry.IsExists())
+ entry.SetValue(1);
+ else
+ entry.SetValue(entry.GetValue() + 1);
+
+ return entry.GetValue();
+ }
+};
+
+/**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+namespace ignite
+{
+ namespace binary
+ {
+ template<>
+ struct BinaryType<IncrementProcessor>
+ {
+ static int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("IncrementProcessor");
+ }
+
+ static void GetTypeName(std::string& dst)
+ {
+ dst = "IncrementProcessor";
+ }
+
+ static int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ static int32_t GetHashCode(const IncrementProcessor& obj)
+ {
+ return 0;
+ }
+
+ static bool IsNull(const IncrementProcessor& obj)
+ {
+ return false;
+ }
+
+ static void GetNull(IncrementProcessor& dst)
+ {
+ dst = IncrementProcessor();
+ }
+
+ static void Write(BinaryWriter& writer, const IncrementProcessor& obj)
+ {
+ // No-op.
+ }
+
+ static void Read(BinaryReader& reader, IncrementProcessor& dst)
+ {
+ // No-op.
+ }
+ };
+ }
+}
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "platforms/cpp/examples/put-get-example/config/example-cache.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ // Get cache instance.
+ Cache<std::string, int32_t> cache = ignite.GetOrCreateCache<std::string, int32_t>("myCache");
+
+ // Get binding instance.
+ IgniteBinding binding = ignite.GetBinding();
+
+ // Registering our class as a cache entry processor.
+ binding.RegisterCacheEntryProcessor<IncrementProcessor>();
+
+ std::string key("mykey");
+ IncrementProcessor inc;
+
+ cache.Invoke<int32_t>(key, inc, NULL);
+}
+//end::invoke[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/key_value_execute_sql.cpp b/docs/_docs/code-snippets/cpp/src/key_value_execute_sql.cpp
new file mode 100644
index 0000000..0ae9317
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/key_value_execute_sql.cpp
@@ -0,0 +1,39 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "country.h";
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+const char* CITY_CACHE_NAME = "City";
+const char* COUNTRY_CACHE_NAME = "Country";
+const char* COUNTRY_LANGUAGE_CACHE_NAME = "CountryLanguage";
+
+int main()
+{
+ //tag::key-value-execute-sql[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "config/sql.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<int64_t, std::string> cityCache = ignite.GetOrCreateCache<int64_t, std::string>(CITY_CACHE_NAME);
+ Cache<int64_t, Country> countryCache = ignite.GetOrCreateCache<int64_t, Country>(COUNTRY_CACHE_NAME);
+ Cache<int64_t, std::string> languageCache = ignite.GetOrCreateCache<int64_t, std::string>(COUNTRY_LANGUAGE_CACHE_NAME);
+
+ // SQL Fields Query can only be performed using fields that have been listed in "QueryEntity" been of the config!
+ SqlFieldsQuery query = SqlFieldsQuery("SELECT name, population FROM country ORDER BY population DESC LIMIT 10");
+
+ QueryFieldsCursor cursor = countryCache.Query(query);
+ while (cursor.HasNext())
+ {
+ QueryFieldsRow row = cursor.GetNext();
+ std::string name = row.GetNext<std::string>();
+ std::string population = row.GetNext<std::string>();
+ std::cout << " >>> " << population << " people live in " << name << std::endl;
+ }
+ //end::key-value-execute-sql[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/key_value_object_key.cpp b/docs/_docs/code-snippets/cpp/src/key_value_object_key.cpp
new file mode 100644
index 0000000..8a2ecf4
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/key_value_object_key.cpp
@@ -0,0 +1,36 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "city.h"
+#include "city_key.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+int main()
+{
+ //tag::key-value-object-key[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<CityKey, City> cityCache = ignite.GetOrCreateCache<CityKey, City>("City");
+
+ CityKey key = CityKey(5, "NLD");
+
+ cityCache.Put(key, 100000);
+
+ //getting the city by ID and country code
+ City city = cityCache.Get(key);
+
+ std::cout << ">> Updating Amsterdam record:" << std::endl;
+ city.population = city.population - 10000;
+
+ cityCache.Put(key, city);
+
+ std::cout << cityCache.Get(key).ToString() << std::endl;
+ //end::key-value-object-key[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/person.h b/docs/_docs/code-snippets/cpp/src/person.h
new file mode 100644
index 0000000..bba56c7
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/person.h
@@ -0,0 +1,78 @@
+#include "ignite/binary/binary.h"
+
+namespace ignite
+{
+ struct Person
+ {
+ Person() : orgId(0), salary(.0)
+ {
+ // No-op.
+ }
+
+ Person(int64_t orgId, const std::string& firstName,
+ const std::string& lastName, const std::string& resume, double salary) :
+ orgId(orgId),
+ firstName(firstName),
+ lastName(lastName),
+ resume(resume),
+ salary(salary)
+ {
+ // No-op.
+ }
+
+ std::string ToString() const
+ {
+ std::ostringstream oss;
+
+ oss << "Person [orgId=" << orgId
+ << ", lastName=" << lastName
+ << ", firstName=" << firstName
+ << ", salary=" << salary
+ << ", resume=" << resume << ']';
+
+ return oss.str();
+ }
+
+ int64_t orgId;
+ std::string firstName;
+ std::string lastName;
+ std::string resume;
+ double salary;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::Person)
+
+ typedef ignite::Person Person;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_IS_NULL_FALSE(Person)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)
+
+ static void Write(BinaryWriter& writer, const ignite::Person& obj)
+ {
+ writer.WriteInt64("orgId", obj.orgId);
+ writer.WriteString("firstName", obj.firstName);
+ writer.WriteString("lastName", obj.lastName);
+ writer.WriteString("resume", obj.resume);
+ writer.WriteDouble("salary", obj.salary);
+ }
+
+ static void Read(BinaryReader& reader, ignite::Person& dst)
+ {
+ dst.orgId = reader.ReadInt64("orgId");
+ dst.firstName = reader.ReadString("firstName");
+ dst.lastName = reader.ReadString("lastName");
+ dst.resume = reader.ReadString("resume");
+ dst.salary = reader.ReadDouble("salary");
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/scan_query.cpp b/docs/_docs/code-snippets/cpp/src/scan_query.cpp
new file mode 100644
index 0000000..af78ac3
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/scan_query.cpp
@@ -0,0 +1,37 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "person.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite grid = Ignition::Start(cfg);
+
+ //tag::query-cursor[]
+ Cache<int64_t, Person> cache = ignite.GetOrCreateCache<int64_t, ignite::Person>("personCache");
+
+ QueryCursor<int64_t, Person> cursor = cache.Query(ScanQuery());
+ //end::query-cursor[]
+
+ // Iterate over results.
+ while (cursor.HasNext())
+ {
+ std::cout << cursor.GetNext().GetKey() << std::endl;
+ }
+
+ //tag::set-local[]
+ ScanQuery sq;
+ sq.SetLocal(true);
+
+ QueryCursor<int64_t, Person> cursor = cache.Query(sq);
+ //end::set-local[]
+
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/setting_work_directory.cpp b/docs/_docs/code-snippets/cpp/src/setting_work_directory.cpp
new file mode 100644
index 0000000..6ed63a0
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/setting_work_directory.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+int main()
+{
+ //tag::setting-work-directory[]
+ IgniteConfiguration cfg;
+
+ cfg.igniteHome = "/path/to/work/directory";
+ //end::setting-work-directory[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/sql.cpp b/docs/_docs/code-snippets/cpp/src/sql.cpp
new file mode 100644
index 0000000..154a49c
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/sql.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "person.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "config/sql.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ //tag::sql-fields-query[]
+ Cache<int64_t, Person> cache = ignite.GetOrCreateCache<int64_t, Person>("Person");
+
+ // Iterate over the result set.
+ // SQL Fields Query can only be performed using fields that have been listed in "QueryEntity" been of the config!
+ QueryFieldsCursor cursor = cache.Query(SqlFieldsQuery("select concat(firstName, ' ', lastName) from Person"));
+ while (cursor.HasNext())
+ {
+ std::cout << "personName=" << cursor.GetNext().GetNext<std::string>() << std::endl;
+ }
+ //end::sql-fields-query[]
+
+ //tag::sql-fields-query-scheme[]
+ // SQL Fields Query can only be performed using fields that have been listed in "QueryEntity" been of the config!
+ SqlFieldsQuery sql = SqlFieldsQuery("select name from City");
+ sql.SetSchema("PERSON");
+ //end::sql-fields-query-scheme[]
+
+ //tag::sql-fields-query-scheme-inline[]
+ // SQL Fields Query can only be performed using fields that have been listed in "QueryEntity" been of the config!
+ sql = SqlFieldsQuery("select name from Person.City");
+ //end::sql-fields-query-scheme-inline[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/sql_create.cpp b/docs/_docs/code-snippets/cpp/src/sql_create.cpp
new file mode 100644
index 0000000..49d6b7f
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/sql_create.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "person.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ //tag::sql-create[]
+ Cache<int64_t, Person> cache = ignite.GetOrCreateCache<int64_t, Person>("Person");
+
+ // Creating City table.
+ cache.Query(SqlFieldsQuery("CREATE TABLE City (id int primary key, name varchar, region varchar)"));
+ //end::sql-create[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/sql_join_order.cpp b/docs/_docs/code-snippets/cpp/src/sql_join_order.cpp
new file mode 100644
index 0000000..66b1d29
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/sql_join_order.cpp
@@ -0,0 +1,17 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "person.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace query;
+
+int main()
+{
+ //tag::sql-join-order[]
+ SqlFieldsQuery query = SqlFieldsQuery("SELECT * FROM TABLE_A, TABLE_B USE INDEX(HASH_JOIN_IDX) WHERE TABLE_A.column1 = TABLE_B.column2");
+ query.SetEnforceJoinOrder(true);
+ //end::sql-join-order[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/start_stop_nodes.cpp b/docs/_docs/code-snippets/cpp/src/start_stop_nodes.cpp
new file mode 100644
index 0000000..a5296ae
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/start_stop_nodes.cpp
@@ -0,0 +1,29 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+
+int main()
+{
+ //tag::start-all-nodes[]
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+ //end::start-all-nodes[]
+
+ //tag::activate-cluster[]
+ ignite.SetActive(true);
+ //end::activate-cluster[]
+
+ //tag::deactivate-cluster[]
+ ignite.SetActive(false);
+ //end::deactivate-cluster[]
+
+ //tag::stop-node[]
+ Ignition::Stop(ignite.GetName(), false);
+ //end::stop-node[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/thin_authentication.cpp b/docs/_docs/code-snippets/cpp/src/thin_authentication.cpp
new file mode 100644
index 0000000..71a0aa9
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/thin_authentication.cpp
@@ -0,0 +1,28 @@
+//tag::thin-authentication[]
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/ignite_client_configuration.h>
+
+using namespace ignite::thin;
+
+void TestClientWithAuth()
+{
+ IgniteClientConfiguration cfg;
+ cfg.SetEndPoints("127.0.0.1:10800");
+
+ // Use your own credentials here.
+ cfg.SetUser("ignite");
+ cfg.SetPassword("ignite");
+
+ IgniteClient client = IgniteClient::Start(cfg);
+
+ cache::CacheClient<int32_t, std::string> cacheClient =
+ client.GetOrCreateCache<int32_t, std::string>("TestCache");
+
+ cacheClient.Put(42, "Hello Ignite Thin Client with auth!");
+}
+//end::thin-authentication[]
+
+int main()
+{
+ TestClientWithAuth();
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/thin_client_cache.cpp b/docs/_docs/code-snippets/cpp/src/thin_client_cache.cpp
new file mode 100644
index 0000000..2e0a1b8
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/thin_client_cache.cpp
@@ -0,0 +1,30 @@
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/ignite_client_configuration.h>
+
+using namespace ignite::thin;
+
+int main()
+{
+ IgniteClientConfiguration cfg;
+ cfg.SetEndPoints("127.0.0.1:10800");
+
+ IgniteClient client = IgniteClient::Start(cfg);
+
+ //tag::thin-getting-cache-instance[]
+ cache::CacheClient<int32_t, std::string> cache =
+ client.GetOrCreateCache<int32_t, std::string>("TestCache");
+ //end::thin-getting-cache-instance[]
+
+ //tag::basic-cache-operations[]
+ std::map<int, std::string> vals;
+ for (int i = 1; i < 100; i++)
+ {
+ vals[i] = i;
+ }
+
+ cache.PutAll(vals);
+ cache.Replace(1, "2");
+ cache.Put(101, "101");
+ cache.RemoveAll();
+ //end::basic-cache-operations[]
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/thin_client_ssl.cpp b/docs/_docs/code-snippets/cpp/src/thin_client_ssl.cpp
new file mode 100644
index 0000000..6679840
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/thin_client_ssl.cpp
@@ -0,0 +1,23 @@
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/ignite_client_configuration.h>
+
+using namespace ignite::thin;
+
+void main()
+{
+ //tag::thin-client-ssl[]
+ IgniteClientConfiguration cfg;
+
+ // Sets SSL mode.
+ cfg.SetSslMode(SslMode::Type::REQUIRE);
+
+ // Sets file path to SSL certificate authority to authenticate server certificate during connection establishment.
+ cfg.SetSslCaFile("path/to/SSL/certificate/authority");
+
+ // Sets file path to SSL certificate to use during connection establishment.
+ cfg.SetSslCertFile("path/to/SSL/certificate");
+
+ // Sets file path to SSL private key to use during connection establishment.
+ cfg.SetSslKeyFile("path/to/SSL/private/key");
+ //end::thin-client-ssl[]
+}
diff --git a/docs/_docs/code-snippets/cpp/src/thin_creating_client_instance.cpp b/docs/_docs/code-snippets/cpp/src/thin_creating_client_instance.cpp
new file mode 100644
index 0000000..b61b17a
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/thin_creating_client_instance.cpp
@@ -0,0 +1,26 @@
+//tag::thin-creating-client-instance[]
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/ignite_client_configuration.h>
+
+using namespace ignite::thin;
+
+void TestClient()
+{
+ IgniteClientConfiguration cfg;
+
+ //Endpoints list format is "<host>[port[..range]][,...]"
+ cfg.SetEndPoints("127.0.0.1:11110,example.com:1234..1240");
+
+ IgniteClient client = IgniteClient::Start(cfg);
+
+ cache::CacheClient<int32_t, std::string> cacheClient =
+ client.GetOrCreateCache<int32_t, std::string>("TestCache");
+
+ cacheClient.Put(42, "Hello Ignite Thin Client!");
+}
+//end::thin-creating-client-instance[]
+
+int main()
+{
+ TestClient();
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/thin_partition_awareness.cpp b/docs/_docs/code-snippets/cpp/src/thin_partition_awareness.cpp
new file mode 100644
index 0000000..adb4329
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/thin_partition_awareness.cpp
@@ -0,0 +1,30 @@
+//tag::thin-partition-awareness[]
+#include <ignite/thin/ignite_client.h>
+#include <ignite/thin/ignite_client_configuration.h>
+
+using namespace ignite::thin;
+
+void TestClientPartitionAwareness()
+{
+ IgniteClientConfiguration cfg;
+ cfg.SetEndPoints("127.0.0.1:10800,217.29.2.1:10800,200.10.33.1:10800");
+ cfg.SetPartitionAwareness(true);
+
+ IgniteClient client = IgniteClient::Start(cfg);
+
+ cache::CacheClient<int32_t, std::string> cacheClient =
+ client.GetOrCreateCache<int32_t, std::string>("TestCache");
+
+ cacheClient.Put(42, "Hello Ignite Partition Awareness!");
+
+ cacheClient.RefreshAffinityMapping();
+
+ // Getting a value
+ std::string val = cacheClient.Get(42);
+}
+//end::thin-partition-awareness[]
+
+int main()
+{
+ TestClientPartitionAwareness();
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/cpp/src/transactions.cpp b/docs/_docs/code-snippets/cpp/src/transactions.cpp
new file mode 100644
index 0000000..1f2909f
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/transactions.cpp
@@ -0,0 +1,62 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace transactions;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignition::Start(cfg);
+
+ Ignite ignite = Ignition::Get();
+
+ Cache<std::string, int32_t> cache = ignite.GetOrCreateCache<std::string, int32_t>("myCache");
+
+ //tag::transactions-execution[]
+ Transactions transactions = ignite.GetTransactions();
+
+ Transaction tx = transactions.TxStart();
+ int hello = cache.Get("Hello");
+
+ if (hello == 1)
+ cache.Put("Hello", 11);
+
+ cache.Put("World", 22);
+
+ tx.Commit();
+ //end::transactions-execution[]
+
+ //tag::transactions-optimistic[]
+ // Re-try the transaction a limited number of times.
+ int const retryCount = 10;
+ int retries = 0;
+
+ // Start a transaction in the optimistic mode with the serializable isolation level.
+ while (retries < retryCount)
+ {
+ retries++;
+
+ try
+ {
+ Transaction tx = ignite.GetTransactions().TxStart(
+ TransactionConcurrency::OPTIMISTIC, TransactionIsolation::SERIALIZABLE);
+
+ // commit the transaction
+ tx.Commit();
+
+ // the transaction succeeded. Leave the while loop.
+ break;
+ }
+ catch (IgniteError e)
+ {
+ // Transaction has failed. Retry.
+ }
+ }
+ //end::transactions-optimistic[]
+}
diff --git a/docs/_docs/code-snippets/cpp/src/transactions_pessimistic.cpp b/docs/_docs/code-snippets/cpp/src/transactions_pessimistic.cpp
new file mode 100644
index 0000000..a0e59a8
--- /dev/null
+++ b/docs/_docs/code-snippets/cpp/src/transactions_pessimistic.cpp
@@ -0,0 +1,36 @@
+#include <iostream>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace cache;
+using namespace transactions;
+
+int main()
+{
+ IgniteConfiguration cfg;
+ cfg.springCfgPath = "/path/to/configuration.xml";
+
+ Ignite ignite = Ignition::Start(cfg);
+
+ Cache<int32_t, int32_t> cache = ignite.GetOrCreateCache<int32_t, int32_t>("myCache");
+
+ //tag::transactions-pessimistic[]
+ try {
+ Transaction tx = ignite.GetTransactions().TxStart(
+ TransactionConcurrency::PESSIMISTIC, TransactionIsolation::READ_COMMITTED, 300, 0);
+ cache.Put(1, 1);
+
+ cache.Put(2, 1);
+
+ tx.Commit();
+ }
+ catch (IgniteError& err)
+ {
+ std::cout << "An error occurred: " << err.GetText() << std::endl;
+ std::cin.get();
+ return err.GetCode();
+ }
+ //end::transactions-pessimistic[]
+}
diff --git a/docs/_docs/code-snippets/dotnet/AffinityCollocation.cs b/docs/_docs/code-snippets/dotnet/AffinityCollocation.cs
new file mode 100644
index 0000000..5e37768
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/AffinityCollocation.cs
@@ -0,0 +1,124 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Affinity;
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ // tag::affinityCollocation[]
+ class Person
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public int CityId { get; set; }
+ public string CompanyId { get; set; }
+ }
+
+ class PersonKey
+ {
+ public int Id { get; set; }
+
+ [AffinityKeyMapped] public string CompanyId { get; set; }
+ }
+
+ class Company
+ {
+ public string Name { get; set; }
+ }
+
+ class AffinityCollocation
+ {
+ public static void Example()
+ {
+ var personCfg = new CacheConfiguration
+ {
+ Name = "persons",
+ Backups = 1,
+ CacheMode = CacheMode.Partitioned
+ };
+
+ var companyCfg = new CacheConfiguration
+ {
+ Name = "companies",
+ Backups = 1,
+ CacheMode = CacheMode.Partitioned
+ };
+
+ using (var ignite = Ignition.Start())
+ {
+ var personCache = ignite.GetOrCreateCache<PersonKey, Person>(personCfg);
+ var companyCache = ignite.GetOrCreateCache<string, Company>(companyCfg);
+
+ var person = new Person {Name = "Vasya"};
+
+ var company = new Company {Name = "Company1"};
+
+ personCache.Put(new PersonKey {Id = 1, CompanyId = "company1_key"}, person);
+ companyCache.Put("company1_key", company);
+ }
+ }
+ }
+ // end::affinityCollocation[]
+
+ static class CacheKeyConfigurationExamples
+ {
+ public static void ConfigureAffinityKeyWithCacheKeyConfiguration() {
+ // tag::config-with-key-configuration[]
+ var personCfg = new CacheConfiguration("persons")
+ {
+ KeyConfiguration = new[]
+ {
+ new CacheKeyConfiguration
+ {
+ TypeName = nameof(Person),
+ AffinityKeyFieldName = nameof(Person.CompanyId)
+ }
+ }
+ };
+
+ var companyCfg = new CacheConfiguration("companies");
+
+ IIgnite ignite = Ignition.Start();
+
+ ICache<PersonKey, Person> personCache = ignite.GetOrCreateCache<PersonKey, Person>(personCfg);
+ ICache<string, Company> companyCache = ignite.GetOrCreateCache<string, Company>(companyCfg);
+
+ var companyId = "company_1";
+ Company c1 = new Company {Name = "My company"};
+ Person p1 = new Person {Id = 1, Name = "John", CompanyId = companyId};
+
+ // Both the p1 and c1 objects will be cached on the same node
+ personCache.Put(new PersonKey {Id = 1, CompanyId = companyId}, p1);
+ companyCache.Put(companyId, c1);
+
+ // Get the person object
+ p1 = personCache.Get(new PersonKey {Id = 1, CompanyId = companyId});
+ // end::config-with-key-configuration[]
+ }
+
+ public static void AffinityKeyClass()
+ {
+ // tag::affinity-key-class[]
+ var personCfg = new CacheConfiguration("persons");
+ var companyCfg = new CacheConfiguration("companies");
+
+ IIgnite ignite = Ignition.Start();
+
+ ICache<AffinityKey, Person> personCache = ignite.GetOrCreateCache<AffinityKey, Person>(personCfg);
+ ICache<string, Company> companyCache = ignite.GetOrCreateCache<string, Company>(companyCfg);
+
+ var companyId = "company_1";
+ Company c1 = new Company {Name = "My company"};
+ Person p1 = new Person {Id = 1, Name = "John", CompanyId = companyId};
+
+ // Both the p1 and c1 objects will be cached on the same node
+ personCache.Put(new AffinityKey(1, companyId), p1);
+ companyCache.Put(companyId, c1);
+
+ // Get the person object
+ p1 = personCache.Get(new AffinityKey(1, companyId));
+ // end::affinity-key-class[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/BasicCacheOperations.cs b/docs/_docs/code-snippets/dotnet/BasicCacheOperations.cs
new file mode 100644
index 0000000..40d2011
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/BasicCacheOperations.cs
@@ -0,0 +1,76 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Compute;
+
+namespace dotnet_helloworld
+{
+ public class BasicCacheOperations
+ {
+ public static void AtomicOperations()
+ {
+ // tag::atomicOperations1[]
+ using (var ignite = Ignition.Start("examples/config/example-cache.xml"))
+ {
+ var cache = ignite.GetCache<int, string>("cache_name");
+
+ for (var i = 0; i < 10; i++)
+ {
+ cache.Put(i, i.ToString());
+ }
+
+ for (var i = 0; i < 10; i++)
+ {
+ Console.Write("Got [key=" + i + ", val=" + cache.Get(i) + ']');
+ }
+ }
+ // end::atomicOperations1[]
+
+ // tag::atomicOperations2[]
+ using (var ignite = Ignition.Start("examples/config/example-cache.xml"))
+ {
+ var cache = ignite.GetCache<string, int>("cache_name");
+
+ // Put-if-absent which returns previous value.
+ var oldVal = cache.GetAndPutIfAbsent("Hello", 11);
+
+ // Put-if-absent which returns boolean success flag.
+ var success = cache.PutIfAbsent("World", 22);
+
+ // Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous value.
+ oldVal = cache.GetAndReplace("Hello", 11);
+
+ // Replace-if-exists operation (opposite of putIfAbsent), returns boolean success flag.
+ success = cache.Replace("World", 22);
+
+ // Replace-if-matches operation.
+ success = cache.Replace("World", 2, 22);
+
+ // Remove-if-matches operation.
+ success = cache.Remove("Hello", 1);
+ }
+ // end::atomicOperations2[]
+ }
+
+ // tag::asyncExec[]
+ class HelloworldFunc : IComputeFunc<string>
+ {
+ public string Invoke()
+ {
+ return "Hello World";
+ }
+ }
+
+ public static void AsynchronousExecution()
+ {
+ var ignite = Ignition.Start();
+ var compute = ignite.GetCompute();
+
+ //Execute a closure asynchronously
+ var fut = compute.CallAsync(new HelloworldFunc());
+
+ // Listen for completion and print out the result
+ fut.ContinueWith(Console.Write);
+ }
+ // end::asyncExec[]
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/ClusterGroups.cs b/docs/_docs/code-snippets/dotnet/ClusterGroups.cs
new file mode 100644
index 0000000..2581344
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/ClusterGroups.cs
@@ -0,0 +1,72 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class ClusterGroups
+ {
+ // tag::broadcastAction[]
+ class PrintNodeIdAction : IComputeAction
+ {
+ public void Invoke()
+ {
+ Console.WriteLine("Hello node: " +
+ Ignition.GetIgnite().GetCluster().GetLocalNode().Id);
+ }
+ }
+
+ public static void RemotesBroadcastDemo()
+ {
+ var ignite = Ignition.Start();
+
+ var cluster = ignite.GetCluster();
+
+ // Get compute instance which will only execute
+ // over remote nodes, i.e. all the nodes except for this one.
+ var compute = cluster.ForRemotes().GetCompute();
+
+ // Broadcast to all remote nodes and print the ID of the node
+ // on which this closure is executing.
+ compute.Broadcast(new PrintNodeIdAction());
+ }
+ // end::broadcastAction[]
+
+ public static void ClusterGroupsDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ // tag::clusterGroups[]
+ var cluster = ignite.GetCluster();
+
+ // All nodes on which cache with name "myCache" is deployed,
+ // either in client or server mode.
+ var cacheGroup = cluster.ForCacheNodes("myCache");
+
+ // All data nodes responsible for caching data for "myCache".
+ var dataGroup = cluster.ForDataNodes("myCache");
+
+ // All client nodes that access "myCache".
+ var clientGroup = cluster.ForClientNodes("myCache");
+ // end::clusterGroups[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/ClusteringOverview.cs b/docs/_docs/code-snippets/dotnet/ClusteringOverview.cs
new file mode 100644
index 0000000..5cfebb6
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/ClusteringOverview.cs
@@ -0,0 +1,41 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Communication.Tcp;
+
+namespace dotnet_helloworld
+{
+ class ClusteringOverview
+ {
+ static void Foo()
+ {
+ // tag::ClientsAndServers[]
+ Ignition.ClientMode = true;
+ Ignition.Start();
+ // end::ClientsAndServers[]
+
+ // tag::CommunicationSPI[]
+ var cfg = new IgniteConfiguration
+ {
+ CommunicationSpi = new TcpCommunicationSpi
+ {
+ LocalPort = 1234
+ }
+ };
+ Ignition.Start(cfg);
+ // end::CommunicationSPI[]
+ }
+
+ static void ClientCfg()
+ {
+ // tag::ClientCfg[]
+ var cfg = new IgniteConfiguration
+ {
+ // Enable client mode.
+ ClientMode = true
+ };
+
+ // Start Ignite in client mode.
+ Ignition.Start(cfg);
+ // end::ClientCfg[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/ClusteringTcpIpDiscovery.cs b/docs/_docs/code-snippets/dotnet/ClusteringTcpIpDiscovery.cs
new file mode 100644
index 0000000..77d5029
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/ClusteringTcpIpDiscovery.cs
@@ -0,0 +1,115 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Communication.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ class ClusteringTcpIpDiscovery
+ {
+ public static void MulticastIpFinderDemo()
+ {
+ //tag::multicast[]
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryMulticastIpFinder
+ {
+ MulticastGroup = "228.10.10.157"
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ //end::multicast[]
+ }
+
+ public static void StaticIpFinderDemo()
+ {
+ //tag::static[]
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] {"1.2.3.4", "1.2.3.5:47500..47509" }
+ }
+ }
+ };
+ //end::static[]
+ Ignition.Start(cfg);
+ }
+
+ public static void MulticastAndStaticDemo()
+ {
+ //tag::multicastAndStatic[]
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryMulticastIpFinder
+ {
+ MulticastGroup = "228.10.10.157",
+ Endpoints = new[] {"1.2.3.4", "1.2.3.5:47500..47509" }
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ //end::multicastAndStatic[]
+ }
+
+ public static void IsolatedClustersDemo()
+ {
+ // tag::isolated1[]
+ var firstCfg = new IgniteConfiguration
+ {
+ IgniteInstanceName = "first",
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ },
+ CommunicationSpi = new TcpCommunicationSpi
+ {
+ LocalPort = 48100
+ }
+ };
+ Ignition.Start(firstCfg);
+ // end::isolated1[]
+
+ // tag::isolated2[]
+ var secondCfg = new IgniteConfiguration
+ {
+ IgniteInstanceName = "second",
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 49500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:49500..49520"
+ }
+ }
+ },
+ CommunicationSpi = new TcpCommunicationSpi
+ {
+ LocalPort = 49100
+ }
+ };
+ Ignition.Start(secondCfg);
+ // end::isolated2[]
+
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/ContiniuosQueries.cs b/docs/_docs/code-snippets/dotnet/ContiniuosQueries.cs
new file mode 100644
index 0000000..699f6f2
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/ContiniuosQueries.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Event;
+using Apache.Ignite.Core.Cache.Query.Continuous;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class ContinuousQueries
+ {
+ // tag::localListener[]
+ // tag::remoteFilter[]
+ class LocalListener : ICacheEntryEventListener<int, string>
+ {
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, string>> evts)
+ {
+ foreach (var cacheEntryEvent in evts)
+ {
+ //react to update events here
+ }
+ }
+ }
+ // end::localListener[]
+ class RemoteFilter : ICacheEntryEventFilter<int, string>
+ {
+ public bool Evaluate(ICacheEntryEvent<int, string> e)
+ {
+ if (e.Key == 1)
+ {
+ return false;
+ }
+ Console.WriteLine("the value for key {0} was updated from {1} to {2}", e.Key, e.OldValue, e.Value);
+ return true;
+ }
+ }
+ // end::remoteFilter[]
+
+ // tag::localListener[]
+ public static void ContinuousQueryListenerDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+ var cache = ignite.GetOrCreateCache<int, string>("myCache");
+
+ var query = new ContinuousQuery<int, string>(new LocalListener());
+
+ var handle = cache.QueryContinuous(query);
+
+ cache.Put(1, "1");
+ cache.Put(2, "2");
+ }
+ // end::localListener[]
+
+ // tag::remoteFilter[]
+ public static void ContinuousQueryFilterDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+ var cache = ignite.GetOrCreateCache<int, string>("myCache");
+
+ var query = new ContinuousQuery<int, string>(new LocalListener(), new RemoteFilter());
+
+ var handle = cache.QueryContinuous(query);
+
+ cache.Put(1, "1");
+ cache.Put(2, "2");
+ }
+ // end::remoteFilter[]
+
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/DataModellingConfiguringCaches.cs b/docs/_docs/code-snippets/dotnet/DataModellingConfiguringCaches.cs
new file mode 100644
index 0000000..75075eb
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/DataModellingConfiguringCaches.cs
@@ -0,0 +1,86 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ class DataModellingConfiguringCaches
+ {
+ public static void ConfigurationExample()
+ {
+ // tag::cfg[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "myCache",
+ CacheMode = CacheMode.Partitioned,
+ Backups = 2,
+ RebalanceMode = CacheRebalanceMode.Sync,
+ WriteSynchronizationMode = CacheWriteSynchronizationMode.FullSync,
+ PartitionLossPolicy = PartitionLossPolicy.ReadOnlySafe
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ // end::cfg[]
+ }
+
+ public static void Backups()
+ {
+ // tag::backups[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "myCache",
+ CacheMode = CacheMode.Partitioned,
+ Backups = 1
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ // end::backups[]
+ }
+
+ public static void AsyncBackups()
+ {
+ // tag::synchronization-mode[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "myCache",
+ WriteSynchronizationMode = CacheWriteSynchronizationMode.FullSync,
+ Backups = 1
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ // end::synchronization-mode[]
+ }
+
+
+ public static void CacheTemplates()
+ {
+ // tag::template[]
+ var ignite = Ignition.Start();
+
+ var cfg = new CacheConfiguration
+ {
+ Name = "myCacheTemplate*",
+ CacheMode = CacheMode.Partitioned,
+ Backups = 2
+ };
+
+ ignite.AddCacheConfiguration(cfg);
+ // end::template[]
+ }
+
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/DataModellingDataPartitioning.cs b/docs/_docs/code-snippets/dotnet/DataModellingDataPartitioning.cs
new file mode 100644
index 0000000..76f7bb6
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/DataModellingDataPartitioning.cs
@@ -0,0 +1,36 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ class DataModellingDataPartitioning
+ {
+
+ public static void Foo()
+ {
+ // tag::partitioning[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "Person",
+ Backups = 1,
+ GroupName = "group1"
+ },
+ new CacheConfiguration
+ {
+ Name = "Organization",
+ Backups = 1,
+ GroupName = "group1"
+ }
+ }
+ };
+ Ignition.Start(cfg);
+ // end::partitioning[]
+
+
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/DataRebalancing.cs b/docs/_docs/code-snippets/dotnet/DataRebalancing.cs
new file mode 100644
index 0000000..05aa661
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/DataRebalancing.cs
@@ -0,0 +1,50 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ class DataRebalancing
+ {
+ public static void RebalanceMode()
+ {
+ // tag::RebalanceMode[]
+ IgniteConfiguration cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "mycache",
+ RebalanceMode = CacheRebalanceMode.Sync
+ }
+ }
+ };
+
+ // Start a node.
+ var ignite = Ignition.Start(cfg);
+ // end::RebalanceMode[]
+ }
+
+ public static void RebalanceThrottle()
+ {
+ // tag::RebalanceThrottle[]
+ IgniteConfiguration cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "mycache",
+ RebalanceBatchSize = 2 * 1024 * 1024,
+ RebalanceThrottle = new TimeSpan(0, 0, 0, 0, 100)
+ }
+ }
+ };
+
+ // Start a node.
+ var ignite = Ignition.Start(cfg);
+ // end::RebalanceThrottle[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/DataStreaming.cs b/docs/_docs/code-snippets/dotnet/DataStreaming.cs
new file mode 100644
index 0000000..1d10182
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/DataStreaming.cs
@@ -0,0 +1,208 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Datastream;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class DataStreaming
+ {
+
+ public static void DataStreamerExample()
+ {
+ using (var ignite = Ignition.Start(Util.getIngiteCfg()))
+ {
+ ignite.GetOrCreateCache<int, string>("myCache");
+ //tag::dataStreamer1[]
+ using (var stmr = ignite.GetDataStreamer<int, string>("myCache"))
+ {
+ for (var i = 0; i < 1000; i++)
+ stmr.AddData(i, i.ToString());
+ //end::dataStreamer1[]
+ //tag::dataStreamer2[]
+ stmr.AllowOverwrite = true;
+ //end::dataStreamer2[]
+ //tag::dataStreamer1[]
+ }
+
+ //end::dataStreamer1[]
+ }
+ }
+ // tag::streamReceiver[]
+ private class MyStreamReceiver : IStreamReceiver<int, string>
+ {
+ public void Receive(ICache<int, string> cache, ICollection<ICacheEntry<int, string>> entries)
+ {
+ foreach (var entry in entries)
+ {
+ // do something with the entry
+
+ cache.Put(entry.Key, entry.Value);
+ }
+ }
+ }
+
+ public static void StreamReceiverDemo()
+ {
+ var ignite = Ignition.Start();
+
+ using (var stmr = ignite.GetDataStreamer<int, string>("myCache"))
+ {
+ stmr.AllowOverwrite = true;
+ stmr.Receiver = new MyStreamReceiver();
+ }
+ }
+ // end::streamReceiver[]
+
+ // tag::streamTransformer[]
+ class MyEntryProcessor : ICacheEntryProcessor<string, long, object, object>
+ {
+ public object Process(IMutableCacheEntry<string, long> e, object arg)
+ {
+ //get current count
+ var val = e.Value;
+
+ //increment count by 1
+ e.Value = val == 0 ? 1L : val + 1;
+
+ return null;
+ }
+ }
+
+ public static void StreamTransformerDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+ var cfg = new CacheConfiguration("wordCountCache");
+ var stmCache = ignite.GetOrCreateCache<string, long>(cfg);
+
+ using (var stmr = ignite.GetDataStreamer<string, long>(stmCache.Name))
+ {
+ //Allow data updates
+ stmr.AllowOverwrite = true;
+
+ //Configure data transformation to count instances of the same word
+ stmr.Receiver = new StreamTransformer<string, long, object, object>(new MyEntryProcessor());
+
+ //stream words into the streamer cache
+ foreach (var word in GetWords())
+ {
+ stmr.AddData(word, 1L);
+ }
+ }
+
+ Console.WriteLine(stmCache.Get("a"));
+ Console.WriteLine(stmCache.Get("b"));
+ }
+
+ static IEnumerable<string> GetWords()
+ {
+ //populate words list somehow
+ return Enumerable.Repeat("a", 3).Concat(Enumerable.Repeat("b", 2));
+ }
+ // end::streamTransformer[]
+
+
+ // tag::streamVisitor[]
+ class Instrument
+ {
+ public readonly string Symbol;
+ public double Latest { get; set; }
+ public double High { get; set; }
+ public double Low { get; set; }
+
+ public Instrument(string symbol)
+ {
+ this.Symbol = symbol;
+ }
+ }
+
+ private static Dictionary<string, double> getMarketData()
+ {
+ //populate market data somehow
+ return new Dictionary<string, double>
+ {
+ ["foo"] = 1.0,
+ ["foo"] = 2.0,
+ ["foo"] = 3.0
+ };
+ }
+
+ public static void StreamVisitorDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+
+ var mrktDataCfg = new CacheConfiguration("marketData");
+ var instCfg = new CacheConfiguration("instruments");
+
+ // Cache for market data ticks streamed into the system
+ var mrktData = ignite.GetOrCreateCache<string, double>(mrktDataCfg);
+ // Cache for financial instruments
+ var instCache = ignite.GetOrCreateCache<string, Instrument>(instCfg);
+
+ using (var mktStmr = ignite.GetDataStreamer<string, double>("marketData"))
+ {
+ // Note that we do not populate 'marketData' cache (it remains empty).
+ // Instead we update the 'instruments' cache based on the latest market price.
+ mktStmr.Receiver = new StreamVisitor<string, double>((cache, e) =>
+ {
+ var symbol = e.Key;
+ var tick = e.Value;
+
+ Instrument inst = instCache.Get(symbol);
+
+ if (inst == null)
+ {
+ inst = new Instrument(symbol);
+ }
+
+ // Update instrument price based on the latest market tick.
+ inst.High = Math.Max(inst.High, tick);
+ inst.Low = Math.Min(inst.Low, tick);
+ inst.Latest = tick;
+ });
+ var marketData = getMarketData();
+ foreach (var tick in marketData)
+ {
+ mktStmr.AddData(tick);
+ }
+ mktStmr.Flush();
+ Console.Write(instCache.Get("foo"));
+ }
+ }
+
+ // end::streamVisitor[]
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/DistributedComputingApi.cs b/docs/_docs/code-snippets/dotnet/DistributedComputingApi.cs
new file mode 100644
index 0000000..bb6bbf6
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/DistributedComputingApi.cs
@@ -0,0 +1,267 @@
+using System;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+using Apache.Ignite.Core.Resource;
+
+namespace dotnet_helloworld
+{
+ public class DistributedComputingApi
+ {
+ public static void ForRemotesDemo()
+ {
+ // tag::forRemotes[]
+ var ignite = Ignition.Start();
+ var compute = ignite.GetCluster().ForRemotes().GetCompute();
+ // end::forRemotes[]
+ }
+
+ public static void GetCompute()
+ {
+ // tag::gettingCompute[]
+ var ignite = Ignition.Start();
+ var compute = ignite.GetCompute();
+ // end::gettingCompute[]
+ }
+
+ // tag::computeAction[]
+ class PrintWordAction : IComputeAction
+ {
+ public void Invoke()
+ {
+ foreach (var s in "Print words on different cluster nodes".Split(" "))
+ {
+ Console.WriteLine(s);
+ }
+ }
+ }
+
+ public static void ComputeRunDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+ ignite.GetCompute().Run(new PrintWordAction());
+ }
+ // end::computeAction[]
+
+ // tag::computeFunc[]
+ // tag::async[]
+ class CharCounter : IComputeFunc<int>
+ {
+ private readonly string arg;
+
+ public CharCounter(string arg)
+ {
+ this.arg = arg;
+ }
+
+ public int Invoke()
+ {
+ return arg.Length;
+ }
+ }
+ // end::async[]
+
+ public static void ComputeFuncDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ // Iterate through all words in the sentence and create callable jobs.
+ var calls = "How many characters".Split(" ").Select(s => new CharCounter(s)).ToList();
+
+ // Execute the collection of calls on the cluster.
+ var res = ignite.GetCompute().Call(calls);
+
+ // Add all the word lengths received from cluster nodes.
+ var total = res.Sum();
+ }
+ // end::computeFunc[]
+
+
+ // tag::computeFuncApply[]
+ class CharCountingFunc : IComputeFunc<string, int>
+ {
+ public int Invoke(string arg)
+ {
+ return arg.Length;
+ }
+ }
+
+ public static void Foo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ var res = ignite.GetCompute().Apply(new CharCountingFunc(), "How many characters".Split());
+
+ int total = res.Sum();
+ }
+ // end::computeFuncApply[]
+
+ // tag::broadcast[]
+ class PrintNodeIdAction : IComputeAction
+ {
+ public void Invoke()
+ {
+ Console.WriteLine("Hello node: " +
+ Ignition.GetIgnite().GetCluster().GetLocalNode().Id);
+ }
+ }
+
+ public static void BroadcastDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ // Limit broadcast to remote nodes only.
+ var compute = ignite.GetCluster().ForRemotes().GetCompute();
+ // Print out hello message on remote nodes in the cluster group.
+ compute.Broadcast(new PrintNodeIdAction());
+ }
+ // end::broadcast[]
+
+ // tag::async[]
+ public static void AsyncDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ var calls = "Count character using async compute"
+ .Split(" ").Select(s => new CharCounter(s)).ToList();
+
+ var future = ignite.GetCompute().CallAsync(calls);
+
+ future.ContinueWith(fut =>
+ {
+ var total = fut.Result.Sum();
+ Console.WriteLine("Total number of characters: " + total);
+ });
+ }
+ // end::async[]
+
+ // tag::instanceResource[]
+ class FuncWithDataAccess : IComputeFunc<int>
+ {
+ [InstanceResource] private IIgnite _ignite;
+
+ public int Invoke()
+ {
+ var cache = _ignite.GetCache<int, string>("someCache");
+
+ // get the data you need
+ string cached = cache.Get(1);
+
+ // do with data what you need to do, for example:
+ Console.WriteLine(cached);
+
+ return 1;
+ }
+ }
+ // end::instanceResource[]
+
+ public static void InstanceResourceDemo()
+ {
+ var ignite = Ignition.Start(
+ new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ }
+ );
+
+ var cache = ignite.GetOrCreateCache<int, string>("someCache");
+ cache.Put(1, "foo");
+ ignite.GetCompute().Call(new FuncWithDataAccess());
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/EvictionPolicies.cs b/docs/_docs/code-snippets/dotnet/EvictionPolicies.cs
new file mode 100644
index 0000000..7c62caa
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/EvictionPolicies.cs
@@ -0,0 +1,97 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Cache.Eviction;
+using Apache.Ignite.Core.Configuration;
+using DataPageEvictionMode = Apache.Ignite.Core.Configuration.DataPageEvictionMode;
+
+namespace dotnet_helloworld
+{
+ class EvictionPolicies
+ {
+ public static void RandomLRU()
+ {
+ // tag::randomLRU[]
+ var cfg = new IgniteConfiguration
+ {
+ DataStorageConfiguration = new DataStorageConfiguration
+ {
+ DataRegionConfigurations = new[]
+ {
+ new DataRegionConfiguration
+ {
+ Name = "20GB_Region",
+ InitialSize = 500L * 1024 * 1024,
+ MaxSize = 20L * 1024 * 1024 * 1024,
+ PageEvictionMode = DataPageEvictionMode.RandomLru
+ }
+ }
+ }
+ };
+ // end::randomLRU[]
+ }
+
+ public static void Random2LRU()
+ {
+ // tag::random2LRU[]
+ var cfg = new IgniteConfiguration
+ {
+ DataStorageConfiguration = new DataStorageConfiguration
+ {
+ DataRegionConfigurations = new[]
+ {
+ new DataRegionConfiguration
+ {
+ Name = "20GB_Region",
+ InitialSize = 500L * 1024 * 1024,
+ MaxSize = 20L * 1024 * 1024 * 1024,
+ PageEvictionMode = DataPageEvictionMode.Random2Lru
+ }
+ }
+ }
+ };
+ // end::random2LRU[]
+ }
+
+ public static void LRU()
+ {
+ // tag::LRU[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "cacheName",
+ OnheapCacheEnabled = true,
+ EvictionPolicy = new LruEvictionPolicy
+ {
+ MaxSize = 100000
+ }
+ }
+ }
+ };
+ // end::LRU[]
+ }
+
+ public static void FIFO()
+ {
+ // tag::FIFO[]
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "cacheName",
+ OnheapCacheEnabled = true,
+ EvictionPolicy = new FifoEvictionPolicy
+ {
+ MaxSize = 100000
+ }
+ }
+ }
+ };
+ // end::FIFO[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/ExpiryPolicies.cs b/docs/_docs/code-snippets/dotnet/ExpiryPolicies.cs
new file mode 100644
index 0000000..514a840
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/ExpiryPolicies.cs
@@ -0,0 +1,43 @@
+using System;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Cache.Expiry;
+using Apache.Ignite.Core.Common;
+
+namespace dotnet_helloworld
+{
+ class ExpiryPolicies
+ {
+
+ // tag::cfg[]
+ class ExpiryPolicyFactoryImpl : IFactory<IExpiryPolicy>
+ {
+ public IExpiryPolicy CreateInstance()
+ {
+ return new ExpiryPolicy(TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100),
+ TimeSpan.FromMilliseconds(100));
+ }
+ }
+
+ public static void Example()
+ {
+ var cfg = new CacheConfiguration
+ {
+ Name = "cache_name",
+ ExpiryPolicyFactory = new ExpiryPolicyFactoryImpl()
+ };
+ // end::cfg[]
+ }
+
+ public static void EagerTtl()
+ {
+ // tag::eagerTTL[]
+ var cfg = new CacheConfiguration
+ {
+ Name = "cache_name",
+ EagerTtl = true
+ };
+ // end::eagerTTL[]
+ }
+
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/MapReduceApi.cs b/docs/_docs/code-snippets/dotnet/MapReduceApi.cs
new file mode 100644
index 0000000..52efdfe
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/MapReduceApi.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cluster;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class MapReduceApi
+ {
+ // tag::mapReduceComputeTask[]
+ // tag::computeTaskExample[]
+ class CharCountComputeJob : IComputeJob<int>
+ {
+ private readonly string _arg;
+
+ public CharCountComputeJob(string arg)
+ {
+ Console.WriteLine(">>> Printing '" + arg + "' from compute job.");
+ this._arg = arg;
+ }
+
+ public int Execute()
+ {
+ return _arg.Length;
+ }
+
+ public void Cancel()
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+
+ // end::computeTaskExample[]
+
+ class CharCountTask : IComputeTask<string, int, int>
+ {
+ public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, string arg)
+ {
+ var map = new Dictionary<IComputeJob<int>, IClusterNode>();
+ using (var enumerator = subgrid.GetEnumerator())
+ {
+ foreach (var s in arg.Split(" "))
+ {
+ if (!enumerator.MoveNext())
+ {
+ enumerator.Reset();
+ enumerator.MoveNext();
+ }
+
+ map.Add(new CharCountComputeJob(s), enumerator.Current);
+ }
+ }
+
+ return map;
+ }
+
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ {
+ // If there is no exception, wait for all job results.
+ return res.Exception != null ? ComputeJobResultPolicy.Failover : ComputeJobResultPolicy.Wait;
+ }
+
+ public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ return results.Select(res => res.Data).Sum();
+ }
+ }
+
+ public static void MapReduceComputeJobDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+
+ var compute = ignite.GetCompute();
+
+ var res = compute.Execute(new CharCountTask(), "Hello Grid Please Count Chars In These Words");
+
+ Console.WriteLine("res=" + res);
+ }
+ // end::mapReduceComputeTask[]
+
+ // tag::computeTaskExample[]
+ public class ComputeTaskExample
+ {
+ private class CharacterCountTask : ComputeTaskSplitAdapter<string, int, int>
+ {
+ public override int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ return results.Select(res => res.Data).Sum();
+ }
+
+ protected override ICollection<IComputeJob<int>> Split(int gridSize, string arg)
+ {
+ return arg.Split(" ")
+ .Select(word => new CharCountComputeJob(word))
+ .Cast<IComputeJob<int>>()
+ .ToList();
+ }
+ }
+
+ public static void RunComputeTaskExample()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+
+ var cnt = ignite.GetCompute().Execute(new CharacterCountTask(), "Hello Grid Enabled World!");
+ Console.WriteLine(">>> Total number of characters in the phrase is '" + cnt + "'.");
+ }
+ }
+ // end::computeTaskExample[]
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/NearCaches.cs b/docs/_docs/code-snippets/dotnet/NearCaches.cs
new file mode 100644
index 0000000..8e31da0
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/NearCaches.cs
@@ -0,0 +1,102 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Cache.Eviction;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class NearCaches
+ {
+ public static void ConfiguringNearCache()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+
+ //tag::nearCacheConf[]
+ var cacheCfg = new CacheConfiguration
+ {
+ Name = "myCache",
+ NearConfiguration = new NearCacheConfiguration
+ {
+ EvictionPolicy = new LruEvictionPolicy
+ {
+ MaxSize = 100_000
+ }
+ }
+ };
+
+ var cache = ignite.GetOrCreateCache<int, int>(cacheCfg);
+ //end::nearCacheConf[]
+ }
+
+ public static void NearCacheOnClientNodeDemo()
+ {
+ //tag::nearCacheClientNode[]
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ },
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration {Name = "myCache"}
+ }
+ });
+ var client = Ignition.Start(new IgniteConfiguration
+ {
+ IgniteInstanceName = "clientNode",
+ ClientMode = true,
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+ // Create a near-cache configuration
+ var nearCfg = new NearCacheConfiguration
+ {
+ // Use LRU eviction policy to automatically evict entries
+ // from near-cache, whenever it reaches 100_000 in size.
+ EvictionPolicy = new LruEvictionPolicy()
+ {
+ MaxSize = 100_000
+ }
+ };
+
+
+ // get the cache named "myCache" and create a near cache for it
+ var cache = client.GetOrCreateNearCache<int, string>("myCache", nearCfg);
+ //end::nearCacheClientNode[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/OnHeapCaching.cs b/docs/_docs/code-snippets/dotnet/OnHeapCaching.cs
new file mode 100644
index 0000000..f3c21c6
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/OnHeapCaching.cs
@@ -0,0 +1,19 @@
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ class OnHeapCaching
+ {
+ public static void Run()
+ {
+ // tag::onheap[]
+ var cfg = new CacheConfiguration
+ {
+ Name = "myCache",
+ OnheapCacheEnabled = true
+ };
+ // end::onheap[]
+ }
+
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/PeerClassLoading.cs b/docs/_docs/code-snippets/dotnet/PeerClassLoading.cs
new file mode 100644
index 0000000..55fba2e
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/PeerClassLoading.cs
@@ -0,0 +1,36 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Deployment;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class PeerClassLoading
+ {
+ public static void PeerClassLoadingEnabled()
+ {
+ //tag::enable[]
+ var cfg = new IgniteConfiguration
+ {
+ PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain
+ };
+ //end::enable[]
+ var discoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ };
+ cfg.DiscoverySpi = discoverySpi;
+ //tag::enable[]
+ var ignite = Ignition.Start(cfg);
+ //end::enable[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/PerformingTransactions.cs b/docs/_docs/code-snippets/dotnet/PerformingTransactions.cs
new file mode 100644
index 0000000..a2db2ab
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/PerformingTransactions.cs
@@ -0,0 +1,136 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+using Apache.Ignite.Core.Transactions;
+
+namespace dotnet_helloworld
+{
+ public class PerformingTransactions
+ {
+ public static void TransactionExecutionDemo()
+ {
+ // tag::executingTransactions[]
+ // tag::optimisticTx[]
+ // tag::deadlock[]
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ },
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "cacheName",
+ AtomicityMode = CacheAtomicityMode.Transactional
+ }
+ },
+ TransactionConfiguration = new TransactionConfiguration
+ {
+ DefaultTimeoutOnPartitionMapExchange = TimeSpan.FromSeconds(20)
+ }
+ };
+
+ var ignite = Ignition.Start(cfg);
+ // end::optimisticTx[]
+ // end::deadlock[]
+ var cache = ignite.GetCache<string, int>("cacheName");
+ cache.Put("Hello", 1);
+ var transactions = ignite.GetTransactions();
+
+ using (var tx = transactions.TxStart())
+ {
+ int hello = cache.Get("Hello");
+
+ if (hello == 1)
+ {
+ cache.Put("Hello", 11);
+ }
+
+ cache.Put("World", 22);
+
+ tx.Commit();
+ }
+ // end::executingTransactions[]
+
+ // tag::optimisticTx[]
+ // Re-try the transaction a limited number of times
+ var retryCount = 10;
+ var retries = 0;
+
+ // Start a transaction in the optimistic mode with the serializable isolation level
+ while (retries < retryCount)
+ {
+ retries++;
+ try
+ {
+ using (var tx = ignite.GetTransactions().TxStart(TransactionConcurrency.Optimistic,
+ TransactionIsolation.Serializable))
+ {
+ // modify cache entries as part of this transaction.
+
+ // commit the transaction
+ tx.Commit();
+
+ // the transaction succeeded. Leave the while loop.
+ break;
+ }
+ }
+ catch (TransactionOptimisticException)
+ {
+ // Transaction has failed. Retry.
+ }
+
+ }
+ // end::optimisticTx[]
+
+ // tag::deadlock[]
+ var intCache = ignite.GetOrCreateCache<int, int>("intCache");
+ try
+ {
+ using (var tx = ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
+ TransactionIsolation.ReadCommitted, TimeSpan.FromMilliseconds(300), 0))
+ {
+ intCache.Put(1, 1);
+ intCache.Put(2, 1);
+ tx.Commit();
+ }
+ }
+ catch (TransactionTimeoutException e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ catch (TransactionDeadlockException e)
+ {
+ Console.WriteLine(e.Message);
+ }
+
+ // end::deadlock[]
+ }
+
+ public static void TxTimeoutOnPme()
+ {
+ // tag::pmeTimeout[]
+ var cfg = new IgniteConfiguration
+ {
+ TransactionConfiguration = new TransactionConfiguration
+ {
+ DefaultTimeoutOnPartitionMapExchange = TimeSpan.FromSeconds(20)
+ }
+ };
+ Ignition.Start(cfg);
+ // end::pmeTimeout[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/PersistenceIgnitePersistence.cs b/docs/_docs/code-snippets/dotnet/PersistenceIgnitePersistence.cs
new file mode 100644
index 0000000..25fd619
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/PersistenceIgnitePersistence.cs
@@ -0,0 +1,66 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Configuration;
+
+namespace dotnet_helloworld
+{
+ class PersistenceIgnitePersistence
+ {
+ public static void DisablingWal()
+ {
+ // tag::disableWal[]
+ var cacheName = "myCache";
+ var ignite = Ignition.Start();
+ ignite.GetCluster().DisableWal(cacheName);
+
+ //load data
+
+ ignite.GetCluster().EnableWal(cacheName);
+ // end::disableWal[]
+ }
+
+ public static void Configuration()
+ {
+ // tag::cfg[]
+ var cfg = new IgniteConfiguration
+ {
+ DataStorageConfiguration = new DataStorageConfiguration
+ {
+ // tag::storage-path[]
+ StoragePath = "/ssd/storage",
+
+ // end::storage-path[]
+ DefaultDataRegionConfiguration = new DataRegionConfiguration
+ {
+ Name = "Default_Region",
+ PersistenceEnabled = true
+ }
+ }
+ };
+
+ Ignition.Start(cfg);
+ // end::cfg[]
+ }
+
+ public static void Swapping()
+ {
+ // tag::cfg-swap[]
+ var cfg = new IgniteConfiguration
+ {
+ DataStorageConfiguration = new DataStorageConfiguration
+ {
+ DataRegionConfigurations = new[]
+ {
+ new DataRegionConfiguration
+ {
+ Name = "5GB_Region",
+ InitialSize = 100L * 1024 * 1024,
+ MaxSize = 5L * 1024 * 1024 * 1024,
+ SwapPath = "/path/to/some/directory"
+ }
+ }
+ }
+ };
+ // end::cfg-swap[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/dotnet/UnderstandingConfiguration.cs b/docs/_docs/code-snippets/dotnet/UnderstandingConfiguration.cs
new file mode 100644
index 0000000..816f599
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/UnderstandingConfiguration.cs
@@ -0,0 +1,34 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Configuration;
+
+namespace dotnet_helloworld
+{
+ class UnderstandingConfiguration
+ {
+ static void Foo()
+ {
+ // tag::UnderstandingConfigurationProgrammatic[]
+ var igniteCfg = new IgniteConfiguration
+ {
+ WorkDirectory = "/path/to/work/directory",
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration
+ {
+ Name = "myCache",
+ CacheMode = CacheMode.Partitioned
+ }
+ }
+ };
+ // end::UnderstandingConfigurationProgrammatic[]
+
+ // tag::SettingWorkDir[]
+ var cfg = new IgniteConfiguration
+ {
+ WorkDirectory = "/path/to/work/directory"
+ };
+ // end::SettingWorkDir[]
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/UsingScanQueries.cs b/docs/_docs/code-snippets/dotnet/UsingScanQueries.cs
new file mode 100644
index 0000000..2930ab2
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/UsingScanQueries.cs
@@ -0,0 +1,65 @@
+using System;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Query;
+
+namespace dotnet_helloworld_queries
+{
+
+ class Person
+ {
+ public string Name { get; set; }
+ public int Salary { get; set; }
+ }
+
+ public class UsingScanQueries
+ {
+ public static void ExecutingScanQueries()
+ {
+ var ignite = Ignition.Start();
+ var cache = ignite.GetOrCreateCache<int, Person>("person_cache");
+ // tag::scanQry1[]
+ var cursor = cache.Query(new ScanQuery<int, Person>());
+ // end::scanQry1[]
+ }
+
+ // tag::scanQry2[]
+ class SalaryFilter : ICacheEntryFilter<int, Person>
+ {
+ public bool Invoke(ICacheEntry<int, Person> entry)
+ {
+ return entry.Value.Salary > 1000;
+ }
+ }
+
+ public static void ScanQueryFilterDemo()
+ {
+ var ignite = Ignition.Start();
+ var cache = ignite.GetOrCreateCache<int, Person>("person_cache");
+
+ cache.Put(1, new Person {Name = "person1", Salary = 1001});
+ cache.Put(2, new Person {Name = "person2", Salary = 999});
+
+ using (var cursor = cache.Query(new ScanQuery<int, Person>(new SalaryFilter())))
+ {
+ foreach (var entry in cursor)
+ {
+ Console.WriteLine("Key = " + entry.Key + ", Value = " + entry.Value);
+ }
+ }
+ }
+
+ // end::scanQry2[]
+
+ public static void LocalScanQuery()
+ {
+ var ignite = Ignition.Start();
+ var cache = ignite.GetOrCreateCache<int, Person>("person_cache");
+
+ // tag::scanQryLocal[]
+ var query = new ScanQuery<int, Person> {Local = true};
+ var cursor = cache.Query(query);
+ // end::scanQryLocal[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/dotnet/WorkingWithBinaryObjects.cs b/docs/_docs/code-snippets/dotnet/WorkingWithBinaryObjects.cs
new file mode 100644
index 0000000..45bc890
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/WorkingWithBinaryObjects.cs
@@ -0,0 +1,126 @@
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Binary;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Discovery.Tcp;
+using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+namespace dotnet_helloworld
+{
+ public class WorkingWithBinaryObjects
+ {
+ class Book
+ {
+ public string Title { get; set; }
+ }
+
+ class MyEntryProcessor : ICacheEntryProcessor<int, IBinaryObject, object, object>
+ {
+ public object Process(IMutableCacheEntry<int, IBinaryObject> entry, object arg)
+ {
+ // Create a builder from the old value
+ var bldr = entry.Value.ToBuilder();
+
+ //Update the field in the builder
+ bldr.SetField("Name", "Ignite");
+
+ // Set new value to the entry
+ entry.Value = bldr.Build();
+
+ return null;
+ }
+ }
+
+ public static void EntryProcessorForBinaryObjectDemo()
+ {
+ var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ LocalPort = 48500,
+ LocalPortRange = 20,
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[]
+ {
+ "127.0.0.1:48500..48520"
+ }
+ }
+ }
+ });
+
+
+ var cache = ignite.CreateCache<int, object>("cacheName");
+ var key = 101;
+ cache.Put(key, new Book {Title = "book_name"});
+
+ cache
+ .WithKeepBinary<int, IBinaryObject>()
+ .Invoke(key, new MyEntryProcessor(), null);
+ // Not supported yet: https://issues.apache.org/jira/browse/IGNITE-3825
+ }
+ // tag::entryProcessor[]
+ // Not supported in C# for now
+ // end::entryProcessor[]
+
+ public class ExampleGlobalNameMapper : IBinaryNameMapper
+ {
+ public string GetTypeName(string name)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public string GetFieldName(string name)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+
+ public class ExampleGlobalIdMapper : IBinaryIdMapper
+ {
+ public int GetTypeId(string typeName)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public int GetFieldId(int typeId, string fieldName)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+
+ public class ExampleSerializer : IBinarySerializer
+ {
+ public void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public void ReadBinary(object obj, IBinaryReader reader)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+
+ public static void ConfiguringBinaryObjects()
+ {
+ // tag::binaryCfg[]
+ var cfg = new IgniteConfiguration
+ {
+ BinaryConfiguration = new BinaryConfiguration
+ {
+ NameMapper = new ExampleGlobalNameMapper(),
+ IdMapper = new ExampleGlobalIdMapper(),
+ TypeConfigurations = new[]
+ {
+ new BinaryTypeConfiguration
+ {
+ TypeName = "org.apache.ignite.examples.*",
+ Serializer = new ExampleSerializer()
+ }
+ }
+ }
+ };
+ // end::binaryCfg[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/java/pom.xml b/docs/_docs/code-snippets/java/pom.xml
new file mode 100644
index 0000000..e0bcbe9
--- /dev/null
+++ b/docs/_docs/code-snippets/java/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>code-snippets</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <ignite.version>2.8.1</ignite.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>ignite-log4j2</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>ignite-jcl</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>ignite-slf4j</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-urideploy</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-zookeeper</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-cloud</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-aws</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-gce</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>8.0.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>5.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.6.2</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.7.0</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.2</version>
+ <configuration>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.22.2</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/AffinityCollocationExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/AffinityCollocationExample.java
new file mode 100644
index 0000000..663d940
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/AffinityCollocationExample.java
@@ -0,0 +1,134 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.AffinityKey;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.configuration.CacheConfiguration;
+
+//tag::collocation[]
+public class AffinityCollocationExample {
+
+ static class Person {
+ private int id;
+ private String companyId;
+ private String name;
+
+ public Person(int id, String companyId, String name) {
+ this.id = id;
+ this.companyId = companyId;
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+
+ static class PersonKey {
+ private int id;
+
+ @AffinityKeyMapped
+ private String companyId;
+
+ public PersonKey(int id, String companyId) {
+ this.id = id;
+ this.companyId = companyId;
+ }
+ }
+
+ static class Company {
+ private String id;
+ private String name;
+
+ public Company(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ public void configureAffinityKeyWithAnnotation() {
+ CacheConfiguration<PersonKey, Person> personCfg = new CacheConfiguration<PersonKey, Person>("persons");
+ personCfg.setBackups(1);
+
+ CacheConfiguration<String, Company> companyCfg = new CacheConfiguration<>("companies");
+ companyCfg.setBackups(1);
+
+ try (Ignite ignite = Ignition.start()) {
+ IgniteCache<PersonKey, Person> personCache = ignite.getOrCreateCache(personCfg);
+ IgniteCache<String, Company> companyCache = ignite.getOrCreateCache(companyCfg);
+
+ Company c1 = new Company("company1", "My company");
+ Person p1 = new Person(1, c1.getId(), "John");
+
+ // Both the p1 and c1 objects will be cached on the same node
+ personCache.put(new PersonKey(p1.getId(), c1.getId()), p1);
+ companyCache.put("company1", c1);
+
+ // Get the person object
+ p1 = personCache.get(new PersonKey(1, "company1"));
+ }
+ }
+
+ // tag::affinity-key-class[]
+ public void configureAffinitKeyWithAffinityKeyClass() {
+ CacheConfiguration<AffinityKey<Integer>, Person> personCfg = new CacheConfiguration<AffinityKey<Integer>, Person>(
+ "persons");
+ personCfg.setBackups(1);
+
+ CacheConfiguration<String, Company> companyCfg = new CacheConfiguration<String, Company>("companies");
+ companyCfg.setBackups(1);
+
+ Ignite ignite = Ignition.start();
+
+ IgniteCache<AffinityKey<Integer>, Person> personCache = ignite.getOrCreateCache(personCfg);
+ IgniteCache<String, Company> companyCache = ignite.getOrCreateCache(companyCfg);
+
+ Company c1 = new Company("company1", "My company");
+ Person p1 = new Person(1, c1.getId(), "John");
+
+ // Both the p1 and c1 objects will be cached on the same node
+ personCache.put(new AffinityKey<Integer>(p1.getId(), c1.getId()), p1);
+ companyCache.put(c1.getId(), c1);
+
+ // Get the person object
+ p1 = personCache.get(new AffinityKey(1, "company1"));
+ }
+
+ // end::affinity-key-class[]
+ // tag::config-with-key-configuration[]
+ public void configureAffinityKeyWithCacheKeyConfiguration() {
+ CacheConfiguration<PersonKey, Person> personCfg = new CacheConfiguration<PersonKey, Person>("persons");
+ personCfg.setBackups(1);
+
+ // Configure the affinity key
+ personCfg.setKeyConfiguration(new CacheKeyConfiguration("Person", "companyId"));
+
+ CacheConfiguration<String, Company> companyCfg = new CacheConfiguration<String, Company>("companies");
+ companyCfg.setBackups(1);
+
+ Ignite ignite = Ignition.start();
+
+ IgniteCache<PersonKey, Person> personCache = ignite.getOrCreateCache(personCfg);
+ IgniteCache<String, Company> companyCache = ignite.getOrCreateCache(companyCfg);
+
+ Company c1 = new Company("company1", "My company");
+ Person p1 = new Person(1, c1.getId(), "John");
+
+ // Both the p1 and c1 objects will be cached on the same node
+ personCache.put(new PersonKey(1, c1.getId()), p1);
+ companyCache.put(c1.getId(), c1);
+
+ // Get the person object
+ p1 = personCache.get(new PersonKey(1, "company1"));
+ }
+ // end::config-with-key-configuration[]
+}
+//end::collocation[]
\ No newline at end of file
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BackupFilter.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BackupFilter.java
new file mode 100644
index 0000000..f376a0e
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BackupFilter.java
@@ -0,0 +1,23 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilter;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.junit.jupiter.api.Test;
+
+public class BackupFilter {
+
+ @Test
+ void backupFilter() {
+
+ //tag::backup-filter[]
+ CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<Integer, String>("myCache");
+
+ cacheCfg.setBackups(1);
+ RendezvousAffinityFunction af = new RendezvousAffinityFunction();
+ af.setAffinityBackupFilter(new ClusterNodeAttributeAffinityBackupFilter("AVAILABILITY_ZONE"));
+
+ cacheCfg.setAffinity(af);
+ //end::backup-filter[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BaselineTopology.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BaselineTopology.java
new file mode 100644
index 0000000..da631f1
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BaselineTopology.java
@@ -0,0 +1,32 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+
+public class BaselineTopology {
+
+ void activate() {
+ //tag::activate[]
+ Ignite ignite = Ignition.start();
+
+ ignite.cluster().active(true);
+ //end::activate[]
+ }
+
+ void enableAutoadjustment() {
+ //tag::enable-autoadjustment[]
+
+ Ignite ignite = Ignition.start();
+
+ ignite.cluster().baselineAutoAdjustEnabled(true);
+
+ ignite.cluster().baselineAutoAdjustTimeout(30000);
+
+ //end::enable-autoadjustment[]
+
+ //tag::disable-autoadjustment[]
+ ignite.cluster().baselineAutoAdjustEnabled(false);
+ //end::disable-autoadjustment[]
+
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BasicCacheOperations.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BasicCacheOperations.java
new file mode 100644
index 0000000..87631db
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/BasicCacheOperations.java
@@ -0,0 +1,111 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.lang.IgniteFuture;
+import org.junit.jupiter.api.Test;
+
+public class BasicCacheOperations {
+
+ @Test
+ void getCacheInstanceExample() {
+ Ignition.start();
+ Ignition.ignite().createCache("myCache");
+ // tag::getCache[]
+ Ignite ignite = Ignition.ignite();
+
+ // Obtain an instance of the cache named "myCache".
+ // Note that different caches may have different generics.
+ IgniteCache<Integer, String> cache = ignite.cache("myCache");
+ // end::getCache[]
+ Ignition.ignite().close();
+ }
+
+ @Test
+ void createCacheExample() {
+ Ignition.start();
+ // tag::createCache[]
+ Ignite ignite = Ignition.ignite();
+
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setName("myNewCache");
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+ // Create a cache with the given name if it does not exist.
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg);
+ // end::createCache[]
+ Ignition.ignite().close();
+ }
+
+ @Test
+ void destroyCacheExaple() {
+ Ignition.start();
+ Ignition.ignite().createCache("myCache");
+ // tag::destroyCache[]
+ Ignite ignite = Ignition.ignite();
+
+ IgniteCache<Long, String> cache = ignite.cache("myCache");
+
+ cache.destroy();
+ // end::destroyCache[]
+ Ignition.ignite().close();
+ }
+
+ @Test
+ void atomicOperationsExample() {
+ try (Ignite ignite = Ignition.start()) {
+ ignite.createCache("myCache");
+ // tag::atomic1[]
+ IgniteCache<Integer, String> cache = ignite.cache("myCache");
+
+ // Store keys in the cache (the values will end up on different cache nodes).
+ for (int i = 0; i < 10; i++)
+ cache.put(i, Integer.toString(i));
+
+ for (int i = 0; i < 10; i++)
+ System.out.println("Got [key=" + i + ", val=" + cache.get(i) + ']');
+ // end::atomic1[]
+ // tag::atomic2[]
+ // Put-if-absent which returns previous value.
+ String oldVal = cache.getAndPutIfAbsent(11, "Hello");
+
+ // Put-if-absent which returns boolean success flag.
+ boolean success = cache.putIfAbsent(22, "World");
+
+ // Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous
+ // value.
+ oldVal = cache.getAndReplace(11, "New value");
+
+ // Replace-if-exists operation (opposite of putIfAbsent), returns boolean
+ // success flag.
+ success = cache.replace(22, "Other new value");
+
+ // Replace-if-matches operation.
+ success = cache.replace(22, "Other new value", "Yet-another-new-value");
+
+ // Remove-if-matches operation.
+ success = cache.remove(11, "Hello");
+ // end::atomic2[]
+ }
+ }
+
+ @Test
+ void asyncExecutionExample() {
+ try (Ignite ignite = Ignition.start()) {
+ // tag::async[]
+ IgniteCompute compute = ignite.compute();
+
+ // Execute a closure asynchronously.
+ IgniteFuture<String> fut = compute.callAsync(() -> "Hello World");
+
+ // Listen for completion and print out the result.
+ fut.listen(f -> System.out.println("Job result: " + f.get()));
+ // end::async[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CacheJdbcPersonStore.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CacheJdbcPersonStore.java
new file mode 100644
index 0000000..e024770
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CacheJdbcPersonStore.java
@@ -0,0 +1,105 @@
+package org.apache.ignite.snippets;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.cache.Cache.Entry;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.lang.IgniteBiInClosure;
+
+//tag::class[]
+public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
+ // This method is called whenever the "get(...)" methods are called on IgniteCache.
+ @Override
+ public Person load(Long key) {
+ try (Connection conn = connection()) {
+ try (PreparedStatement st = conn.prepareStatement("select * from PERSON where id=?")) {
+ st.setLong(1, key);
+
+ ResultSet rs = st.executeQuery();
+
+ return rs.next() ? new Person(rs.getInt(1), rs.getString(2)) : null;
+ }
+ } catch (SQLException e) {
+ throw new CacheLoaderException("Failed to load: " + key, e);
+ }
+ }
+
+ @Override
+ public void write(Entry<? extends Long, ? extends Person> entry) throws CacheWriterException {
+ try (Connection conn = connection()) {
+ // Syntax of MERGE statement is database specific and should be adopted for your database.
+ // If your database does not support MERGE statement then use sequentially
+ // update, insert statements.
+ try (PreparedStatement st = conn.prepareStatement("merge into PERSON (id, name) key (id) VALUES (?, ?)")) {
+ Person val = entry.getValue();
+
+ st.setLong(1, entry.getKey());
+ st.setString(2, val.getName());
+
+ st.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CacheWriterException("Failed to write entry (" + entry + ")", e);
+ }
+ }
+
+ // This method is called whenever the "remove(...)" method are called on IgniteCache.
+ @Override
+ public void delete(Object key) {
+ try (Connection conn = connection()) {
+ try (PreparedStatement st = conn.prepareStatement("delete from PERSON where id=?")) {
+ st.setLong(1, (Long) key);
+
+ st.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CacheWriterException("Failed to delete: " + key, e);
+ }
+ }
+
+ // This method is called whenever the "loadCache()" and "localLoadCache()"
+ // methods are called on IgniteCache. It is used for bulk-loading the cache.
+ // If you don't need to bulk-load the cache, skip this method.
+ @Override
+ public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
+ if (args == null || args.length == 0 || args[0] == null)
+ throw new CacheLoaderException("Expected entry count parameter is not provided.");
+
+ final int entryCnt = (Integer) args[0];
+
+ try (Connection conn = connection()) {
+ try (PreparedStatement st = conn.prepareStatement("select * from PERSON")) {
+ try (ResultSet rs = st.executeQuery()) {
+ int cnt = 0;
+
+ while (cnt < entryCnt && rs.next()) {
+ Person person = new Person(rs.getInt(1), rs.getString(2));
+ clo.apply(person.getId(), person);
+ cnt++;
+ }
+ }
+ }
+ } catch (SQLException e) {
+ throw new CacheLoaderException("Failed to load values from cache store.", e);
+ }
+ }
+
+ // Open JDBC connection.
+ private Connection connection() throws SQLException {
+ // Open connection to your RDBMS systems (Oracle, MySQL, Postgres, DB2, Microsoft SQL, etc.)
+ Connection conn = DriverManager.getConnection("jdbc:mysql://[host]:[port]/[database]", "YOUR_USER_NAME", "YOUR_PASSWORD");
+
+ conn.setAutoCommit(true);
+
+ return conn;
+ }
+}
+
+//end::class[]
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterGroups.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterGroups.java
new file mode 100644
index 0000000..4228a54
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterGroups.java
@@ -0,0 +1,43 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+
+public class ClusterGroups {
+
+ void remoteNodes() {
+ // tag::remote-nodes[]
+ Ignite ignite = Ignition.ignite();
+
+ IgniteCluster cluster = ignite.cluster();
+
+ // Get compute instance which will only execute
+ // over remote nodes, i.e. all the nodes except for this one.
+ IgniteCompute compute = ignite.compute(cluster.forRemotes());
+
+ // Broadcast to all remote nodes and print the ID of the node
+ // on which this closure is executing.
+ compute.broadcast(() -> System.out.println("Hello Node: " + ignite.cluster().localNode().id()));
+ // end::remote-nodes[]
+ }
+
+ void example(Ignite ignite) {
+ // tag::examples[]
+ IgniteCluster cluster = ignite.cluster();
+
+ // All nodes on which the cache with name "myCache" is deployed,
+ // either in client or server mode.
+ ClusterGroup cacheGroup = cluster.forCacheNodes("myCache");
+
+ // All data nodes responsible for caching data for "myCache".
+ ClusterGroup dataGroup = cluster.forDataNodes("myCache");
+
+ // All client nodes that can access "myCache".
+ ClusterGroup clientGroup = cluster.forClientNodes("myCache");
+
+ // end::examples[]
+ }
+}
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
new file mode 100644
index 0000000..ced0d06
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusteringOverview.java
@@ -0,0 +1,67 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.junit.jupiter.api.Test;
+
+public class ClusteringOverview {
+
+ @Test
+ void clientModeCfg() {
+ Ignite serverNode = Ignition.start(new IgniteConfiguration().setIgniteInstanceName("server-node"));
+ // tag::clientCfg[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Enable client mode.
+ cfg.setClientMode(true);
+
+ // Start the node in client mode.
+ Ignite ignite = Ignition.start(cfg);
+ // end::clientCfg[]
+
+ ignite.close();
+ serverNode.close();
+ }
+
+ @Test
+ void setClientModeEnabledByIgnition() {
+
+ Ignite serverNode = Ignition.start(new IgniteConfiguration().setIgniteInstanceName("server-node"));
+ // tag::clientModeIgnition[]
+ Ignition.setClientMode(true);
+
+ // Start the node in the client mode.
+ Ignite ignite = Ignition.start();
+ // end::clientModeIgnition[]
+
+
+ ignite.close();
+ serverNode.close();
+ }
+
+ @Test
+ void communicationSpiDemo() {
+
+ Ignite serverNode = Ignition.start(new IgniteConfiguration().setIgniteInstanceName("server-node"));
+ // tag::commSpi[]
+ TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
+
+ // Override local port.
+ commSpi.setLocalPort(4321);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ // end::commSpi[]
+ // tag::commSpi[]
+
+ // Override default communication SPI.
+ cfg.setCommunicationSpi(commSpi);
+
+ // Start grid.
+ Ignition.start(cfg);
+ // end::commSpi[]
+ serverNode.close();
+ Ignition.ignite().close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CollocatedComputations.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CollocatedComputations.java
new file mode 100644
index 0000000..f0bec76
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/CollocatedComputations.java
@@ -0,0 +1,168 @@
+package org.apache.ignite.snippets;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.cache.Cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+public class CollocatedComputations {
+
+ public static void main(String[] args) {
+ Ignite ignite = Ignition.start();
+ HashSet<Long> keys = new HashSet<>();
+ keys.add(1L);
+ keys.add(2L);
+ keys.add(3L);
+ keys.add(4L);
+
+ calculateAverage(ignite, keys);
+
+ }
+
+ void collocatingByKey(Ignite ignite) {
+ // tag::collocating-by-key[]
+ IgniteCache<Integer, String> cache = ignite.cache("myCache");
+
+ IgniteCompute compute = ignite.compute();
+
+ int key = 1;
+
+ // This closure will execute on the remote node where
+ // data for the given 'key' is located.
+ compute.affinityRun("myCache", key, () -> {
+ // Peek is a local memory lookup.
+ System.out.println("Co-located [key= " + key + ", value= " + cache.localPeek(key) + ']');
+ });
+
+ // end::collocating-by-key[]
+ }
+
+ // tag::calculate-average[]
+ // this task sums up the values of the salary field for the given set of keys
+ private static class SumTask implements IgniteCallable<BigDecimal> {
+ private Set<Long> keys;
+
+ public SumTask(Set<Long> keys) {
+ this.keys = keys;
+ }
+
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override
+ public BigDecimal call() throws Exception {
+
+ IgniteCache<Long, BinaryObject> cache = ignite.cache("person").withKeepBinary();
+
+ BigDecimal sum = new BigDecimal(0);
+
+ for (long k : keys) {
+ BinaryObject person = cache.localPeek(k, CachePeekMode.PRIMARY);
+ if (person != null)
+ sum = sum.add(new BigDecimal((float) person.field("salary")));
+ }
+
+ return sum;
+ }
+ }
+
+ public static void calculateAverage(Ignite ignite, Set<Long> keys) {
+
+ // get the affinity function configured for the cache
+ Affinity<Long> affinityFunc = ignite.affinity("person");
+
+ // this map stores collections of keys for each partition
+ HashMap<Integer, Set<Long>> partMap = new HashMap<>();
+ keys.forEach(k -> {
+ int partId = affinityFunc.partition(k);
+
+ Set<Long> keysByPartition = partMap.computeIfAbsent(partId, key -> new HashSet<Long>());
+ keysByPartition.add(k);
+ });
+
+ BigDecimal total = new BigDecimal(0);
+
+ IgniteCompute compute = ignite.compute();
+
+ List<String> caches = Arrays.asList("person");
+
+ // iterate over all partitions
+ for (Map.Entry<Integer, Set<Long>> pair : partMap.entrySet()) {
+ // send a task that gets specific keys for the partition
+ BigDecimal sum = compute.affinityCall(caches, pair.getKey().intValue(), new SumTask(pair.getValue()));
+ total = total.add(sum);
+ }
+
+ System.out.println("the average salary is " + total.floatValue() / keys.size());
+ }
+
+ // end::calculate-average[]
+
+ // tag::sum-by-partition[]
+ // this task sums up the value of the 'salary' field for all objects stored in
+ // the given partition
+ private static class SumByPartitionTask implements IgniteCallable<BigDecimal> {
+ private int partId;
+
+ public SumByPartitionTask(int partId) {
+ this.partId = partId;
+ }
+
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override
+ public BigDecimal call() throws Exception {
+ // use binary objects to avoid deserialization
+ IgniteCache<Long, BinaryObject> cache = ignite.cache("person").withKeepBinary();
+
+ BigDecimal total = new BigDecimal(0);
+ try (QueryCursor<Cache.Entry<Long, BinaryObject>> cursor = cache
+ .query(new ScanQuery<Long, BinaryObject>(partId).setLocal(true))) {
+ for (Cache.Entry<Long, BinaryObject> entry : cursor) {
+ total = total.add(new BigDecimal((float) entry.getValue().field("salary")));
+ }
+ }
+
+ return total;
+ }
+ }
+
+ // end::sum-by-partition[]
+
+ public static void entryProcessor(Ignite ignite) {
+ // tag::entry-processor[]
+ IgniteCache<String, Integer> cache = ignite.cache("mycache");
+
+ // Increment the value for a specific key by 1.
+ // The operation will be performed on the node where the key is stored.
+ // Note that if the cache does not contain an entry for the given key, it will
+ // be created.
+ cache.invoke("mykey", (entry, args) -> {
+ Integer val = entry.getValue();
+
+ entry.setValue(val == null ? 1 : val + 1);
+
+ return null;
+ });
+
+ // end::entry-processor[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ComputeTaskExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ComputeTaskExample.java
new file mode 100644
index 0000000..cbcc943
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ComputeTaskExample.java
@@ -0,0 +1,65 @@
+package org.apache.ignite.snippets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+
+//tag::compute-task-example[]
+public class ComputeTaskExample {
+ private static class CharacterCountTask extends ComputeTaskSplitAdapter<String, Integer> {
+ // 1. Splits the received string into words
+ // 2. Creates a child job for each word
+ // 3. Sends the jobs to other nodes for processing.
+ @Override
+ public List<ComputeJob> split(int gridSize, String arg) {
+ String[] words = arg.split(" ");
+
+ List<ComputeJob> jobs = new ArrayList<>(words.length);
+
+ for (final String word : words) {
+ jobs.add(new ComputeJobAdapter() {
+ @Override
+ public Object execute() {
+ System.out.println(">>> Printing '" + word + "' on from compute job.");
+
+ // Return the number of letters in the word.
+ return word.length();
+ }
+ });
+ }
+
+ return jobs;
+ }
+
+ @Override
+ public Integer reduce(List<ComputeJobResult> results) {
+ int sum = 0;
+
+ for (ComputeJobResult res : results)
+ sum += res.<Integer>getData();
+
+ return sum;
+ }
+ }
+
+ public static void main(String[] args) {
+
+ Ignite ignite = Ignition.start();
+
+ IgniteCompute compute = ignite.compute();
+
+ // Execute the task on the cluster and wait for its completion.
+ int cnt = compute.execute(CharacterCountTask.class, "Hello Grid Enabled World!");
+
+ System.out.println(">>> Total number of characters in the phrase is '" + cnt + "'.");
+ }
+}
+
+//end::compute-task-example[]
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ConfiguringCaches.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ConfiguringCaches.java
new file mode 100644
index 0000000..f5705a3
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ConfiguringCaches.java
@@ -0,0 +1,88 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.PartitionLossPolicy;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class ConfiguringCaches {
+
+ public static void main(String[] args) {
+ configurationExample();
+ cacheTemplateExample();
+ }
+
+ public static void configurationExample() {
+ // tag::cfg[]
+ CacheConfiguration cacheCfg = new CacheConfiguration("myCache");
+
+ cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ cacheCfg.setBackups(2);
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ cacheCfg.setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setCacheConfiguration(cacheCfg);
+
+ // Start a node.
+ Ignition.start(cfg);
+ // end::cfg[]
+ Ignition.ignite().close();
+ }
+
+ public static void cacheTemplateExample() {
+ // tag::template[]
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+
+ try (Ignite ignite = Ignition.start(igniteCfg)) {
+ CacheConfiguration cacheCfg = new CacheConfiguration("myCacheTemplate");
+
+ cacheCfg.setBackups(2);
+ cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+
+ // Register the cache template
+ ignite.addCacheConfiguration(cacheCfg);
+ }
+ // end::template[]
+ }
+
+ static void backupsSync() {
+ // tag::synchronization-mode[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+ cacheCfg.setBackups(1);
+ cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ // Start the node.
+ Ignition.start(cfg);
+ // end::synchronization-mode[]
+ }
+
+ static void configuringBackups() {
+ // tag::backups[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+ cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ cacheCfg.setBackups(1);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+
+ // end::backups[]
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataPartitioning.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataPartitioning.java
new file mode 100644
index 0000000..3d9ebf6
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataPartitioning.java
@@ -0,0 +1,51 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.PartitionLossPolicy;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.junit.jupiter.api.Test;
+
+public class DataPartitioning {
+
+ @Test
+ void configurationExample() {
+ // tag::cfg[]
+ // Defining cluster configuration.
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Defining Person cache configuration.
+ CacheConfiguration<Integer, Person> personCfg = new CacheConfiguration<Integer, Person>("Person");
+
+ personCfg.setBackups(1);
+
+ // Group the cache belongs to.
+ personCfg.setGroupName("group1");
+
+ // Defining Organization cache configuration.
+ CacheConfiguration orgCfg = new CacheConfiguration("Organization");
+
+ orgCfg.setBackups(1);
+
+ // Group the cache belongs to.
+ orgCfg.setGroupName("group1");
+
+ cfg.setCacheConfiguration(personCfg, orgCfg);
+
+ // Starting the node.
+ Ignition.start(cfg);
+ // end::cfg[]
+ Ignition.ignite().close();
+ }
+
+ @Test
+ void partitionLossPolicy() {
+ //tag::partition-loss-policy[]
+
+ CacheConfiguration<Integer, Person> personCfg = new CacheConfiguration<Integer, Person>("Person");
+
+ personCfg.setPartitionLossPolicy(PartitionLossPolicy.IGNORE);
+
+ //end::partition-loss-policy[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataRegionConfigurationExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataRegionConfigurationExample.java
new file mode 100644
index 0000000..2174d0c
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataRegionConfigurationExample.java
@@ -0,0 +1,55 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataPageEvictionMode;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class DataRegionConfigurationExample {
+
+ public static void main(String[] args) {
+
+ //tag::ignite-config[]
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+ //tag::default[]
+
+ DataRegionConfiguration defaultRegion = new DataRegionConfiguration();
+ defaultRegion.setName("Default_Region");
+ defaultRegion.setInitialSize(100 * 1024 * 1024);
+
+ storageCfg.setDefaultDataRegionConfiguration(defaultRegion);
+ //end::default[]
+ //tag::data-regions[]
+ // 40MB memory region with eviction enabled.
+ DataRegionConfiguration regionWithEviction = new DataRegionConfiguration();
+ regionWithEviction.setName("40MB_Region_Eviction");
+ regionWithEviction.setInitialSize(20 * 1024 * 1024);
+ regionWithEviction.setMaxSize(40 * 1024 * 1024);
+ regionWithEviction.setPageEvictionMode(DataPageEvictionMode.RANDOM_2_LRU);
+
+ storageCfg.setDataRegionConfigurations(regionWithEviction);
+ //end::data-regions[]
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setDataStorageConfiguration(storageCfg);
+ //tag::caches[]
+
+ CacheConfiguration cache1 = new CacheConfiguration("SampleCache");
+ //this cache will be hosted in the "40MB_Region_Eviction" data region
+ cache1.setDataRegionName("40MB_Region_Eviction");
+
+ cfg.setCacheConfiguration(cache1);
+ //end::caches[]
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::ignite-config[]
+
+ ignite.close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataStreaming.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataStreaming.java
new file mode 100644
index 0000000..f7cab57
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DataStreaming.java
@@ -0,0 +1,163 @@
+package org.apache.ignite.snippets;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.stream.StreamReceiver;
+import org.apache.ignite.stream.StreamTransformer;
+import org.apache.ignite.stream.StreamVisitor;
+import org.junit.jupiter.api.Test;
+
+public class DataStreaming {
+
+ @Test
+ void dataStreamerExample() {
+ try (Ignite ignite = Ignition.start()) {
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
+ //tag::dataStreamer1[]
+ // Get the data streamer reference and stream data.
+ try (IgniteDataStreamer<Integer, String> stmr = ignite.dataStreamer("myCache")) {
+ // Stream entries.
+ for (int i = 0; i < 100000; i++)
+ stmr.addData(i, Integer.toString(i));
+ //end::dataStreamer1[]
+ //tag::dataStreamer2[]
+ stmr.allowOverwrite(true);
+ //end::dataStreamer2[]
+ //tag::dataStreamer1[]
+ }
+ System.out.println("dataStreamerExample output:" + cache.get(99999));
+ //end::dataStreamer1[]
+ }
+ }
+
+ @Test
+ void streamTransformerExample() {
+ try (Ignite ignite = Ignition.start()) {
+ //tag::streamTransformer[]
+ String[] text = { "hello", "world", "hello", "Ignite" };
+ CacheConfiguration<String, Long> cfg = new CacheConfiguration<>("wordCountCache");
+
+ IgniteCache<String, Long> stmCache = ignite.getOrCreateCache(cfg);
+
+ try (IgniteDataStreamer<String, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
+ // Allow data updates.
+ stmr.allowOverwrite(true);
+
+ // Configure data transformation to count instances of the same word.
+ stmr.receiver(StreamTransformer.from((e, arg) -> {
+ // Get current count.
+ Long val = e.getValue();
+
+ // Increment count by 1.
+ e.setValue(val == null ? 1L : val + 1);
+
+ return null;
+ }));
+
+ // Stream words into the streamer cache.
+ for (String word : text)
+ stmr.addData(word, 1L);
+
+ }
+ //end::streamTransformer[]
+ System.out.println("StreamTransformer example output:" + stmCache.get("hello"));
+ }
+ }
+
+ @Test
+ void streamReceiverExample() {
+ try (Ignite ignite = Ignition.start()) {
+ ignite.getOrCreateCache("myCache");
+ //tag::streamReceiver[]
+ try (IgniteDataStreamer<Integer, String> stmr = ignite.dataStreamer("myCache")) {
+
+ stmr.allowOverwrite(true);
+
+ stmr.receiver((StreamReceiver<Integer, String>) (cache, entries) -> entries.forEach(entry -> {
+
+ // do something with the entry
+
+ cache.put(entry.getKey(), entry.getValue());
+ }));
+ }
+ //end::streamReceiver[]
+ }
+ }
+
+ @Test
+ void poolSize() {
+ //tag::pool-size[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ cfg.setDataStreamerThreadPoolSize(10);
+
+ Ignite ignite = Ignition.start(cfg);
+ //end::pool-size[]
+ ignite.close();
+ }
+
+ // tag::stream-visitor[]
+ static class Instrument {
+ final String symbol;
+ Double latest;
+ Double high;
+ Double low;
+
+ public Instrument(String symbol) {
+ this.symbol = symbol;
+ }
+
+ }
+
+ static Map<String, Double> getMarketData() {
+ //populate market data somehow
+ return new HashMap<>();
+ }
+
+ @Test
+ void streamVisitorExample() {
+ try (Ignite ignite = Ignition.start()) {
+ CacheConfiguration<String, Double> mrktDataCfg = new CacheConfiguration<>("marketData");
+ CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instruments");
+
+ // Cache for market data ticks streamed into the system.
+ IgniteCache<String, Double> mrktData = ignite.getOrCreateCache(mrktDataCfg);
+
+ // Cache for financial instruments.
+ IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg);
+
+ try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer("marketData")) {
+ // Note that we do not populate the 'marketData' cache (it remains empty).
+ // Instead we update the 'instruments' cache based on the latest market price.
+ mktStmr.receiver(StreamVisitor.from((cache, e) -> {
+ String symbol = e.getKey();
+ Double tick = e.getValue();
+
+ Instrument inst = instCache.get(symbol);
+
+ if (inst == null)
+ inst = new Instrument(symbol);
+
+ // Update instrument price based on the latest market tick.
+ inst.high = Math.max(inst.high, tick);
+ inst.low = Math.min(inst.low, tick);
+ inst.latest = tick;
+
+ // Update the instrument cache.
+ instCache.put(symbol, inst);
+ }));
+
+ // Stream market data into the cluster.
+ Map<String, Double> marketData = getMarketData();
+ for (Map.Entry<String, Double> tick : marketData.entrySet())
+ mktStmr.addData(tick);
+ }
+ }
+ }
+ // end::stream-visitor[]
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DiscoveryInTheCloud.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DiscoveryInTheCloud.java
new file mode 100644
index 0000000..b0c57e4
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DiscoveryInTheCloud.java
@@ -0,0 +1,135 @@
+package org.apache.ignite.snippets;
+
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.auth.InstanceProfileCredentialsProvider;
+import java.util.Arrays;
+import java.util.Collections;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.elb.TcpDiscoveryElbIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder;
+
+public class DiscoveryInTheCloud {
+
+ public static void apacheJcloudsExample() {
+ //tag::jclouds[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryCloudIpFinder ipFinder = new TcpDiscoveryCloudIpFinder();
+
+ // Configuration for AWS EC2.
+ ipFinder.setProvider("aws-ec2");
+ ipFinder.setIdentity("yourAccountId");
+ ipFinder.setCredential("yourAccountKey");
+ ipFinder.setRegions(Collections.singletonList("us-east-1"));
+ ipFinder.setZones(Arrays.asList("us-east-1b", "us-east-1e"));
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start a node.
+ Ignition.start(cfg);
+ //end::jclouds[]
+ }
+
+ public static void awsExample1() {
+ //tag::aws1[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ BasicAWSCredentials creds = new BasicAWSCredentials("yourAccessKey", "yourSecreteKey");
+
+ TcpDiscoveryS3IpFinder ipFinder = new TcpDiscoveryS3IpFinder();
+ ipFinder.setAwsCredentials(creds);
+ ipFinder.setBucketName("yourBucketName");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start a node.
+ Ignition.start(cfg);
+ //end::aws1[]
+ }
+
+ public static void awsExample2() {
+ //tag::aws2[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ AWSCredentialsProvider instanceProfileCreds = new InstanceProfileCredentialsProvider(false);
+
+ TcpDiscoveryS3IpFinder ipFinder = new TcpDiscoveryS3IpFinder();
+ ipFinder.setAwsCredentialsProvider(instanceProfileCreds);
+ ipFinder.setBucketName("yourBucketName");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start a node.
+ Ignition.start(cfg);
+ //end::aws2[]
+ }
+
+ public static void awsElbExample() {
+ //tag::awsElb[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ BasicAWSCredentials creds = new BasicAWSCredentials("yourAccessKey", "yourSecreteKey");
+
+ TcpDiscoveryElbIpFinder ipFinder = new TcpDiscoveryElbIpFinder();
+ ipFinder.setRegion("yourElbRegion");
+ ipFinder.setLoadBalancerName("yourLoadBalancerName");
+ ipFinder.setCredentialsProvider(new AWSStaticCredentialsProvider(creds));
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignition.start(cfg);
+ //end::awsElb[]
+ }
+
+ public static void googleCloudStorageExample() {
+ //tag::google[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryGoogleStorageIpFinder ipFinder = new TcpDiscoveryGoogleStorageIpFinder();
+
+ ipFinder.setServiceAccountId("yourServiceAccountId");
+ ipFinder.setServiceAccountP12FilePath("pathToYourP12Key");
+ ipFinder.setProjectName("yourGoogleClourPlatformProjectName");
+
+ // Bucket name must be unique across the whole Google Cloud Platform.
+ ipFinder.setBucketName("your_bucket_name");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignition.start(cfg);
+ //end::google[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DistributedComputing.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DistributedComputing.java
new file mode 100644
index 0000000..f9ca6a7
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/DistributedComputing.java
@@ -0,0 +1,181 @@
+package org.apache.ignite.snippets;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+public class DistributedComputing {
+
+ void getCompute() {
+ // tag::get-compute[]
+ Ignite ignite = Ignition.start();
+
+ IgniteCompute compute = ignite.compute();
+ // end::get-compute[]
+ }
+
+ void getComputeForNodes() {
+
+ // tag::get-compute-for-nodes[]
+ Ignite ignite = Ignition.start();
+
+ IgniteCompute compute = ignite.compute(ignite.cluster().forRemotes());
+
+ // end::get-compute-for-nodes[]
+ }
+
+ void taskTimeout() {
+ Ignite ignite = Ignition.start();
+
+ // tag::timeout[]
+ IgniteCompute compute = ignite.compute();
+
+ compute.withTimeout(300_000).run(() -> {
+ // your computation
+ // ...
+ });
+ // end::timeout[]
+ }
+
+ void executeRunnable(Ignite ignite) {
+ // tag::execute-runnable[]
+ IgniteCompute compute = ignite.compute();
+
+ // Iterate through all words and print
+ // each word on a different cluster node.
+ for (String word : "Print words on different cluster nodes".split(" ")) {
+ compute.run(() -> System.out.println(word));
+ }
+ // end::execute-runnable[]
+ }
+
+ void executeCallable(Ignite ignite) {
+ // tag::execute-callable[]
+ Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
+
+ // Iterate through all words in the sentence and create callable jobs.
+ for (String word : "How many characters".split(" "))
+ calls.add(word::length);
+
+ // Execute the collection of callables on the cluster.
+ Collection<Integer> res = ignite.compute().call(calls);
+
+ // Add all the word lengths received from cluster nodes.
+ int total = res.stream().mapToInt(Integer::intValue).sum();
+ // end::execute-callable[]
+ }
+
+ void executeIgniteClosure(Ignite ignite) {
+ // tag::execute-closure[]
+ IgniteCompute compute = ignite.compute();
+
+ // Execute closure on all cluster nodes.
+ Collection<Integer> res = compute.apply(String::length, Arrays.asList("How many characters".split(" ")));
+
+ // Add all the word lengths received from cluster nodes.
+ int total = res.stream().mapToInt(Integer::intValue).sum();
+ // end::execute-closure[]
+ }
+
+ void broadcast(Ignite ignite) {
+
+ // tag::broadcast[]
+ // Limit broadcast to remote nodes only.
+ IgniteCompute compute = ignite.compute(ignite.cluster().forRemotes());
+
+ // Print out hello message on remote nodes in the cluster group.
+ compute.broadcast(() -> System.out.println("Hello Node: " + ignite.cluster().localNode().id()));
+ // end::broadcast[]
+ }
+
+ void async(Ignite ignite) {
+
+ // tag::async[]
+
+ IgniteCompute compute = ignite.compute();
+
+ Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
+
+ // Iterate through all words in the sentence and create callable jobs.
+ for (String word : "Count characters using a callable".split(" "))
+ calls.add(word::length);
+
+ IgniteFuture<Collection<Integer>> future = compute.callAsync(calls);
+
+ future.listen(fut -> {
+ // Total number of characters.
+ int total = fut.get().stream().mapToInt(Integer::intValue).sum();
+
+ System.out.println("Total number of characters: " + total);
+ });
+
+ // end::async[]
+ }
+
+ void shareState(Ignite ignite) {
+ // tag::get-map[]
+ IgniteCluster cluster = ignite.cluster();
+
+ ConcurrentMap<String, Integer> nodeLocalMap = cluster.nodeLocalMap();
+ // end::get-map[]
+
+ // tag::job-counter[]
+ IgniteCallable<Long> job = new IgniteCallable<Long>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override
+ public Long call() {
+ // Get a reference to node local.
+ ConcurrentMap<String, AtomicLong> nodeLocalMap = ignite.cluster().nodeLocalMap();
+
+ AtomicLong cntr = nodeLocalMap.get("counter");
+
+ if (cntr == null) {
+ AtomicLong old = nodeLocalMap.putIfAbsent("counter", cntr = new AtomicLong());
+
+ if (old != null)
+ cntr = old;
+ }
+
+ return cntr.incrementAndGet();
+ }
+ };
+
+ // end::job-counter[]
+ }
+
+ // tag::access-data[]
+ public class MyCallableTask implements IgniteCallable<Integer> {
+
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override
+ public Integer call() throws Exception {
+
+ IgniteCache<Long, Person> cache = ignite.cache("person");
+
+ // Get the data you need
+ Person person = cache.get(1L);
+
+ // do with the data what you need to do
+
+ return 1;
+ }
+ }
+
+ // end::access-data[]
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Events.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Events.java
new file mode 100644
index 0000000..f28b1f4
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Events.java
@@ -0,0 +1,172 @@
+package org.apache.ignite.snippets;
+
+import java.util.Collection;
+import java.util.UUID;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.events.JobEvent;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
+
+public class Events {
+
+ public static void main(String[] args) {
+
+ }
+
+ void enablingEvents() {
+ // tag::enabling-events[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Enable cache events.
+ cfg.setIncludeEventTypes(EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ,
+ EventType.EVT_CACHE_OBJECT_REMOVED, EventType.EVT_NODE_JOINED, EventType.EVT_NODE_LEFT);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ // end::enabling-events[]
+
+ // tag::get-events[]
+ IgniteEvents events = ignite.events();
+ // end::get-events[]
+ }
+
+ void getEventsForNodes() {
+ // tag::get-events-for-cache[]
+ Ignite ignite = Ignition.ignite();
+
+ IgniteEvents events = ignite.events(ignite.cluster().forCacheNodes("person"));
+ // end::get-events-for-cache[]
+ }
+
+ void getNodeFromEvent(Ignite ignite) {
+ // tag::get-node[]
+ IgniteEvents events = ignite.events();
+
+ UUID uuid = events.remoteListen(new IgniteBiPredicate<UUID, JobEvent>() {
+ @Override
+ public boolean apply(UUID uuid, JobEvent e) {
+
+ System.out.println("nodeID = " + e.node().id() + ", addresses=" + e.node().addresses());
+
+ return true; //continue listening
+ }
+ }, null, EventType.EVT_JOB_FINISHED);
+
+ // end::get-node[]
+ }
+
+ void localEvents(Ignite ignite) {
+ // tag::local[]
+ IgniteEvents events = ignite.events();
+
+ // Local listener that listens to local events.
+ IgnitePredicate<CacheEvent> localListener = evt -> {
+ System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() + ", oldVal=" + evt.oldValue()
+ + ", newVal=" + evt.newValue());
+
+ return true; // Continue listening.
+ };
+
+ // Subscribe to specified cache events occurring on the local node.
+ events.localListen(localListener, EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ,
+ EventType.EVT_CACHE_OBJECT_REMOVED);
+ // end::local[]
+ }
+
+ void remoteEvents(Ignite ignite) {
+ // tag::remote[]
+ IgniteEvents events = ignite.events();
+
+ IgnitePredicate<CacheEvent> filter = evt -> {
+ System.out.println("remote event: " + evt.name());
+ return true;
+ };
+
+ // Subscribe to specified cache events on all nodes that have cache running.
+ UUID uuid = events.remoteListen(new IgniteBiPredicate<UUID, CacheEvent>() {
+
+ @Override
+ public boolean apply(UUID uuid, CacheEvent e) {
+
+ // process the event
+
+ return true; //continue listening
+ }
+ }, filter, EventType.EVT_CACHE_OBJECT_PUT);
+ // end::remote[]
+ }
+
+ void batching() {
+ // tag::batching[]
+ Ignite ignite = Ignition.ignite();
+
+ // Get an instance of named cache.
+ final IgniteCache<Integer, String> cache = ignite.cache("cacheName");
+
+ // Sample remote filter which only accepts events for keys
+ // that are greater than or equal to 10.
+ IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() {
+ @Override
+ public boolean apply(CacheEvent evt) {
+ System.out.println("Cache event: " + evt);
+
+ int key = evt.key();
+
+ return key >= 10;
+ }
+ };
+
+ // Subscribe to cache events occurring on all nodes
+ // that have the specified cache running.
+ // Send notifications in batches of 10.
+ ignite.events(ignite.cluster().forCacheNodes("cacheName")).remoteListen(10 /* batch size */,
+ 0 /* time intervals */, false, null, rmtLsnr, EventType.EVTS_CACHE);
+
+ // Generate cache events.
+ for (int i = 0; i < 20; i++)
+ cache.put(i, Integer.toString(i));
+
+ // end::batching[]
+ }
+
+ void storeEvents() {
+ // tag::event-storage[]
+ MemoryEventStorageSpi eventStorageSpi = new MemoryEventStorageSpi();
+ eventStorageSpi.setExpireAgeMs(600000);
+
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+ igniteCfg.setEventStorageSpi(eventStorageSpi);
+
+ Ignite ignite = Ignition.start(igniteCfg);
+ // end::event-storage[]
+
+ IgniteEvents events = ignite.events();
+
+ // tag::query-local-events[]
+ Collection<CacheEvent> cacheEvents = events.localQuery(e -> {
+ // process the event
+ return true;
+ }, EventType.EVT_CACHE_OBJECT_PUT);
+
+ // end::query-local-events[]
+
+ // tag::query-remote-events[]
+ Collection<CacheEvent> storedEvents = events.remoteQuery(e -> {
+ // process the event
+ return true;
+ }, 0, EventType.EVT_CACHE_OBJECT_PUT);
+
+ // end::query-remote-events[]
+
+ ignite.close();
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/EvictionPolicies.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/EvictionPolicies.java
new file mode 100644
index 0000000..87e2305
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/EvictionPolicies.java
@@ -0,0 +1,148 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
+import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
+import org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataPageEvictionMode;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class EvictionPolicies {
+
+ public static void runAll() {
+ randomLRU();
+ random2LRU();
+ LRU();
+ FIFO();
+ sorted();
+ }
+
+ public static void randomLRU() {
+ //tag::randomLRU[]
+ // Node configuration.
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Memory configuration.
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+
+ // Creating a new data region.
+ DataRegionConfiguration regionCfg = new DataRegionConfiguration();
+
+ // Region name.
+ regionCfg.setName("20GB_Region");
+
+ // 500 MB initial size (RAM).
+ regionCfg.setInitialSize(500L * 1024 * 1024);
+
+ // 20 GB max size (RAM).
+ regionCfg.setMaxSize(20L * 1024 * 1024 * 1024);
+
+ // Enabling RANDOM_LRU eviction for this region.
+ regionCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU);
+
+ // Setting the data region configuration.
+ storageCfg.setDataRegionConfigurations(regionCfg);
+
+ // Applying the new configuration.
+ cfg.setDataStorageConfiguration(storageCfg);
+ //end::randomLRU[]
+
+ try (Ignite ignite = Ignition.start(new IgniteConfiguration().setDataStorageConfiguration(storageCfg))) {
+
+ }
+ }
+
+ public static void random2LRU() {
+ //tag::random2LRU[]
+ // Ignite configuration.
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Memory configuration.
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+
+ // Creating a new data region.
+ DataRegionConfiguration regionCfg = new DataRegionConfiguration();
+
+ // Region name.
+ regionCfg.setName("20GB_Region");
+
+ // 500 MB initial size (RAM).
+ regionCfg.setInitialSize(500L * 1024 * 1024);
+
+ // 20 GB max size (RAM).
+ regionCfg.setMaxSize(20L * 1024 * 1024 * 1024);
+
+ // Enabling RANDOM_2_LRU eviction for this region.
+ regionCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_2_LRU);
+
+ // Setting the data region configuration.
+ storageCfg.setDataRegionConfigurations(regionCfg);
+
+ // Applying the new configuration.
+ cfg.setDataStorageConfiguration(storageCfg);
+ //end::random2LRU[]
+
+ }
+
+ public static void LRU() {
+ //tag::LRU[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+
+ // Enabling on-heap caching for this distributed cache.
+ cacheCfg.setOnheapCacheEnabled(true);
+
+ // Set the maximum cache size to 1 million (default is 100,000).
+ cacheCfg.setEvictionPolicyFactory(() -> new LruEvictionPolicy(1000000));
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+ //end::LRU[]
+
+ }
+
+ public static void FIFO() {
+ //tag::FIFO[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+
+ // Enabling on-heap caching for this distributed cache.
+ cacheCfg.setOnheapCacheEnabled(true);
+
+ // Set the maximum cache size to 1 million (default is 100,000).
+ cacheCfg.setEvictionPolicyFactory(() -> new FifoEvictionPolicy(1000000));
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+ //end::FIFO[]
+
+
+ }
+
+ public static void sorted() {
+ //tag::sorted[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+
+ // Enabling on-heap caching for this distributed cache.
+ cacheCfg.setOnheapCacheEnabled(true);
+
+ // Set the maximum cache size to 1 million (default is 100,000).
+ cacheCfg.setEvictionPolicyFactory(() -> new SortedEvictionPolicy(1000000));
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+ //end::sorted[]
+
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExpiryPolicies.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExpiryPolicies.java
new file mode 100644
index 0000000..4d1dc60
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExpiryPolicies.java
@@ -0,0 +1,52 @@
+package org.apache.ignite.snippets;
+
+import java.util.concurrent.TimeUnit;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.junit.jupiter.api.Test;
+
+public class ExpiryPolicies {
+
+ @Test
+ void expiryPoliciesExample() {
+ //tag::cfg[]
+ //tag::eagerTtl[]
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<Integer, String>();
+ cfg.setName("myCache");
+ //end::cfg[]
+
+ cfg.setEagerTtl(true);
+ //end::eagerTtl[]
+ //tag::cfg[]
+ cfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES));
+ //end::cfg[]
+
+ }
+
+ @Test
+ void expiryPolicyForIndividualEntry() {
+
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+ try (Ignite ignite = Ignition.start(igniteCfg)) {
+
+ //tag::expiry2[]
+
+ CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<Integer, String>("myCache");
+
+ ignite.createCache(cacheCfg);
+
+ IgniteCache cache = ignite.cache("myCache")
+ .withExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.MINUTES, 5)));
+
+ // if the cache does not contain key 1, the entry will expire after 5 minutes
+ cache.put(1, "first value");
+
+ //end::expiry2[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExternalStorage.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExternalStorage.java
new file mode 100644
index 0000000..905acb1
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ExternalStorage.java
@@ -0,0 +1,153 @@
+package org.apache.ignite.snippets;
+
+import com.mysql.cj.jdbc.MysqlDataSource;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import javax.cache.configuration.Factory;
+import javax.sql.DataSource;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory;
+import org.apache.ignite.cache.store.jdbc.JdbcType;
+import org.apache.ignite.cache.store.jdbc.JdbcTypeField;
+import org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class ExternalStorage {
+
+ public static void cacheJdbcPojoStoreExample() {
+ //tag::pojo[]
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+
+ CacheConfiguration<Integer, Person> personCacheCfg = new CacheConfiguration<>();
+
+ personCacheCfg.setName("PersonCache");
+ personCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ personCacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+ personCacheCfg.setReadThrough(true);
+ personCacheCfg.setWriteThrough(true);
+
+ CacheJdbcPojoStoreFactory<Integer, Person> factory = new CacheJdbcPojoStoreFactory<>();
+ factory.setDialect(new MySQLDialect());
+ factory.setDataSourceFactory((Factory<DataSource>)() -> {
+ MysqlDataSource mysqlDataSrc = new MysqlDataSource();
+ mysqlDataSrc.setURL("jdbc:mysql://[host]:[port]/[database]");
+ mysqlDataSrc.setUser("YOUR_USER_NAME");
+ mysqlDataSrc.setPassword("YOUR_PASSWORD");
+ return mysqlDataSrc;
+ });
+
+ JdbcType personType = new JdbcType();
+ personType.setCacheName("PersonCache");
+ personType.setKeyType(Integer.class);
+ personType.setValueType(Person.class);
+ // Specify the schema if applicable
+ // personType.setDatabaseSchema("MY_DB_SCHEMA");
+ personType.setDatabaseTable("PERSON");
+
+ personType.setKeyFields(new JdbcTypeField(java.sql.Types.INTEGER, "id", Integer.class, "id"));
+
+ personType.setValueFields(new JdbcTypeField(java.sql.Types.INTEGER, "id", Integer.class, "id"));
+ personType.setValueFields(new JdbcTypeField(java.sql.Types.VARCHAR, "name", String.class, "name"));
+
+ factory.setTypes(personType);
+
+ personCacheCfg.setCacheStoreFactory(factory);
+
+ QueryEntity qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType(Integer.class.getName());
+ qryEntity.setValueType(Person.class.getName());
+ qryEntity.setKeyFieldName("id");
+
+ Set<String> keyFields = new HashSet<>();
+ keyFields.add("id");
+ qryEntity.setKeyFields(keyFields);
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+ fields.put("id", "java.lang.Integer");
+ fields.put("name", "java.lang.String");
+
+ qryEntity.setFields(fields);
+
+ personCacheCfg.setQueryEntities(Collections.singletonList(qryEntity));
+
+ igniteCfg.setCacheConfiguration(personCacheCfg);
+ //end::pojo[]
+ }
+
+ //tag::person[]
+ class Person implements Serializable {
+ private static final long serialVersionUID = 0L;
+
+ private int id;
+
+ private String name;
+
+ public Person() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+ //end::person[]
+
+ public static void cacheJdbcBlobStoreExample() {
+ //tag::blob1[]
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+
+ CacheConfiguration<Integer, Person> personCacheCfg = new CacheConfiguration<>();
+ personCacheCfg.setName("PersonCache");
+
+ CacheJdbcBlobStoreFactory<Integer, Person> cacheStoreFactory = new CacheJdbcBlobStoreFactory<>();
+
+ cacheStoreFactory.setUser("USER_NAME");
+
+ MysqlDataSource mysqlDataSrc = new MysqlDataSource();
+ mysqlDataSrc.setURL("jdbc:mysql://[host]:[port]/[database]");
+ mysqlDataSrc.setUser("USER_NAME");
+ mysqlDataSrc.setPassword("PASSWORD");
+
+ cacheStoreFactory.setDataSource(mysqlDataSrc);
+
+ personCacheCfg.setCacheStoreFactory(cacheStoreFactory);
+
+ personCacheCfg.setWriteThrough(true);
+ personCacheCfg.setReadThrough(true);
+
+ igniteCfg.setCacheConfiguration(personCacheCfg);
+ //end::blob1[]
+
+ Ignite ignite = Ignition.start(igniteCfg);
+
+ //tag::blob2[]
+ // Load data from person table into PersonCache.
+ IgniteCache<Integer, Person> personCache = ignite.cache("PersonCache");
+
+ personCache.loadCache(null);
+ //end::blob2[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/FaultTolerance.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/FaultTolerance.java
new file mode 100644
index 0000000..c77e0b8
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/FaultTolerance.java
@@ -0,0 +1,49 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi;
+import org.apache.ignite.spi.failover.never.NeverFailoverSpi;
+
+public class FaultTolerance {
+ void always() {
+ // tag::always[]
+ AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
+
+ // Override maximum failover attempts.
+ failSpi.setMaximumFailoverAttempts(5);
+
+ // Override the default failover SPI.
+ IgniteConfiguration cfg = new IgniteConfiguration().setFailoverSpi(failSpi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ // end::always[]
+
+ ignite.close();
+ }
+
+ void never() {
+ // tag::never[]
+ NeverFailoverSpi failSpi = new NeverFailoverSpi();
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override the default failover SPI.
+ cfg.setFailoverSpi(failSpi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ // end::never[]
+
+ ignite.close();
+ }
+
+ public static void main(String[] args) {
+ FaultTolerance ft = new FaultTolerance();
+
+ ft.always();
+ ft.never();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteExecutorService.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteExecutorService.java
new file mode 100644
index 0000000..7f43576
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteExecutorService.java
@@ -0,0 +1,40 @@
+package org.apache.ignite.snippets;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+public class IgniteExecutorService {
+
+ void test(Ignite ignite) {
+
+ // tag::execute[]
+ // Get cluster-enabled executor service.
+ ExecutorService exec = ignite.executorService();
+
+ // Iterate through all words in the sentence and create jobs.
+ for (final String word : "Print words using runnable".split(" ")) {
+ // Execute runnable on some node.
+ exec.submit(new IgniteRunnable() {
+ @Override
+ public void run() {
+ System.out.println(">>> Printing '" + word + "' on this node from grid job.");
+ }
+ });
+ }
+ // end::execute[]
+ }
+
+ void clusterGroup(Ignite ignite) {
+ // tag::cluster-group[]
+ // A group for nodes where the attribute 'worker' is defined.
+ ClusterGroup workerGrp = ignite.cluster().forAttribute("ROLE", "worker");
+
+ // Get an executor service for the cluster group.
+ ExecutorService exec = ignite.executorService(workerGrp);
+ // end::cluster-group[]
+
+ }
+}
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
new file mode 100644
index 0000000..475203e
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgniteLifecycle.java
@@ -0,0 +1,50 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.junit.jupiter.api.Test;
+
+public class IgniteLifecycle {
+
+ void test() {
+ }
+
+ @Test
+ void startNode() {
+ //tag::start[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ Ignite ignite = Ignition.start(cfg);
+ //end::start[]
+ }
+
+ @Test
+ void startAndClose() {
+
+ //tag::autoclose[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ try (Ignite ignite = Ignition.start(cfg)) {
+ //
+ }
+
+ //end::autoclose[]
+ }
+
+ @Test
+ void startClientNode() {
+ //tag::client-node[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Enable client mode.
+ cfg.setClientMode(true);
+
+ // Start a client
+ Ignite ignite = Ignition.start(cfg);
+ //end::client-node[]
+
+ ignite.close();
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgnitePersistence.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgnitePersistence.java
new file mode 100644
index 0000000..51a95cad
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/IgnitePersistence.java
@@ -0,0 +1,80 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class IgnitePersistence {
+
+ public static void disablingWal() {
+
+ //tag::wal[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+ storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
+
+ cfg.setDataStorageConfiguration(storageCfg);
+
+ Ignite ignite = Ignition.start(cfg);
+
+ ignite.cluster().active(true);
+
+ String cacheName = "myCache";
+
+ ignite.getOrCreateCache(cacheName);
+
+ ignite.cluster().disableWal(cacheName);
+
+ //load data
+ ignite.cluster().enableWal(cacheName);
+
+ //end::wal[]
+ ignite.close();
+ }
+
+ public static void changeWalSegmentSize() {
+ // tag::segment-size[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+ storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
+
+ storageCfg.setWalSegmentSize(128 * 1024 * 1024);
+
+ cfg.setDataStorageConfiguration(storageCfg);
+
+ Ignite ignite = Ignition.start(cfg);
+ // end::segment-size[]
+
+ ignite.close();
+ }
+
+ public static void cfgExample() {
+ //tag::cfg[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ //data storage configuration
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+
+ storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
+
+ //tag::storage-path[]
+ storageCfg.setStoragePath("/opt/storage");
+ //end::storage-path[]
+
+ cfg.setDataStorageConfiguration(storageCfg);
+
+ Ignite ignite = Ignition.start(cfg);
+ //end::cfg[]
+ ignite.close();
+ }
+
+ public static void main(String[] args) {
+ IgnitePersistence ip = new IgnitePersistence();
+
+ ip.disablingWal();
+ ip.changeWalSegmentSize();
+ ip.cfgExample();
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/JobScheduling.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/JobScheduling.java
new file mode 100644
index 0000000..1d782e5
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/JobScheduling.java
@@ -0,0 +1,106 @@
+package org.apache.ignite.snippets;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskSession;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.resources.TaskSessionResource;
+import org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi;
+import org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi;
+
+public class JobScheduling {
+
+ void fifo() {
+ // tag::fifo[]
+ FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi();
+
+ // Execute jobs sequentially, one at a time,
+ // by setting parallel job number to 1.
+ colSpi.setParallelJobsNumber(1);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default collision SPI.
+ cfg.setCollisionSpi(colSpi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+
+ // end::fifo[]
+ ignite.close();
+ }
+
+ void priority() {
+ // tag::priority[]
+ PriorityQueueCollisionSpi colSpi = new PriorityQueueCollisionSpi();
+
+ // Change the parallel job number if needed.
+ // Default is number of cores times 2.
+ colSpi.setParallelJobsNumber(5);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default collision SPI.
+ cfg.setCollisionSpi(colSpi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+
+ // end::priority[]
+ ignite.close();
+ }
+
+ //tag::task-priority[]
+ public class MyUrgentTask extends ComputeTaskSplitAdapter<Object, Object> {
+ // Auto-injected task session.
+ @TaskSessionResource
+ private ComputeTaskSession taskSes = null;
+
+ @Override
+ protected Collection<ComputeJob> split(int gridSize, Object arg) {
+ // Set high task priority.
+ taskSes.setAttribute("grid.task.priority", 10);
+
+ List<ComputeJob> jobs = new ArrayList<>(gridSize);
+
+ for (int i = 1; i <= gridSize; i++) {
+ jobs.add(new ComputeJobAdapter() {
+
+ @Override
+ public Object execute() throws IgniteException {
+
+ //your implementation goes here
+
+ return null;
+ }
+ });
+ }
+
+ // These jobs will be executed with higher priority.
+ return jobs;
+ }
+
+ @Override
+ public Object reduce(List<ComputeJobResult> results) throws IgniteException {
+ return null;
+ }
+ }
+
+ //end::task-priority[]
+
+
+ public static void main(String[] args) {
+ JobScheduling js = new JobScheduling();
+ js.fifo();
+ js.priority();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/LoadBalancing.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/LoadBalancing.java
new file mode 100644
index 0000000..fbb9d58
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/LoadBalancing.java
@@ -0,0 +1,103 @@
+package org.apache.ignite.snippets;
+
+import java.util.Collections;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi;
+import org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi;
+import org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi;
+import org.apache.ignite.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi;
+
+public class LoadBalancing {
+
+ void roundRobin() {
+ // tag::load-balancing[]
+ RoundRobinLoadBalancingSpi spi = new RoundRobinLoadBalancingSpi();
+ spi.setPerTask(true);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ // these events are required for the per-task mode
+ cfg.setIncludeEventTypes(EventType.EVT_TASK_FINISHED, EventType.EVT_TASK_FAILED, EventType.EVT_JOB_MAPPED);
+
+ // Override default load balancing SPI.
+ cfg.setLoadBalancingSpi(spi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ // end::load-balancing[]
+
+ ignite.close();
+ }
+
+ void weighted() {
+
+ // tag::weighted[]
+ WeightedRandomLoadBalancingSpi spi = new WeightedRandomLoadBalancingSpi();
+
+ // Configure SPI to use the weighted random load balancing algorithm.
+ spi.setUseWeights(true);
+
+ // Set weight for the local node.
+ spi.setNodeWeight(10);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default load balancing SPI.
+ cfg.setLoadBalancingSpi(spi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ // end::weighted[]
+
+ ignite.close();
+ }
+
+ void jobStealing() {
+ //tag::job-stealing[]
+ JobStealingCollisionSpi spi = new JobStealingCollisionSpi();
+
+ // Configure number of waiting jobs
+ // in the queue for job stealing.
+ spi.setWaitJobsThreshold(10);
+
+ // Configure message expire time (in milliseconds).
+ spi.setMessageExpireTime(1000);
+
+ // Configure stealing attempts number.
+ spi.setMaximumStealingAttempts(10);
+
+ // Configure number of active jobs that are allowed to execute
+ // in parallel. This number should usually be equal to the number
+ // of threads in the pool (default is 100).
+ spi.setActiveJobsThreshold(50);
+
+ // Enable stealing.
+ spi.setStealingEnabled(true);
+
+ // Set stealing attribute to steal from/to nodes that have it.
+ spi.setStealingAttributes(Collections.singletonMap("node.segment", "foobar"));
+
+ // Enable `JobStealingFailoverSpi`
+ JobStealingFailoverSpi failoverSpi = new JobStealingFailoverSpi();
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default Collision SPI.
+ cfg.setCollisionSpi(spi);
+
+ cfg.setFailoverSpi(failoverSpi);
+ //end::job-stealing[]
+ Ignition.start(cfg).close();
+ }
+
+ public static void main(String[] args) {
+ LoadBalancing lb = new LoadBalancing();
+
+ lb.roundRobin();
+ lb.weighted();
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Logging.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Logging.java
new file mode 100644
index 0000000..bfd816a
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Logging.java
@@ -0,0 +1,78 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.logger.jcl.JclLogger;
+import org.apache.ignite.logger.log4j.Log4JLogger;
+import org.apache.ignite.logger.log4j2.Log4J2Logger;
+import org.apache.ignite.logger.slf4j.Slf4jLogger;
+
+public class Logging {
+
+ void log4j() throws IgniteCheckedException {
+
+ // tag::log4j[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ IgniteLogger log = new Log4JLogger("log4j-config.xml");
+
+ cfg.setGridLogger(log);
+
+ // Start a node.
+ try (Ignite ignite = Ignition.start(cfg)) {
+ ignite.log().info("Info Message Logged!");
+ }
+ // end::log4j[]
+ }
+
+ void log4j2() throws IgniteCheckedException {
+ // tag::log4j2[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ IgniteLogger log = new Log4J2Logger("log4j2-config.xml");
+
+ cfg.setGridLogger(log);
+
+ // Start a node.
+ try (Ignite ignite = Ignition.start(cfg)) {
+ ignite.log().info("Info Message Logged!");
+ }
+ // end::log4j2[]
+ }
+
+ void jcl() {
+ //tag::jcl[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setGridLogger(new JclLogger());
+
+ // Start a node.
+ try (Ignite ignite = Ignition.start(cfg)) {
+ ignite.log().info("Info Message Logged!");
+ }
+ //end::jcl[]
+ }
+
+ void slf4j() {
+ //tag::slf4j[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setGridLogger(new Slf4jLogger());
+
+ // Start a node.
+ try (Ignite ignite = Ignition.start(cfg)) {
+ ignite.log().info("Info Message Logged!");
+ }
+ //end::slf4j[]
+ }
+
+ public static void main(String[] args) throws IgniteCheckedException {
+ Logging logging = new Logging();
+
+ logging.jcl();
+ logging.slf4j();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MapReduce.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MapReduce.java
new file mode 100644
index 0000000..7ee1e1f
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MapReduce.java
@@ -0,0 +1,154 @@
+package org.apache.ignite.snippets;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobContext;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeJobResultPolicy;
+import org.apache.ignite.compute.ComputeJobSibling;
+import org.apache.ignite.compute.ComputeTask;
+import org.apache.ignite.compute.ComputeTaskSession;
+import org.apache.ignite.compute.ComputeTaskSessionFullSupport;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.resources.JobContextResource;
+import org.apache.ignite.resources.TaskSessionResource;
+
+public class MapReduce {
+
+ private static class CharacterCountTask extends ComputeTaskSplitAdapter<String, Integer> {
+ // 1. Splits the received string into words
+ // 2. Creates a child job for each word
+ // 3. Sends the jobs to other nodes for processing.
+ @Override
+ public List<ComputeJob> split(int gridSize, String arg) {
+ String[] words = arg.split(" ");
+
+ List<ComputeJob> jobs = new ArrayList<>(words.length);
+
+ for (final String word : words) {
+ jobs.add(new ComputeJobAdapter() {
+ @Override
+ public Object execute() {
+ System.out.println(">>> This compute job calculates the length of the word '" + word + "'.");
+
+ // Return the number of letters in the word.
+ return word.length();
+ }
+ });
+ }
+
+ return jobs;
+ }
+
+ @Override
+ public Integer reduce(List<ComputeJobResult> results) {
+ int sum = 0;
+
+ for (ComputeJobResult res : results)
+ sum += res.<Integer>getData();
+
+ return sum;
+ }
+ }
+
+ void executeComputeTask() {
+
+ // tag::execute-compute-task[]
+ Ignite ignite = Ignition.start();
+
+ IgniteCompute compute = ignite.compute();
+
+ int count = compute.execute(new CharacterCountTask(), "Hello Grid Enabled World!");
+
+ // end::execute-compute-task[]
+ }
+
+ // tag::session[]
+ @ComputeTaskSessionFullSupport
+ private static class TaskSessionAttributesTask extends ComputeTaskSplitAdapter<Object, Object> {
+
+ @Override
+ protected Collection<? extends ComputeJob> split(int gridSize, Object arg) {
+ Collection<ComputeJob> jobs = new LinkedList<>();
+
+ // Generate jobs by number of nodes in the grid.
+ for (int i = 0; i < gridSize; i++) {
+ jobs.add(new ComputeJobAdapter(arg) {
+ // Auto-injected task session.
+ @TaskSessionResource
+ private ComputeTaskSession ses;
+
+ // Auto-injected job context.
+ @JobContextResource
+ private ComputeJobContext jobCtx;
+
+ @Override
+ public Object execute() {
+ // Perform STEP1.
+ // ...
+
+ // Tell other jobs that STEP1 is complete.
+ ses.setAttribute(jobCtx.getJobId(), "STEP1");
+
+ // Wait for other jobs to complete STEP1.
+ for (ComputeJobSibling sibling : ses.getJobSiblings())
+ try {
+ ses.waitForAttribute(sibling.getJobId(), "STEP1", 0);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ // Move on to STEP2.
+ // ...
+
+ // tag::exclude[]
+ /*
+ // end::exclude[]
+ return ...
+
+ // tag::exclude[]
+ */
+ return new Object();
+ // end::exclude[]
+ }
+ });
+ }
+ return jobs;
+ }
+
+ @Override
+ public Object reduce(List<ComputeJobResult> results) {
+ // No-op.
+ return null;
+ }
+
+ //tag::exclude[]
+ //tag::failover[]
+ @Override
+ public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) {
+ IgniteException err = res.getException();
+
+ if (err != null)
+ return ComputeJobResultPolicy.FAILOVER;
+
+ // If there is no exception, wait for all job results.
+ return ComputeJobResultPolicy.WAIT;
+ }
+ //end::failover[]
+ //end::exclude[]
+ }
+
+ // end::session[]
+
+
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyNodeFilter.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyNodeFilter.java
new file mode 100644
index 0000000..ec4350e
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/MyNodeFilter.java
@@ -0,0 +1,24 @@
+package org.apache.ignite.snippets;
+
+import java.util.Collection;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgnitePredicate;
+
+//tag::node-filter-example[]
+public class MyNodeFilter implements IgnitePredicate<ClusterNode> {
+
+ // fill the collection with consistent IDs of the nodes you want to exclude
+ private Collection<String> nodesToExclude;
+
+ public MyNodeFilter(Collection<String> nodesToExclude) {
+ this.nodesToExclude = nodesToExclude;
+ }
+
+ @Override
+ public boolean apply(ClusterNode node) {
+ return nodesToExclude == null || !nodesToExclude.contains(node.consistentId());
+ }
+}
+
+//end::node-filter-example[]
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NearCache.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NearCache.java
new file mode 100644
index 0000000..41f5d61
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NearCache.java
@@ -0,0 +1,53 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.eviction.lru.LruEvictionPolicyFactory;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+
+public class NearCache {
+
+ public static void main(String[] args) {
+ Ignite ignite = Ignition.start();
+
+ // tag::nearCacheConfiguration[]
+ // Create a near-cache configuration for "myCache".
+ NearCacheConfiguration<Integer, Integer> nearCfg = new NearCacheConfiguration<>();
+
+ // Use LRU eviction policy to automatically evict entries
+ // from near-cache whenever it reaches 100_000 entries
+ nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100_000));
+
+ CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<Integer, Integer>("myCache");
+
+ cacheCfg.setNearConfiguration(nearCfg);
+
+ // Create a distributed cache on server nodes
+ IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cacheCfg);
+ // end::nearCacheConfiguration[]
+
+ }
+
+ public void createDynamically() {
+
+ Ignition.setClientMode(true);
+
+ Ignite ignite = Ignition.start();
+
+ // tag::createNearCacheDynamically[]
+ // Create a near-cache configuration
+ NearCacheConfiguration<Integer, String> nearCfg = new NearCacheConfiguration<>();
+
+ // Use LRU eviction policy to automatically evict entries
+ // from near-cache, whenever it reaches 100_000 in size.
+ nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100_000));
+
+ // get the cache named "myCache" and create a near cache for it
+ IgniteCache<Integer, String> cache = ignite.getOrCreateNearCache("myCache", nearCfg);
+
+ String value = cache.get(1);
+ // end::createNearCacheDynamically[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NodeFilter.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NodeFilter.java
new file mode 100644
index 0000000..2a4f256
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/NodeFilter.java
@@ -0,0 +1,59 @@
+package org.apache.ignite.snippets;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.util.AttributeNodeFilter;
+import org.junit.jupiter.api.Test;
+
+public class NodeFilter {
+
+ @Test
+ void setNodeFilter() {
+
+ //tag::cache-node-filter[]
+ Ignite ignite = Ignition.start();
+
+ CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<>("myCache");
+
+ Collection<String> consistenIdSet = new HashSet<>();
+ consistenIdSet.add("consistentId1");
+
+ //the cache will not be hosted on the provided nodes
+ cacheCfg.setNodeFilter(new MyNodeFilter(consistenIdSet));
+
+ ignite.createCache(cacheCfg);
+ //end::cache-node-filter[]
+
+ ignite.close();
+ }
+
+ @Test
+ void attributeNodeFilter() {
+ //tag::add-attribute[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put("host_myCache", true);
+ cfg.setUserAttributes(attributes);
+
+ Ignite ignite = Ignition.start(cfg);
+
+ //end::add-attribute[]
+
+ //tag::attribute-node-filter[]
+ CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<>("myCache");
+
+ cacheCfg.setNodeFilter(new AttributeNodeFilter("host_myCache", "true"));
+ //end::attribute-node-filter[]
+
+ ignite.createCache(cacheCfg);
+
+ ignite.close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/OnHeapCaching.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/OnHeapCaching.java
new file mode 100644
index 0000000..d1f40e3
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/OnHeapCaching.java
@@ -0,0 +1,15 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.configuration.CacheConfiguration;
+
+public class OnHeapCaching {
+
+ public static void onHeapCacheExample() {
+ //tag::onHeap[]
+ CacheConfiguration cfg = new CacheConfiguration();
+ cfg.setName("myCache");
+ cfg.setOnheapCacheEnabled(true);
+ //end::onHeap[]
+
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PartitionLossPolicyExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PartitionLossPolicyExample.java
new file mode 100644
index 0000000..cc54248
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PartitionLossPolicyExample.java
@@ -0,0 +1,97 @@
+package org.apache.ignite.snippets;
+
+import java.util.Arrays;
+
+import javax.cache.CacheException;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.PartitionLossPolicy;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.events.CacheRebalancingEvent;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.processors.cache.CacheInvalidStateException;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.junit.jupiter.api.Test;
+
+public class PartitionLossPolicyExample {
+ @Test
+ void configure() {
+
+ //tag::cfg[]
+ CacheConfiguration cacheCfg = new CacheConfiguration("myCache");
+
+ cacheCfg.setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE);
+
+ //end::cfg[]
+ }
+
+ @Test
+ void events() {
+ //tag::events[]
+ Ignite ignite = Ignition.start();
+
+ IgnitePredicate<Event> locLsnr = evt -> {
+ CacheRebalancingEvent cacheEvt = (CacheRebalancingEvent) evt;
+
+ int lostPart = cacheEvt.partition();
+
+ ClusterNode node = cacheEvt.discoveryNode();
+
+ System.out.println(lostPart);
+
+ return true; // Continue listening.
+ };
+
+ ignite.events().localListen(locLsnr, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
+
+ //end::events[]
+
+ ignite.close();
+
+ }
+
+ @Test
+ void reset() {
+ Ignite ignite = Ignition.start();
+ //tag::reset[]
+ ignite.resetLostPartitions(Arrays.asList("myCache"));
+ //end::reset[]
+ ignite.close();
+ }
+
+ void getLostPartitions(Ignite ignite) {
+ //tag::lost-partitions[]
+ IgniteCache<Integer, String> cache = ignite.cache("myCache");
+
+ cache.lostPartitions();
+
+ //end::lost-partitions[]
+ }
+
+ @Test
+ void exception() {
+
+ try (Ignite ignite = Ignition.start()) {
+ ignite.getOrCreateCache("myCache");
+
+ //tag::exception[]
+ IgniteCache<Integer, Integer> cache = ignite.cache("myCache");
+
+ try {
+ Integer value = cache.get(3);
+ System.out.println(value);
+ } catch (CacheException e) {
+ if (e.getCause() instanceof CacheInvalidStateException) {
+ System.out.println(e.getCause().getMessage());
+ } else {
+ e.printStackTrace();
+ }
+ }
+ //end::exception[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PeerClassLoading.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PeerClassLoading.java
new file mode 100644
index 0000000..7d591f8
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PeerClassLoading.java
@@ -0,0 +1,26 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.DeploymentMode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.junit.jupiter.api.Test;
+
+public class PeerClassLoading {
+
+ @Test
+ void configure() {
+
+ //tag::configure[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setPeerClassLoadingEnabled(true);
+ cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::configure[]
+
+ ignite.close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PerformingTransactions.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PerformingTransactions.java
new file mode 100644
index 0000000..47335fa
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/PerformingTransactions.java
@@ -0,0 +1,162 @@
+package org.apache.ignite.snippets;
+
+import javax.cache.CacheException;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionDeadlockException;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionOptimisticException;
+import org.apache.ignite.transactions.TransactionTimeoutException;
+
+public class PerformingTransactions {
+
+ public static void main(String[] args) {
+ deadlockDetectionExample();
+ }
+
+ public static void runAll() {
+ enablingTransactions();
+ executingTransactionsExample();
+ optimisticTransactionExample();
+ deadlockDetectionExample();
+
+ }
+
+ public static void enablingTransactions() {
+ // tag::enabling[]
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setName("cacheName");
+
+ cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ // Optional transaction configuration. Configure TM lookup here.
+ TransactionConfiguration txCfg = new TransactionConfiguration();
+
+ cfg.setTransactionConfiguration(txCfg);
+
+ // Start a node
+ Ignition.start(cfg);
+ // end::enabling[]
+ Ignition.ignite().close();
+ }
+
+ public static void executingTransactionsExample() {
+ try (Ignite i = Ignition.start()) {
+ CacheConfiguration<String, Integer> cfg = new CacheConfiguration<>();
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setName("myCache");
+ IgniteCache<String, Integer> cache = i.getOrCreateCache("myCache");
+ cache.put("Hello", 1);
+ // tag::executing[]
+ Ignite ignite = Ignition.ignite();
+
+ IgniteTransactions transactions = ignite.transactions();
+
+ try (Transaction tx = transactions.txStart()) {
+ Integer hello = cache.get("Hello");
+
+ if (hello == 1)
+ cache.put("Hello", 11);
+
+ cache.put("World", 22);
+
+ tx.commit();
+ }
+ // end::executing[]
+ System.out.println(cache.get("Hello"));
+ System.out.println(cache.get("World"));
+ }
+ }
+
+ public static void optimisticTransactionExample() {
+ try (Ignite ignite = Ignition.start()) {
+ // tag::optimistic[]
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setName("myCache");
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg);
+
+ // Re-try the transaction a limited number of times.
+ int retryCount = 10;
+ int retries = 0;
+
+ // Start a transaction in the optimistic mode with the serializable isolation
+ // level.
+ while (retries < retryCount) {
+ retries++;
+ try (Transaction tx = ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
+ TransactionIsolation.SERIALIZABLE)) {
+ // modify cache entries as part of this transaction.
+ cache.put(1, "foo");
+ cache.put(2, "bar");
+ // commit the transaction
+ tx.commit();
+
+ // the transaction succeeded. Leave the while loop.
+ break;
+ } catch (TransactionOptimisticException e) {
+ // Transaction has failed. Retry.
+ }
+ }
+ // end::optimistic[]
+ System.out.println(cache.get(1));
+ }
+ }
+
+ void timeout() {
+ // tag::timeout[]
+ // Create a configuration
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Create a Transaction configuration
+ TransactionConfiguration txCfg = new TransactionConfiguration();
+
+ // Set the timeout to 20 seconds
+ txCfg.setTxTimeoutOnPartitionMapExchange(20000);
+
+ cfg.setTransactionConfiguration(txCfg);
+
+ // Start the node
+ Ignition.start(cfg);
+ // end::timeout[]
+ }
+
+ public static void deadlockDetectionExample() {
+ try (Ignite ignite = Ignition.start()) {
+
+ // tag::deadlock[]
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+ cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cfg.setName("myCache");
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg);
+
+ try (Transaction tx = ignite.transactions().txStart(TransactionConcurrency.PESSIMISTIC,
+ TransactionIsolation.READ_COMMITTED, 300, 0)) {
+ cache.put(1, "1");
+ cache.put(2, "1");
+
+ tx.commit();
+ } catch (CacheException e) {
+ if (e.getCause() instanceof TransactionTimeoutException
+ && e.getCause().getCause() instanceof TransactionDeadlockException)
+
+ System.out.println(e.getCause().getCause().getMessage());
+ }
+ // end::deadlock[]
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Person.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Person.java
new file mode 100644
index 0000000..2f4bda7
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Person.java
@@ -0,0 +1,59 @@
+package org.apache.ignite.snippets;
+
+public class Person {
+ private long id;
+
+ private String name;
+
+ private int age;
+
+ private float salary;
+
+ private int orgId;
+
+ public Person(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public float getSalary() {
+ return salary;
+ }
+
+ public void setSalary(float salary) {
+ this.salary = salary;
+ }
+
+ public int getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(int orgId) {
+ this.orgId = orgId;
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntitiesExampleWithAnnotation.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntitiesExampleWithAnnotation.java
new file mode 100644
index 0000000..9a362bd
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntitiesExampleWithAnnotation.java
@@ -0,0 +1,42 @@
+package org.apache.ignite.snippets;
+
+import java.io.Serializable;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+
+public class QueryEntitiesExampleWithAnnotation {
+// tag::query-entity-annotation[]
+ class Person implements Serializable {
+ /** Indexed field. Will be visible to the SQL engine. */
+ @QuerySqlField(index = true)
+ private long id;
+
+ /** Queryable field. Will be visible to the SQL engine. */
+ @QuerySqlField
+ private String name;
+
+ /** Will NOT be visible to the SQL engine. */
+ private int age;
+
+ /**
+ * Indexed field sorted in descending order. Will be visible to the SQL engine.
+ */
+ @QuerySqlField(index = true, descending = true)
+ private float salary;
+ }
+
+ public static void main(String[] args) {
+ Ignite ignite = Ignition.start();
+ CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<Long, Person>();
+ personCacheCfg.setName("Person");
+
+ personCacheCfg.setIndexedTypes(Long.class, Person.class);
+ IgniteCache<Long, Person> cache = ignite.createCache(personCacheCfg);
+ }
+
+// end::query-entity-annotation[]
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntityExample.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntityExample.java
new file mode 100644
index 0000000..a3aee3f
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/QueryEntityExample.java
@@ -0,0 +1,43 @@
+package org.apache.ignite.snippets;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.configuration.CacheConfiguration;
+
+
+public class QueryEntityExample {
+ // tag::query-entity[]
+ class Person implements Serializable {
+ private long id;
+
+ private String name;
+
+ private int age;
+
+ private float salary;
+ }
+
+ public static void main(String[] args) {
+ Ignite ignite = Ignition.start();
+ CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<Long, Person>();
+ personCacheCfg.setName("Person");
+
+ QueryEntity queryEntity = new QueryEntity(Long.class, Person.class)
+ .addQueryField("id", Long.class.getName(), null).addQueryField("age", Integer.class.getName(), null)
+ .addQueryField("salary", Float.class.getName(), null)
+ .addQueryField("name", String.class.getName(), null);
+
+ queryEntity.setIndexes(Arrays.asList(new QueryIndex("id"), new QueryIndex("salary", false)));
+
+ personCacheCfg.setQueryEntities(Arrays.asList(queryEntity));
+
+ IgniteCache<Long, Person> cache = ignite.createCache(personCacheCfg);
+ }
+ // end::query-entity[]
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/RebalancingConfiguration.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/RebalancingConfiguration.java
new file mode 100644
index 0000000..7846bf5
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/RebalancingConfiguration.java
@@ -0,0 +1,46 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class RebalancingConfiguration {
+
+ public static void main(String[] args) {
+ RebalancingConfiguration rc = new RebalancingConfiguration();
+
+ rc.configure();
+ }
+
+ void configure() {
+ //tag::ignite-config[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+ //tag::pool-size[]
+
+ cfg.setRebalanceThreadPoolSize(4);
+ //end::pool-size[]
+
+ CacheConfiguration cacheCfg = new CacheConfiguration("mycache");
+ //tag::mode[]
+
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+
+ //end::mode[]
+ //tag::throttling[]
+
+ cfg.setRebalanceBatchSize(2 * 1024 * 1024);
+ cfg.setRebalanceThrottle(100);
+
+ //end::throttling[]
+ cfg.setCacheConfiguration(cacheCfg);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::ignite-config[]
+
+ ignite.close();
+ }
+
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Swap.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Swap.java
new file mode 100644
index 0000000..bd0cf75
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/Swap.java
@@ -0,0 +1,39 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class Swap {
+
+ public void configureSwap() {
+ //tag::swap[]
+ // Node configuration.
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Durable Memory configuration.
+ DataStorageConfiguration storageCfg = new DataStorageConfiguration();
+
+ // Creating a new data region.
+ DataRegionConfiguration regionCfg = new DataRegionConfiguration();
+
+ // Region name.
+ regionCfg.setName("500MB_Region");
+
+ // Setting initial RAM size.
+ regionCfg.setInitialSize(100L * 1024 * 1024);
+
+ // Setting region max size equal to physical RAM size(5 GB)
+ regionCfg.setMaxSize(5L * 1024 * 1024 * 1024);
+
+ // Enable swap space.
+ regionCfg.setSwapPath("/path/to/some/directory");
+
+ // Setting the data region configuration.
+ storageCfg.setDataRegionConfigurations(regionCfg);
+
+ // Applying the new configuration.
+ cfg.setDataStorageConfiguration(storageCfg);
+ //end::swap[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/TcpIpDiscovery.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/TcpIpDiscovery.java
new file mode 100644
index 0000000..81250dd
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/TcpIpDiscovery.java
@@ -0,0 +1,319 @@
+package org.apache.ignite.snippets;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.logging.Logger;
+import javax.sql.DataSource;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder;
+import org.junit.jupiter.api.Test;
+
+public class TcpIpDiscovery {
+
+ @Test
+ void multicastIpFinderDemo() {
+ //tag::multicast[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
+
+ ipFinder.setMulticastGroup("228.10.10.157");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::multicast[]
+ ignite.close();
+ }
+
+ @Test
+ void failureDetectionTimeout() {
+ //tag::failure-detection-timeout[]
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ cfg.setFailureDetectionTimeout(5_000);
+
+ cfg.setClientFailureDetectionTimeout(10_000);
+ //end::failure-detection-timeout[]
+ }
+
+ @Test
+ void staticIpFinderDemo() {
+ //tag::static[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+ // Set initial IP addresses.
+ // Note that you can optionally specify a port or a port range.
+ ipFinder.setAddresses(Arrays.asList("1.2.3.4", "1.2.3.5:47500..47509"));
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::static[]
+ ignite.close();
+ }
+
+ @Test
+ void multicastAndStaticDemo() {
+ //tag::multicastAndStatic[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
+
+ // Set Multicast group.
+ ipFinder.setMulticastGroup("228.10.10.157");
+
+ // Set initial IP addresses.
+ // Note that you can optionally specify a port or a port range.
+ ipFinder.setAddresses(Arrays.asList("1.2.3.4", "1.2.3.5:47500..47509"));
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start a node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::multicastAndStatic[]
+ ignite.close();
+ }
+
+ @Test
+ void isolatedClustersDemo() {
+ //tag::isolated1[]
+ IgniteConfiguration firstCfg = new IgniteConfiguration();
+
+ firstCfg.setIgniteInstanceName("first");
+
+ // Explicitly configure TCP discovery SPI to provide list of initial nodes
+ // from the first cluster.
+ TcpDiscoverySpi firstDiscoverySpi = new TcpDiscoverySpi();
+
+ // Initial local port to listen to.
+ firstDiscoverySpi.setLocalPort(48500);
+
+ // Changing local port range. This is an optional action.
+ firstDiscoverySpi.setLocalPortRange(20);
+
+ TcpDiscoveryVmIpFinder firstIpFinder = new TcpDiscoveryVmIpFinder();
+
+ // Addresses and port range of the nodes from the first cluster.
+ // 127.0.0.1 can be replaced with actual IP addresses or host names.
+ // The port range is optional.
+ firstIpFinder.setAddresses(Collections.singletonList("127.0.0.1:48500..48520"));
+
+ // Overriding IP finder.
+ firstDiscoverySpi.setIpFinder(firstIpFinder);
+
+ // Explicitly configure TCP communication SPI by changing local port number for
+ // the nodes from the first cluster.
+ TcpCommunicationSpi firstCommSpi = new TcpCommunicationSpi();
+
+ firstCommSpi.setLocalPort(48100);
+
+ // Overriding discovery SPI.
+ firstCfg.setDiscoverySpi(firstDiscoverySpi);
+
+ // Overriding communication SPI.
+ firstCfg.setCommunicationSpi(firstCommSpi);
+
+ // Starting a node.
+ Ignition.start(firstCfg);
+ //end::isolated1[]
+
+ //tag::isolated2[]
+ IgniteConfiguration secondCfg = new IgniteConfiguration();
+
+ secondCfg.setIgniteInstanceName("second");
+
+ // Explicitly configure TCP discovery SPI to provide list of initial nodes
+ // from the second cluster.
+ TcpDiscoverySpi secondDiscoverySpi = new TcpDiscoverySpi();
+
+ // Initial local port to listen to.
+ secondDiscoverySpi.setLocalPort(49500);
+
+ // Changing local port range. This is an optional action.
+ secondDiscoverySpi.setLocalPortRange(20);
+
+ TcpDiscoveryVmIpFinder secondIpFinder = new TcpDiscoveryVmIpFinder();
+
+ // Addresses and port range of the nodes from the second cluster.
+ // 127.0.0.1 can be replaced with actual IP addresses or host names.
+ // The port range is optional.
+ secondIpFinder.setAddresses(Collections.singletonList("127.0.0.1:49500..49520"));
+
+ // Overriding IP finder.
+ secondDiscoverySpi.setIpFinder(secondIpFinder);
+
+ // Explicitly configure TCP communication SPI by changing local port number for
+ // the nodes from the second cluster.
+ TcpCommunicationSpi secondCommSpi = new TcpCommunicationSpi();
+
+ secondCommSpi.setLocalPort(49100);
+
+ // Overriding discovery SPI.
+ secondCfg.setDiscoverySpi(secondDiscoverySpi);
+
+ // Overriding communication SPI.
+ secondCfg.setCommunicationSpi(secondCommSpi);
+
+ // Starting a node.
+ Ignition.start(secondCfg);
+ //end::isolated2[]
+
+ Ignition.ignite("first").close();
+ Ignition.ignite("second").close();
+ }
+
+ static class MySampleDataSource implements DataSource {
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection(String username, String password) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter out) throws SQLException {
+
+ }
+
+ @Override
+ public void setLoginTimeout(int seconds) throws SQLException {
+
+ }
+
+ @Override
+ public int getLoginTimeout() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ return null;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+ }
+
+ @Test
+ void jdbcIpFinderDemo() {
+ //tag::jdbc[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ // Configure your DataSource.
+ DataSource someDs = new MySampleDataSource();
+
+ TcpDiscoveryJdbcIpFinder ipFinder = new TcpDiscoveryJdbcIpFinder();
+
+ ipFinder.setDataSource(someDs);
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::jdbc[]
+ ignite.close();
+ }
+
+ void sharedFileSystemIpFinderDemo() {
+
+ //tag::sharedFS[]
+ // Configuring discovery SPI.
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ // Configuring IP finder.
+ TcpDiscoverySharedFsIpFinder ipFinder = new TcpDiscoverySharedFsIpFinder();
+
+ ipFinder.setPath("/var/ignite/addresses");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::sharedFS[]
+ ignite.close();
+ }
+
+ @Test
+ void zookeeperIpFinderDemo() {
+
+ //tag::zk[]
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ TcpDiscoveryZookeeperIpFinder ipFinder = new TcpDiscoveryZookeeperIpFinder();
+
+ // Specify ZooKeeper connection string.
+ ipFinder.setZkConnectionString("127.0.0.1:2181");
+
+ spi.setIpFinder(ipFinder);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ // Override default discovery SPI.
+ cfg.setDiscoverySpi(spi);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::zk[]
+
+ ignite.close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UnderstandingConfiguration.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UnderstandingConfiguration.java
new file mode 100644
index 0000000..70b39ee
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UnderstandingConfiguration.java
@@ -0,0 +1,26 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class UnderstandingConfiguration {
+
+ public static void configurationDemo() {
+ //tag::cfg[]
+ //tag::dir[]
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+ //end::dir[]
+ //setting a work directory
+ //tag::dir[]
+ igniteCfg.setWorkDirectory("/path/to/work/directory");
+ //end::dir[]
+
+ //defining a partitioned cache
+ CacheConfiguration cacheCfg = new CacheConfiguration("myCache");
+ cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+
+ igniteCfg.setCacheConfiguration(cacheCfg);
+ //end::cfg[]
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingContinuousQueries.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingContinuousQueries.java
new file mode 100644
index 0000000..d3ff358
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingContinuousQueries.java
@@ -0,0 +1,142 @@
+package org.apache.ignite.snippets;
+
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.ContinuousQueryWithTransformer;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.lang.IgniteClosure;
+
+public class UsingContinuousQueries {
+
+ public static void runAll() {
+ initialQueryExample();
+ localListenerExample();
+ remoteFilterExample();
+ remoteTransformerExample();
+ }
+
+ public static void initialQueryExample() {
+ try (Ignite ignite = Ignition.start()) {
+
+ //tag::initialQry[]
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
+
+ //end::initialQry[]
+ cache.put(100, "100");
+
+ //tag::initialQry[]
+ ContinuousQuery<Integer, String> query = new ContinuousQuery<>();
+
+ // Setting an optional initial query.
+ // The query will return entries for the keys greater than 10.
+ query.setInitialQuery(new ScanQuery<>((k, v) -> k > 10));
+
+ //mandatory local listener
+ query.setLocalListener(events -> {
+ });
+
+ try (QueryCursor<Cache.Entry<Integer, String>> cursor = cache.query(query)) {
+ // Iterating over the entries returned by the initial query
+ for (Cache.Entry<Integer, String> e : cursor)
+ System.out.println("key=" + e.getKey() + ", val=" + e.getValue());
+ }
+ //end::initialQry[]
+ }
+ }
+
+ public static void localListenerExample() {
+ try (Ignite ignite = Ignition.start()) {
+
+ //tag::localListener[]
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
+
+ ContinuousQuery<Integer, String> query = new ContinuousQuery<>();
+
+ query.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() {
+
+ @Override
+ public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> events)
+ throws CacheEntryListenerException {
+ // react to the update events here
+ }
+ });
+
+ cache.query(query);
+
+ //end::localListener[]
+ }
+ }
+
+ public static void remoteFilterExample() {
+ try (Ignite ignite = Ignition.start()) {
+
+ IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCache");
+
+ //tag::remoteFilter[]
+ ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
+
+ qry.setLocalListener(events ->
+ events.forEach(event -> System.out.format("Entry: key=[%s] value=[%s]\n", event.getKey(), event.getValue()))
+ );
+
+ qry.setRemoteFilterFactory(new Factory<CacheEntryEventFilter<Integer, String>>() {
+ @Override
+ public CacheEntryEventFilter<Integer, String> create() {
+ return new CacheEntryEventFilter<Integer, String>() {
+ @Override
+ public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends String> e) {
+ System.out.format("the value for key [%s] was updated from [%s] to [%s]\n", e.getKey(), e.getOldValue(), e.getValue());
+ return true;
+ }
+ };
+ }
+ });
+
+ //end::remoteFilter[]
+ cache.query(qry);
+ cache.put(1, "1");
+
+ }
+ }
+
+ public static void remoteTransformerExample() {
+ try (Ignite ignite = Ignition.start()) {
+
+ //tag::transformer[]
+ IgniteCache<Integer, Person> cache = ignite.getOrCreateCache("myCache");
+
+ // Create a new continuous query with a transformer.
+ ContinuousQueryWithTransformer<Integer, Person, String> qry = new ContinuousQueryWithTransformer<>();
+
+ // Factory to create transformers.
+ Factory factory = FactoryBuilder.factoryOf(
+ // Return one field of a complex object.
+ // Only this field will be sent over to the local listener.
+ (IgniteClosure<CacheEntryEvent, String>)
+ event -> ((Person)event.getValue()).getName()
+ );
+
+ qry.setRemoteTransformerFactory(factory);
+
+ // Listener that will receive transformed data.
+ qry.setLocalListener(names -> {
+ for (String name : names)
+ System.out.println("New person name: " + name);
+ });
+ //end::transformer[]
+
+ cache.query(qry);
+ cache.put(1, new Person(1, "Vasya"));
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingScanQueries.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingScanQueries.java
new file mode 100644
index 0000000..46148a7
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/UsingScanQueries.java
@@ -0,0 +1,71 @@
+package org.apache.ignite.snippets;
+
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
+import org.junit.jupiter.api.Test;
+
+public class UsingScanQueries {
+
+ @Test
+ void localQuery() {
+ try (Ignite ignite = Ignition.start()) {
+ IgniteCache<Integer, Person> cache = ignite.getOrCreateCache("myCache");
+ //tag::localQuery[]
+ QueryCursor<Cache.Entry<Integer, Person>> cursor = cache
+ .query(new ScanQuery<Integer, Person>().setLocal(true));
+ //end::localQuery[]
+ }
+ }
+
+ @Test
+ void executingScanQueriesExample() {
+ try (Ignite ignite = Ignition.start()) {
+ //tag::scanQry[]
+ //tag::predicate[]
+ //tag::transformer[]
+ IgniteCache<Integer, Person> cache = ignite.getOrCreateCache("myCache");
+ //end::scanQry[]
+ //end::predicate[]
+ //end::transformer[]
+
+ Person person = new Person(1, "Vasya Ivanov");
+ person.setSalary(2000);
+ cache.put(1, person);
+ //tag::scanQry[]
+
+ QueryCursor<Cache.Entry<Integer, Person>> cursor = cache.query(new ScanQuery<>());
+ //end::scanQry[]
+ System.out.println("Scan query output:" + cursor.getAll().get(0).getValue().getName());
+
+ //tag::predicate[]
+
+ // Find the persons who earn more than 1,000.
+ IgniteBiPredicate<Integer, Person> filter = (key, p) -> p.getSalary() > 1000;
+
+ try (QueryCursor<Cache.Entry<Integer, Person>> qryCursor = cache.query(new ScanQuery<>(filter))) {
+ qryCursor.forEach(
+ entry -> System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()));
+ }
+ //end::predicate[]
+
+ //tag::transformer[]
+
+ // Get only keys for persons earning more than 1,000.
+ List<Integer> keys = cache.query(new ScanQuery<>(
+ // Remote filter
+ (IgniteBiPredicate<Integer, Person>) (k, p) -> p.getSalary() > 1000),
+ // Transformer
+ (IgniteClosure<Cache.Entry<Integer, Person>, Integer>) Cache.Entry::getKey).getAll();
+ //end::transformer[]
+
+ System.out.println("Transformer example output:" + keys.get(0));
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/WorkingWithBinaryObjects.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/WorkingWithBinaryObjects.java
new file mode 100644
index 0000000..6487ba4
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/WorkingWithBinaryObjects.java
@@ -0,0 +1,167 @@
+package org.apache.ignite.snippets;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+public class WorkingWithBinaryObjects {
+
+ public static void runAll() {
+ binaryObjectsDemo();
+ binaryFieldsExample();
+ configuringBinaryObjects();
+ }
+
+ public static void binaryObjectsDemo() {
+ try (Ignite ignite = Ignition.start()) {
+ IgniteCache<Integer, Person> cache = ignite.createCache("personCache");
+
+ //tag::enablingBinary[]
+ // Create a regular Person object and put it into the cache.
+ Person person = new Person(1, "FirstPerson");
+ ignite.cache("personCache").put(1, person);
+
+ // Get an instance of binary-enabled cache.
+ IgniteCache<Integer, BinaryObject> binaryCache = ignite.cache("personCache").withKeepBinary();
+ BinaryObject binaryPerson = binaryCache.get(1);
+ //end::enablingBinary[]
+ System.out.println("Binary object:" + binaryPerson);
+
+ //tag::binaryBuilder[]
+ BinaryObjectBuilder builder = ignite.binary().builder("org.apache.ignite.snippets.Person");
+
+ builder.setField("id", 2L);
+ builder.setField("name", "SecondPerson");
+
+ binaryCache.put(2, builder.build());
+ //end::binaryBuilder[]
+ System.out.println("Value from binary builder:" + cache.get(2).getName());
+
+ //tag::cacheEntryProc[]
+ // The EntryProcessor is to be executed for this key.
+ int key = 1;
+ ignite.cache("personCache").<Integer, BinaryObject>withKeepBinary().invoke(key, (entry, arguments) -> {
+ // Create a builder from the old value.
+ BinaryObjectBuilder bldr = entry.getValue().toBuilder();
+
+ //Update the field in the builder.
+ bldr.setField("name", "Ignite");
+
+ // Set new value to the entry.
+ entry.setValue(bldr.build());
+
+ return null;
+ });
+ //end::cacheEntryProc[]
+ System.out.println("EntryProcessor output:" + cache.get(1).getName());
+ }
+ }
+
+ public static void binaryFieldsExample() {
+ try (Ignite ignite = Ignition.start()) {
+ //tag::binaryField[]
+ Collection<BinaryObject> persons = getPersons();
+
+ BinaryField salary = null;
+ double total = 0;
+ int count = 0;
+
+ for (BinaryObject person : persons) {
+ if (salary == null) {
+ salary = person.type().field("salary");
+ }
+
+ total += (float) salary.value(person);
+ count++;
+ }
+
+ double avg = total / count;
+ //end::binaryField[]
+ System.out.println("binary fields example:" + avg);
+ }
+ }
+
+ private static Collection<BinaryObject> getPersons() {
+ IgniteBinary binary = Ignition.ignite().binary();
+ Person p1 = new Person(1, "name1");
+ p1.setSalary(1);
+ Person p2 = new Person(2, "name2");
+ p2.setSalary(2);
+ return Arrays.asList(binary.toBinary(p1), binary.toBinary(p2));
+ }
+
+ public static void configuringBinaryObjects() {
+ //tag::cfg[]
+ IgniteConfiguration igniteCfg = new IgniteConfiguration();
+
+ BinaryConfiguration binaryConf = new BinaryConfiguration();
+ binaryConf.setNameMapper(new MyBinaryNameMapper());
+ binaryConf.setIdMapper(new MyBinaryIdMapper());
+
+ BinaryTypeConfiguration binaryTypeCfg = new BinaryTypeConfiguration();
+ binaryTypeCfg.setTypeName("org.apache.ignite.snippets.*");
+ binaryTypeCfg.setSerializer(new ExampleSerializer());
+
+ binaryConf.setTypeConfigurations(Collections.singleton(binaryTypeCfg));
+
+ igniteCfg.setBinaryConfiguration(binaryConf);
+ //end::cfg[]
+
+ }
+
+ private static class MyBinaryNameMapper implements BinaryNameMapper {
+
+ @Override
+ public String typeName(String clsName) {
+ return clsName;
+ }
+
+ @Override
+ public String fieldName(String fieldName) {
+ return fieldName;
+ }
+ }
+
+ private static class MyBinaryIdMapper implements BinaryIdMapper {
+
+ @Override
+ public int typeId(String typeName) {
+ return typeName.hashCode();
+ }
+
+ @Override
+ public int fieldId(int typeId, String fieldName) {
+ return typeId + fieldName.hashCode();
+ }
+ }
+
+ private static class ExampleSerializer implements BinarySerializer {
+
+ @Override
+ public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+
+ }
+
+ @Override
+ public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+
+ }
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ZookeeperDiscovery.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ZookeeperDiscovery.java
new file mode 100644
index 0000000..863ec81
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ZookeeperDiscovery.java
@@ -0,0 +1,30 @@
+package org.apache.ignite.snippets;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
+
+public class ZookeeperDiscovery {
+
+ void ZookeeperDiscoveryConfigurationExample() {
+ //tag::cfg[]
+ ZookeeperDiscoverySpi zkDiscoverySpi = new ZookeeperDiscoverySpi();
+
+ zkDiscoverySpi.setZkConnectionString("127.0.0.1:34076,127.0.0.1:43310,127.0.0.1:36745");
+ zkDiscoverySpi.setSessionTimeout(30_000);
+
+ zkDiscoverySpi.setZkRootPath("/ignite");
+ zkDiscoverySpi.setJoinTimeout(10_000);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ //Override default discovery SPI.
+ cfg.setDiscoverySpi(zkDiscoverySpi);
+
+ // Start the node.
+ Ignite ignite = Ignition.start(cfg);
+ //end::cfg[]
+ ignite.close();
+ }
+}
diff --git a/docs/_docs/code-snippets/java/src/main/resources/config/ignite-jdbc.xml b/docs/_docs/code-snippets/java/src/main/resources/config/ignite-jdbc.xml
new file mode 100644
index 0000000..5f288c8
--- /dev/null
+++ b/docs/_docs/code-snippets/java/src/main/resources/config/ignite-jdbc.xml
@@ -0,0 +1,21 @@
+<?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">
+ <bean class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="clientMode" value="true"/>
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="reconnectCount" value="1"/>
+ <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>
+ </bean>
+</beans>
diff --git a/docs/_docs/code-snippets/java/src/main/resources/keystore/node.jks b/docs/_docs/code-snippets/java/src/main/resources/keystore/node.jks
new file mode 100644
index 0000000..006ecec
Binary files /dev/null and b/docs/_docs/code-snippets/java/src/main/resources/keystore/node.jks differ
diff --git a/docs/_docs/code-snippets/java/src/main/resources/keystore/trust.jks b/docs/_docs/code-snippets/java/src/main/resources/keystore/trust.jks
new file mode 100644
index 0000000..a00f125
Binary files /dev/null and b/docs/_docs/code-snippets/java/src/main/resources/keystore/trust.jks differ
diff --git a/docs/_docs/code-snippets/xml/affinity-backup-filter.xml b/docs/_docs/code-snippets/xml/affinity-backup-filter.xml
new file mode 100644
index 0000000..0474c2f
--- /dev/null
+++ b/docs/_docs/code-snippets/xml/affinity-backup-filter.xml
@@ -0,0 +1,49 @@
+<?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">
+ <!-- tag::node-attribute[] -->
+ <property name="userAttributes">
+ <map>
+ <entry key="AVAILABILITY_ZONE" value="us-east-1a"/>
+ </map>
+ </property>
+ <!-- end::node-attribute[] -->
+ <property name="cacheConfiguration">
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="myCache"/>
+ <property name="backups" value="1"/>
+ <property name="affinity">
+ <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+ <property name="affinityBackupFilter">
+ <bean class="org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilter">
+ <constructor-arg>
+ <array value-type="java.lang.String">
+ <!-- Backups must go to different availability zones -->
+ <value>AVAILABILITY_ZONE</value>
+ </array>
+ </constructor-arg>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <!-- tag::discovery[] -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <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/code-snippets/xml/attribute-node-filter.xml b/docs/_docs/code-snippets/xml/attribute-node-filter.xml
new file mode 100644
index 0000000..2e3abfc
--- /dev/null
+++ b/docs/_docs/code-snippets/xml/attribute-node-filter.xml
@@ -0,0 +1,42 @@
+<?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">
+ <!-- tag::node-attribute[] -->
+ <property name="userAttributes">
+ <map>
+ <entry key="host_myCache" value="true"/>
+ </map>
+ </property>
+ <!-- end::node-attribute[] -->
+ <!-- tag::cache-config[] -->
+ <property name="cacheConfiguration">
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="myCache"/>
+ <property name="nodeFilter">
+ <bean class="org.apache.ignite.util.AttributeNodeFilter">
+ <constructor-arg value="host_myCache"/>
+ <constructor-arg value="true"/>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <!-- end::cache-config[] -->
+ <!-- tag::discovery[] -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <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/code-snippets/xml/cache-configuration.xml b/docs/_docs/code-snippets/xml/cache-configuration.xml
new file mode 100644
index 0000000..954dd28
--- /dev/null
+++ b/docs/_docs/code-snippets/xml/cache-configuration.xml
@@ -0,0 +1,33 @@
+<?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="cacheConfiguration">
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="myCache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="2"/>
+ <property name="rebalanceMode" value="SYNC"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+ <property name="partitionLossPolicy" value="READ_ONLY_SAFE"/>
+ <!-- Other parameters -->
+ </bean>
+ </property>
+ <!-- tag::discovery[] -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
... 12415 lines suppressed ...