Skip to content

Commit 4cde80b

Browse files
Nikita-tech-writerMmuzaf
authored andcommitted
IGNITE-13385 Fixed documentation pages for cache warm-up strategy examples (#8703)
1 parent 5176390 commit 4cde80b

3 files changed

Lines changed: 229 additions & 22 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
//tag::warm-all-regions[]
18+
IgniteConfiguration cfg = new IgniteConfiguration();
19+
20+
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
21+
22+
//Changing the default warm-up strategy for all data regions
23+
storageCfg.setDefaultWarmUpConfiguration(new LoadAllWarmUpConfiguration());
24+
25+
cfg.setDataStorageConfiguration(storageCfg);
26+
//end::warm-all-regions[]
27+
//tag::warm-specific-region[]
28+
IgniteConfiguration cfg = new IgniteConfiguration();
29+
30+
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
31+
32+
//Setting another warm-up strategy for a custom data region
33+
DataRegionConfiguration myNewDataRegion = new DataRegionConfiguration();
34+
35+
myNewDataRegion.setName("NewDataRegion");
36+
37+
//You can tweak the initial size as well as other settings
38+
myNewDataRegion.setInitialSize(100 * 1024 * 1024);
39+
40+
//Performing data loading from disk in DRAM on restarts.
41+
myNewDataRegion.setWarmUpConfiguration(new LoadAllWarmUpConfiguration());
42+
43+
//Enabling Ignite persistence. Ignite reads data from disk when queried for tables/caches from this region.
44+
myNewDataRegion.setPersistenceEnabled(true);
45+
46+
//Applying the configuration.
47+
storageCfg.setDataRegionConfigurations(myNewDataRegion);
48+
49+
cfg.setDataStorageConfiguration(storageCfg);
50+
//end::warm-specific-region[]
51+
//tag::disable-all-regions[]
52+
IgniteConfiguration cfg = new IgniteConfiguration();
53+
54+
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
55+
56+
storageCfg.setDefaultWarmUpConfiguration(new NoOpWarmUpConfiguration());
57+
58+
cfg.setDataStorageConfiguration(storageCfg);
59+
//end::disable-all-regions[]
60+
//tag::disable-specific-region[]
61+
IgniteConfiguration cfg = new IgniteConfiguration();
62+
63+
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
64+
65+
//Setting another warm-up strategy for a custom data region
66+
DataRegionConfiguration myNewDataRegion = new DataRegionConfiguration();
67+
68+
myNewDataRegion.setName("NewDataRegion");
69+
70+
//You can tweak the initial size as well as other settings
71+
myNewDataRegion.setInitialSize(100 * 1024 * 1024);
72+
73+
//Skip data loading from disk in DRAM on restarts.
74+
myNewDataRegion.setWarmUpConfiguration(new NoOpWarmUpConfiguration());
75+
76+
//Enabling Ignite persistence. Ignite reads data from disk when queried for tables/caches from this region.
77+
myNewDataRegion.setPersistenceEnabled(true);
78+
79+
//Applying the configuration.
80+
storageCfg.setDataRegionConfigurations(myNewDataRegion);
81+
82+
cfg.setDataStorageConfiguration(storageCfg);
83+
//end::disable-specific-region[]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<!-- tag::warm-all-regions[] -->
19+
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
20+
<property name="dataStorageConfiguration">
21+
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
22+
<property name="defaultWarmUpConfiguration">
23+
<bean class="org.apache.ignite.configuration.LoadAllWarmUpConfiguration"/>
24+
</property>
25+
</bean>
26+
</property>
27+
</bean>
28+
<!-- end::warm-all-regions[] -->
29+
<!-- tag::warm-specific-region[] -->
30+
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
31+
<property name="dataStorageConfiguration">
32+
<property name="dataRegionConfigurations">
33+
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
34+
<property name="name" value="NewDataRegion"/>
35+
<property name="initialSize" value="#{100 * 1024 * 1024}"/>
36+
<property name="persistenceEnabled" value="true"/>
37+
<property name="warmUpConfiguration">
38+
<bean class="org.apache.ignite.configuration.LoadAllWarmUpConfiguration"/>
39+
</property>
40+
</bean>
41+
</property>
42+
</property>
43+
</bean>
44+
<!-- end::warm-specific-region[] -->
45+
<!-- tag::disable-all-regions[] -->
46+
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
47+
<property name="dataStorageConfiguration">
48+
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
49+
<property name="defaultWarmUpConfiguration">
50+
<bean class="org.apache.ignite.configuration.NoOpWarmUpConfiguration"/>
51+
</property>
52+
</bean>
53+
</property>
54+
</bean>
55+
<!-- end::disable-all-regions[] -->
56+
<!-- tag::disable-specific-region[] -->
57+
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
58+
<property name="dataStorageConfiguration">
59+
<property name="dataRegionConfigurations">
60+
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
61+
<property name="name" value="NewDataRegion"/>
62+
<property name="initialSize" value="#{100 * 1024 * 1024}"/>
63+
<property name="persistenceEnabled" value="true"/>
64+
<property name="warmUpConfiguration">
65+
<bean class="org.apache.ignite.configuration.NoOpWarmUpConfiguration"/>
66+
</property>
67+
</bean>
68+
</property>
69+
</property>
70+
</bean>
71+
<!-- end::disable-specific-region[] -->

docs/_docs/memory-configuration/data-regions.adoc

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,51 +84,103 @@ tab:C++[unsupported]
8484

8585
== Cache Warm-Up Strategy
8686

87-
The cache warm-up strategy provides an ability to load data from the disk to the node before it is joined to the cluster.
88-
This prevents performance loss when the node is restarted.
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.
8988

90-
[NOTE]
91-
====
92-
The cache warm-up strategy is applicable only to the data regions. It can be configured both for all regions (by default) or for each region separately.
93-
====
94-
95-
Presently, Ignite warm-up strategy implies loading data into the region, starting with indexes, until it runs out of free space.
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.
9690

9791
To warm up all data regions, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
9892

99-
[source, java]
93+
:xmlFile: code-snippets/xml/warm-up-strategy.xml
94+
:javaFile: {javaCodeDir}/WarmUpStrategy.java
95+
96+
[tabs]
97+
--
98+
tab:XML[]
99+
[source,xml]
100100
----
101-
setDefaultWarmUpConfiguration(loadAllWarmUpStrategy)
101+
include::{xmlFile}[tag=warm-all-regions,indent=0]
102102
----
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+
103113

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

106-
[source, java]
116+
117+
[tabs]
118+
--
119+
tab:XML[]
120+
[source,xml]
121+
----
122+
include::{xmlFile}[tag=warm-specific-region,indent=0]
107123
----
108-
setWarmUpConfiguration(loadAllWarmUpStrategy)
124+
tab:Java[]
125+
[source,java]
109126
----
127+
include::{javaFile}[tag=warm-specific-region,indent=0]
128+
----
129+
tab:C#/.NET[unsupported]
110130

111-
To stop warming up all data regions, pass the configuration parameter `NoOpWarmUpStrategy` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
131+
tab:C++[unsupported]
132+
--
112133

113-
[source, java]
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]
114142
----
115-
setDefaultWarmUpConfiguration(noOpWarmUpStrategy)
143+
include::{xmlFile}[tag=disable-all-regions,indent=0]
116144
----
145+
tab:Java[]
146+
[source,java]
147+
----
148+
include::{javaFile}[tag=disable-all-regions,indent=0]
149+
----
150+
tab:C#/.NET[unsupported]
117151

118-
To stop warming up a specific data region, pass the configuration parameter `NoOpWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
152+
tab:C++[unsupported]
153+
--
119154

120-
[source, java]
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]
121167
----
122-
setWarmUpConfiguration(noOpWarmUpStrategy)
168+
include::{javaFile}[tag=disable-specific-region,indent=0]
123169
----
170+
tab:C#/.NET[unsupported]
171+
172+
tab:C++[unsupported]
173+
--
124174

125-
You can also stop the cache warming up process by using `control.sh` and JMX.
126175

127-
To stop the warming up using control.sh:
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:
128180

129181
[tabs]
130182
--
131-
tab:Linux[]
183+
tab:Unix[]
132184
[source,shell,subs="verbatim,quotes"]
133185
----
134186
control.sh --warm-up --stop --yes
@@ -140,7 +192,8 @@ control.bat --warm-up --stop --yes
140192
----
141193
--
142194

143-
To stop the warming up using JMX, use the method below:
195+
196+
To stop the warm-up using JMX, use the method:
144197

145198
[source, java]
146199
----

0 commit comments

Comments
 (0)