apache-ignite
201 строка · 6.3 Кб
1// Licensed to the Apache Software Foundation (ASF) under one or more
2// contributor license agreements. See the NOTICE file distributed with
3// this work for additional information regarding copyright ownership.
4// The ASF licenses this file to You under the Apache License, Version 2.0
5// (the "License"); you may not use this file except in compliance with
6// the License. You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15= Configuring Data Regions
16
17== Overview
18Ignite uses the concept of _data regions_ to control the amount of RAM available to a cache or a group of caches. A data region is a logical extendable area in RAM in which cached data resides. You can control the initial size of the region and the maximum size it can occupy. In addition to the size, data regions control link:persistence/native-persistence[persistence settings] for caches.
19
20By default, there is one data region that can take up to 20% of RAM available to the node, and all caches you create are placed in that region; but you can add as many regions as you want. There are a couple of reasons why you may want to have multiple regions:
21
22* Regions allow you to configure the amount of RAM available to a cache or number of caches.
23* Persistence parameters are configured per region. If you want to have both in-memory only caches and the caches that store their content to disk, you need to configure two (or more) data regions with different persistence settings: one for in-memory caches and one for persistent caches.
24* Some memory parameters, such as link:memory-configuration/eviction-policies[eviction policies], are configured per data region.
25
26See the following section to learn how to change the parameters of the default data region or configure multiple data regions.
27
28== Configuring Default Data Region
29
30By default, a new cache is added to the default data region. If you want to change the properties of the default data region, you can do so in the data storage configuration.
31
32
33:xmlFile: code-snippets/xml/data-regions-configuration.xml
34:javaFile: {javaCodeDir}/DataRegionConfigurationExample.java
35
36[tabs]
37--
38tab:XML[]
39
40[source,xml]
41----
42include::{xmlFile}[tags=!*;ignite-config;default;!discovery,indent=0]
43----
44tab:Java[]
45[source,java]
46----
47include::{javaFile}[tags=!*;ignite-config;default,indent=0]
48----
49tab:C#/.NET[]
50[source,csharp]
51----
52include::code-snippets/dotnet/MemoryArchitecture.cs[tag=DefaultDataReqion,indent=0]
53----
54tab:C++[unsupported]
55--
56
57== Adding Custom Data Regions
58
59In addition to the default data region, you can add more data regions with custom settings.
60In the following example, we configure a data region that can take up to 40 MB and uses the link:memory-configuration/eviction-policies#random-2-lru[Random-2-LRU] eviction policy.
61Note that further below in the configuration, we create a cache that resides in the new data region.
62
63[tabs]
64--
65tab:XML[]
66[source,xml]
67----
68include::{xmlFile}[tags=!*;ignite-config;data-region;default;caches;!discovery,indent=0]
69----
70
71For the full list of properties, refer to the link:{javadoc_base_url}/org/apache/ignite/configuration/DataStorageConfiguration.html[DataStorageConfiguration] javadoc.
72tab:Java[]
73[source,java]
74----
75include::{javaFile}[tags=ignite-config,indent=0]
76----
77tab:C#/.NET[]
78[source,csharp]
79----
80include::code-snippets/dotnet/MemoryArchitecture.cs[tag=mem,indent=0]
81----
82tab:C++[unsupported]
83--
84
85== Cache Warm-Up Strategy
86
87Ignite does not require you to warm memory up from disk on restarts. As soon as a cluster is inter-connected, your application can query and compute on it. At the same time, the memory warm-up feature is designed for low-latency applications that prefer data being loaded in memory before it can be queried.
88
89Presently, the Ignite warm-up strategy implies loading data into all or specific data regions of Ignite, starting with indexes, until it runs out of free space. It can be configured both for all regions (by default) or for each region separately.
90
91To warm up all data regions, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
92
93:xmlFile: code-snippets/xml/warm-up-strategy.xml
94:javaFile: {javaCodeDir}/WarmUpStrategy.java
95
96[tabs]
97--
98tab:XML[]
99[source,xml]
100----
101include::{xmlFile}[tag=warm-all-regions,indent=0]
102----
103tab:Java[]
104[source,java]
105----
106include::{javaFile}[tag=warm-all-regions,indent=0]
107----
108tab:C#/.NET[unsupported]
109
110tab:C++[unsupported]
111--
112
113
114To warm up a specific data region, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
115
116
117[tabs]
118--
119tab:XML[]
120[source,xml]
121----
122include::{xmlFile}[tag=warm-specific-region,indent=0]
123----
124tab:Java[]
125[source,java]
126----
127include::{javaFile}[tag=warm-specific-region,indent=0]
128----
129tab:C#/.NET[unsupported]
130
131tab:C++[unsupported]
132--
133
134
135To stop the warm-up for all data regions, pass the configuration parameter `NoOpWarmUpConfiguration` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
136
137
138[tabs]
139--
140tab:XML[]
141[source,xml]
142----
143include::{xmlFile}[tag=disable-all-regions,indent=0]
144----
145tab:Java[]
146[source,java]
147----
148include::{javaFile}[tag=disable-all-regions,indent=0]
149----
150tab:C#/.NET[unsupported]
151
152tab:C++[unsupported]
153--
154
155
156To stop the warm-up for a specific data region, pass the configuration parameter `NoOpWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
157
158[tabs]
159--
160tab:XML[]
161[source,xml]
162----
163include::{xmlFile}[tag=disable-specific-region,indent=0]
164----
165tab:Java[]
166[source,java]
167----
168include::{javaFile}[tag=disable-specific-region,indent=0]
169----
170tab:C#/.NET[unsupported]
171
172tab:C++[unsupported]
173--
174
175
176You can also stop the cache warm-up by using `control.sh` and JMX.
177
178
179To stop the warm-up using control.sh:
180
181[tabs]
182--
183tab:Unix[]
184[source,shell,subs="verbatim,quotes"]
185----
186control.sh --warm-up --stop --yes
187----
188tab:Windows[]
189[source,shell,subs="verbatim,quotes"]
190----
191control.bat --warm-up --stop --yes
192----
193--
194
195
196To stop the warm-up using JMX, use the method:
197
198[source, java]
199----
200org.apache.ignite.mxbean.WarmUpMXBean#stopWarmUp
201----
202
203
204
205
206
207