You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ab...@apache.org on 2020/08/27 09:58:32 UTC
[ignite] branch IGNITE-7595 updated (c10ce4e -> 02ed896)
This is an automated email from the ASF dual-hosted git repository.
abudnikov pushed a change to branch IGNITE-7595
in repository https://gitbox.apache.org/repos/asf/ignite.git.
from c10ce4e minor fixes
new d94f7d4 add .net platform cache page
new 02ed896 minor updates
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
docs/_data/toc.yaml | 4 +-
docs/_docs/code-snippets/dotnet/PlatformCache.cs | 104 +++++++++++++++++++
.../org/apache/ignite/snippets/ClusterAPI.java | 2 -
docs/_docs/monitoring-metrics/tracing.adoc | 4 +-
docs/_docs/platform-cache.adoc | 111 +++++++++++++++++++++
docs/_docs/plugins.adoc | 4 +-
6 files changed, 220 insertions(+), 9 deletions(-)
create mode 100644 docs/_docs/code-snippets/dotnet/PlatformCache.cs
create mode 100644 docs/_docs/platform-cache.adoc
[ignite] 01/02: add .net platform cache page
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
abudnikov pushed a commit to branch IGNITE-7595
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit d94f7d42edb8498dcb5fa422d45b6853c4e6b742
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Thu Aug 27 12:57:26 2020 +0300
add .net platform cache page
---
docs/_data/toc.yaml | 4 +-
docs/_docs/code-snippets/dotnet/PlatformCache.cs | 104 +++++++++++++++++++++
docs/_docs/platform-cache.adoc | 111 +++++++++++++++++++++++
3 files changed, 217 insertions(+), 2 deletions(-)
diff --git a/docs/_data/toc.yaml b/docs/_data/toc.yaml
index 95a0b08..bab4c2d 100644
--- a/docs/_data/toc.yaml
+++ b/docs/_data/toc.yaml
@@ -179,8 +179,8 @@
url: /events/events
- title: Near Caches
url: /near-cache
-# - title: .NET Platform Cache
-# url: /platform-cache
+- title: .NET Platform Cache
+ url: /platform-cache
- title: Monitoring
items:
- title: Introduction
diff --git a/docs/_docs/code-snippets/dotnet/PlatformCache.cs b/docs/_docs/code-snippets/dotnet/PlatformCache.cs
new file mode 100644
index 0000000..689ea43
--- /dev/null
+++ b/docs/_docs/code-snippets/dotnet/PlatformCache.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Binary;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Configuration;
+using Apache.Ignite.Core.Cache.Eviction;
+
+namespace dotnet_helloworld
+{
+ public class PlatformCache
+ {
+ public static void ConfigurePlatformCacheOnServer()
+ {
+ var ignite = Ignition.Start();
+
+ //tag::platformCacheConf[]
+ var cacheCfg = new CacheConfiguration("my-cache")
+ {
+ PlatformCacheConfiguration = new PlatformCacheConfiguration()
+ };
+
+ var cache = ignite.CreateCache<int, string>(cacheCfg);
+ //end::platformCacheConf[]
+ }
+
+ public static void ConfigurePlatformCacheOnClient()
+ {
+ var ignite = Ignition.Start();
+
+ //tag::platformCacheConfClient[]
+ var nearCacheCfg = new NearCacheConfiguration
+ {
+ // Keep up to 1000 most recently used entries in Near and Platform caches.
+ EvictionPolicy = new LruEvictionPolicy
+ {
+ MaxSize = 1000
+ }
+ };
+
+ var cache = ignite.CreateNearCache<int, string>("my-cache",
+ nearCacheCfg,
+ new PlatformCacheConfiguration());
+ //end::platformCacheConfClient[]
+ }
+
+ public static void AccessPlatformCache()
+ {
+ var ignite = Ignition.Start();
+
+ //tag::platformCacheAccess[]
+ var cache = ignite.GetCache<int, string>("my-cache");
+
+ // Get value from platform cache.
+ bool hasKey = cache.TryLocalPeek(1, out var val, CachePeekMode.Platform);
+
+ // Get platform cache size (current number of entries on local node).
+ int size = cache.GetLocalSize(CachePeekMode.Platform);
+
+ // Get all values from platform cache.
+ IEnumerable<ICacheEntry<int, string>> entries = cache.GetLocalEntries(CachePeekMode.Platform);
+
+ //end::platformCacheAccess[]
+ }
+
+ public static void AdvancedConfigBinaryMode()
+ {
+ var ignite = Ignition.Start();
+
+ //tag::advancedConfigBinaryMode[]
+ var cacheCfg = new CacheConfiguration("people")
+ {
+ PlatformCacheConfiguration = new PlatformCacheConfiguration
+ {
+ KeepBinary = true
+ }
+ };
+
+ var cache = ignite.CreateCache<int, Person>(cacheCfg)
+ .WithKeepBinary<int, IBinaryObject>();
+
+ IBinaryObject binaryPerson = cache.Get(1);
+ //end::advancedConfigBinaryMode[]
+ }
+
+ public static void AdvancedConfigKeyValTypes()
+ {
+ var ignite = Ignition.Start();
+
+ //tag::advancedConfigKeyValTypes[]
+ var cacheCfg = new CacheConfiguration("people")
+ {
+ PlatformCacheConfiguration = new PlatformCacheConfiguration
+ {
+ KeyTypeName = typeof(long).FullName,
+ ValueTypeName = typeof(Guid).FullName
+ }
+ };
+
+ var cache = ignite.CreateCache<long, Guid>(cacheCfg);
+ //end::advancedConfigKeyValTypes[]
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/_docs/platform-cache.adoc b/docs/_docs/platform-cache.adoc
new file mode 100644
index 0000000..fd062d4
--- /dev/null
+++ b/docs/_docs/platform-cache.adoc
@@ -0,0 +1,111 @@
+= .NET Platform Cache
+
+CAUTION: Experimental API
+
+Ignite.NET provides an additional layer of caching in the link:https://docs.microsoft.com/en-us/dotnet/standard/clr[CLR] heap. The platform cache keeps a deserialized copy of every cache entry that is present on the current node, thus greatly improving cache read performance at the cost of increased memory usage.
+
+[NOTE]
+====
+Platform caches are bypassed within transactions: when a transaction is active, `cache.Get` and the other APIs listed below do not use the platform cache. Transaction support is coming soon.
+====
+
+
+== Configuring Platform Cache
+
+:dotnetCodeFile: code-snippets/dotnet/PlatformCache.cs
+
+
+=== Server Nodes
+
+Platform cache is configured once for all server nodes by setting `CacheConfiguration.PlatformCacheConfiguration` to a non-null value. Platform cache on server nodes stores *all primary and backup cache entries assigned to the given node* in .NET memory.
+Entries are updated in real time and they are guaranteed to be up to date at any given moment, even before user code accesses them.
+
+CAUTION: Platform cache effectively doubles memory usage on server nodes, every cache entry is stored twice: serialized in unmanaged (offheap) memory, and deserialized in CLR heap.
+
+[tabs]
+--
+tab:C#/.NET[]
+[source,csharp]
+----
+include::{dotnetCodeFile}[tag=platformCacheConf,indent=0]
+----
+--
+
+
+=== Client Nodes
+
+Platform caches on client nodes require a link:near-cache[Near Cache] to be configured, since client nodes do not store data otherwise. The platform cache on a client node keeps the same set of entries as the near cache on that node. the near cache eviction policy effectively applies to the platform cache.
+
+[tabs]
+--
+tab:C#/.NET[]
+[source,csharp]
+----
+include::{dotnetCodeFile}[tag=platformCacheConfClient,indent=0]
+----
+--
+
+
+== Supported APIs
+
+The following `ICache<K, V>` APIs use a platform cache (including the corresponding async versions):
+
+* `Get`, `TryGet`, indexer (`ICache[k]`)
+* `GetAll` (reads from the platform cache first and falls back to the distributed cache when necessary)
+* `ContainsKey`, `ContainsKeys`
+* `LocalPeek`, `TryLocalPeek`
+* `GetLocalEntries`
+* `GetLocalSize`
+* `Query` with `ScanQuery`
+** Uses the platform cache to pass values to `ScanQuery.Filter`
+** Iterates over the platform cache directly when `ScanQuery.Local` is `true` and `ScanQuery.Partition` is not null
+
+
+== Access Platform Cache Data Directly
+
+You don't need to change your code to take advantage of a Platform Cache. Existing calls to `ICache.Get` and other APIs listed above will be served from the platform cache when possible, improving performance. When a given entry is not present in the platform cache, Ignite falls back to a normal path and retrieves the value from the cluster.
+
+However, in some cases we may wish to access the platform cache exclusively, avoiding Java and network calls. `Local` APIs in combination with `CachePeekMode.Platform` allow us to do just that:
+
+[tabs]
+--
+tab:C#/.NET[]
+[source,csharp]
+----
+include::{dotnetCodeFile}[tag=platformCacheAccess,indent=0]
+----
+--
+
+
+== Advanced Configuration
+
+=== Binary Mode
+
+In order to use link:key-value-api/binary-objects[Binary Objects] together with platform cache, set `PlatformCacheConfiguration.KeepBinary` to `true`:
+
+[tabs]
+--
+tab:C#/.NET[]
+[source,csharp]
+----
+include::{dotnetCodeFile}[tag=advancedConfigBinaryMode,indent=0]
+----
+--
+
+
+=== Key and Value Types
+
+When using Ignite cache with link:https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types[Value Types], you should set `PlatformCacheConfiguration.KeyTypeName` and `ValueTypeName` accordingly to achieve maximum performance and reduce GC pressure:
+
+[tabs]
+--
+tab:C#/.NET[]
+[source,csharp]
+----
+include::{dotnetCodeFile}[tag=advancedConfigKeyValTypes,indent=0]
+----
+--
+
+Ignite uses `ConcurrentDictionary<object, object>` by default to store platform cache data, because the actual types are unknown beforehand. This results in link:https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing[boxing and unboxing] for value types, reducing performance and allocating more memory. When `KeyTypeName` and `ValueTypeName` are set in `PlatformCacheConfiguration`, Ignite uses those types to create an internal `ConcurrentDictionary` in [...]
+
+CAUTION: Incorrect `KeyTypeName` and/or `ValueTypeName` settings can cause runtime cast exceptions.
[ignite] 02/02: minor updates
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
abudnikov pushed a commit to branch IGNITE-7595
in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 02ed896add1e96c48d61e9d6f4aff20f65099a97
Author: abudnikov <ab...@gridgain.com>
AuthorDate: Thu Aug 27 12:57:52 2020 +0300
minor updates
---
.../java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java | 2 --
docs/_docs/monitoring-metrics/tracing.adoc | 4 ++--
docs/_docs/plugins.adoc | 4 +---
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
index d56d8a0..552f2a9 100644
--- a/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
+++ b/docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/ClusterAPI.java
@@ -1,7 +1,5 @@
package org.apache.ignite.snippets;
-import java.util.UUID;
-
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteCluster;
diff --git a/docs/_docs/monitoring-metrics/tracing.adoc b/docs/_docs/monitoring-metrics/tracing.adoc
index 5db0717..575db00 100644
--- a/docs/_docs/monitoring-metrics/tracing.adoc
+++ b/docs/_docs/monitoring-metrics/tracing.adoc
@@ -56,8 +56,8 @@ You can do this in two ways:
* via the control script from the command line
* programmatically
-Traces are collected with a given probabilistic sampling rate.
-The rate is specified as a value between 0 and 1 inclusive: `0` means no sampling, `1` means always sampling.
+Traces are collected at a given probabilistic sampling rate.
+The rate is specified as a value between 0.0 and 1.0 inclusive: `0` means no sampling, `1` means always sampling.
When the sampling rate is set to a value greater than 0, Ignite collects traces.
To disable trace collection, set the sampling rate to 0.
diff --git a/docs/_docs/plugins.adoc b/docs/_docs/plugins.adoc
index b9d038b..e5d1d30 100644
--- a/docs/_docs/plugins.adoc
+++ b/docs/_docs/plugins.adoc
@@ -2,8 +2,6 @@
== Overview
-
-
The Ignite plugin system allows you to extend the core functionality of Ignite.
Plugins have access to different internal Ignite components, such as security processor and others, and can extend the programmatic API of Ignite.
@@ -52,7 +50,6 @@ include::{javaCodeDir}/plugin/MyPluginProvider.java[tags=!no-op-methods, indent=
The `onIgniteStart()` method is invoked when Ignite is started.
We start the plugin by calling `MyPlugin.start()`, which simply schedules periodic execution of the task that prints cache size information.
-
=== {counter:step}. Implement IgnitePlugin
The implementation of the `IgnitePlugin` returned by the plugin provider is available to the users via `Ignite.plugin(String pluginName)`.
@@ -109,6 +106,7 @@ When you start the node, you should see the following message in the console:
=== {counter:step}. Access the Plugin at Runtime
You can access the instance of the plugin by calling `Ignite.plugin(pluginName)`.
+The `pluginName` argument must be equal to the plugin name returned in `MyPluginProvider.name()`.
[source, java]
----