apache-ignite

Форк
0
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
18
Ignite 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

20
By 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

26
See 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

30
By 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
--
38
tab:XML[]
39

40
[source,xml]
41
----
42
include::{xmlFile}[tags=!*;ignite-config;default;!discovery,indent=0]
43
----
44
tab:Java[]
45
[source,java]
46
----
47
include::{javaFile}[tags=!*;ignite-config;default,indent=0]
48
----
49
tab:C#/.NET[]
50
[source,csharp]
51
----
52
include::code-snippets/dotnet/MemoryArchitecture.cs[tag=DefaultDataReqion,indent=0]
53
----
54
tab:C++[unsupported]
55
--
56

57
== Adding Custom Data Regions
58

59
In addition to the default data region, you can add more data regions with custom settings.
60
In 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.
61
Note that further below in the configuration, we create a cache that resides in the new data region.
62

63
[tabs]
64
--
65
tab:XML[]
66
[source,xml]
67
----
68
include::{xmlFile}[tags=!*;ignite-config;data-region;default;caches;!discovery,indent=0]
69
----
70

71
For the full list of properties, refer to the link:{javadoc_base_url}/org/apache/ignite/configuration/DataStorageConfiguration.html[DataStorageConfiguration] javadoc.
72
tab:Java[]
73
[source,java]
74
----
75
include::{javaFile}[tags=ignite-config,indent=0]
76
----
77
tab:C#/.NET[]
78
[source,csharp]
79
----
80
include::code-snippets/dotnet/MemoryArchitecture.cs[tag=mem,indent=0]
81
----
82
tab:C++[unsupported]
83
--
84

85
== Cache Warm-Up Strategy
86

87
Ignite 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

89
Presently, 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

91
To 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
--
98
tab:XML[]
99
[source,xml]
100
----
101
include::{xmlFile}[tag=warm-all-regions,indent=0]
102
----
103
tab:Java[]
104
[source,java]
105
----
106
include::{javaFile}[tag=warm-all-regions,indent=0]
107
----
108
tab:C#/.NET[unsupported]
109

110
tab:C++[unsupported]
111
--
112

113

114
To warm up a specific data region, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
115

116

117
[tabs]
118
--
119
tab:XML[]
120
[source,xml]
121
----
122
include::{xmlFile}[tag=warm-specific-region,indent=0]
123
----
124
tab:Java[]
125
[source,java]
126
----
127
include::{javaFile}[tag=warm-specific-region,indent=0]
128
----
129
tab:C#/.NET[unsupported]
130

131
tab:C++[unsupported]
132
--
133

134

135
To stop the warm-up for all data regions, pass the configuration parameter `NoOpWarmUpConfiguration` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
136

137

138
[tabs]
139
--
140
tab:XML[]
141
[source,xml]
142
----
143
include::{xmlFile}[tag=disable-all-regions,indent=0]
144
----
145
tab:Java[]
146
[source,java]
147
----
148
include::{javaFile}[tag=disable-all-regions,indent=0]
149
----
150
tab:C#/.NET[unsupported]
151

152
tab:C++[unsupported]
153
--
154

155

156
To stop the warm-up for a specific data region, pass the configuration parameter `NoOpWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
157

158
[tabs]
159
--
160
tab:XML[]
161
[source,xml]
162
----
163
include::{xmlFile}[tag=disable-specific-region,indent=0]
164
----
165
tab:Java[]
166
[source,java]
167
----
168
include::{javaFile}[tag=disable-specific-region,indent=0]
169
----
170
tab:C#/.NET[unsupported]
171

172
tab:C++[unsupported]
173
--
174

175

176
You can also stop the cache warm-up by using `control.sh` and JMX.
177

178

179
To stop the warm-up using control.sh:
180

181
[tabs]
182
--
183
tab:Unix[]
184
[source,shell,subs="verbatim,quotes"]
185
----
186
control.sh --warm-up --stop --yes
187
----
188
tab:Windows[]
189
[source,shell,subs="verbatim,quotes"]
190
----
191
control.bat --warm-up --stop --yes
192
----
193
--
194

195

196
To stop the warm-up using JMX, use the method:
197

198
[source, java]
199
----
200
org.apache.ignite.mxbean.WarmUpMXBean#stopWarmUp
201
----
202

203

204

205

206

207

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.