Skip to content

Commit cf7df76

Browse files
authored
Add "content" tier as new "data_content" role (#62247)
Similar to the work in #60994 where we introduced the `data_hot`, `data_warm`, etc node roles. This introduces a new `data_content` node role to be used for the Content tier. Currently this tier is not used anywhere, but subsequent work will use this tier. Relates to #60848
1 parent 0bfde88 commit cf7df76

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTier.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
import java.util.Set;
2020

2121
/**
22-
* The {@code DataTier} class encapsulates the formalization of the "hot",
23-
* "warm", "cold", and "frozen" tiers as node roles. In contains the roles
24-
* themselves as well as helpers for validation and determining if a node has
25-
* a tier configured.
22+
* The {@code DataTier} class encapsulates the formalization of the "content",
23+
* "hot", "warm", "cold", and "frozen" tiers as node roles. In contains the
24+
* roles themselves as well as helpers for validation and determining if a node
25+
* has a tier configured.
2626
*
2727
* Related:
2828
* {@link org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider}
2929
*/
3030
public class DataTier {
3131

32+
public static final String DATA_CONTENT = "data_content";
3233
public static final String DATA_HOT = "data_hot";
3334
public static final String DATA_WARM = "data_warm";
3435
public static final String DATA_COLD = "data_cold";
@@ -38,7 +39,8 @@ public class DataTier {
3839
* Returns true if the given tier name is a valid tier
3940
*/
4041
public static boolean validTierName(String tierName) {
41-
return DATA_HOT.equals(tierName) ||
42+
return DATA_CONTENT.equals(tierName) ||
43+
DATA_HOT.equals(tierName) ||
4244
DATA_WARM.equals(tierName) ||
4345
DATA_COLD.equals(tierName) ||
4446
DATA_FROZEN.equals(tierName);
@@ -61,6 +63,23 @@ public static boolean isExplicitDataTier(Settings settings) {
6163
return false;
6264
}
6365

66+
public static DiscoveryNodeRole DATA_CONTENT_NODE_ROLE = new DiscoveryNodeRole("data_content", "s") {
67+
@Override
68+
public boolean isEnabledByDefault(final Settings settings) {
69+
return false;
70+
}
71+
72+
@Override
73+
public Setting<Boolean> legacySetting() {
74+
return null;
75+
}
76+
77+
@Override
78+
public boolean canContainData() {
79+
return true;
80+
}
81+
};
82+
6483
public static DiscoveryNodeRole DATA_HOT_NODE_ROLE = new DiscoveryNodeRole("data_hot", "h") {
6584
@Override
6685
public boolean isEnabledByDefault(final Settings settings) {
@@ -129,6 +148,10 @@ public boolean canContainData() {
129148
}
130149
};
131150

151+
public static boolean isContentNode(DiscoveryNode discoveryNode) {
152+
return discoveryNode.getRoles().contains(DATA_CONTENT_NODE_ROLE) || discoveryNode.getRoles().contains(DiscoveryNodeRole.DATA_ROLE);
153+
}
154+
132155
public static boolean isHotNode(DiscoveryNode discoveryNode) {
133156
return discoveryNode.getRoles().contains(DATA_HOT_NODE_ROLE) || discoveryNode.getRoles().contains(DiscoveryNodeRole.DATA_ROLE);
134157
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ public List<Setting<?>> getSettings() {
379379
@Override
380380
public Set<DiscoveryNodeRole> getRoles() {
381381
return new HashSet<>(Arrays.asList(
382+
DataTier.DATA_CONTENT_NODE_ROLE,
382383
DataTier.DATA_HOT_NODE_ROLE,
383384
DataTier.DATA_WARM_NODE_ROLE,
384385
DataTier.DATA_COLD_NODE_ROLE,

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/DataTierTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public void testNodeSelection() {
4040
.map(DiscoveryNode::getId)
4141
.toArray(String[]::new);
4242

43+
final String[] contentNodes =
44+
StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false)
45+
.map(n -> n.value)
46+
.filter(DataTier::isContentNode)
47+
.map(DiscoveryNode::getId)
48+
.toArray(String[]::new);
49+
4350
final String[] hotNodes =
4451
StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false)
4552
.map(n -> n.value)
@@ -69,11 +76,13 @@ public void testNodeSelection() {
6976
.toArray(String[]::new);
7077

7178
assertThat(discoveryNodes.resolveNodes("data:true"), arrayContainingInAnyOrder(dataNodes));
79+
assertThat(discoveryNodes.resolveNodes("data_content:true"), arrayContainingInAnyOrder(contentNodes));
7280
assertThat(discoveryNodes.resolveNodes("data_hot:true"), arrayContainingInAnyOrder(hotNodes));
7381
assertThat(discoveryNodes.resolveNodes("data_warm:true"), arrayContainingInAnyOrder(warmNodes));
7482
assertThat(discoveryNodes.resolveNodes("data_cold:true"), arrayContainingInAnyOrder(coldNodes));
7583
assertThat(discoveryNodes.resolveNodes("data_frozen:true"), arrayContainingInAnyOrder(frozenNodes));
76-
Set<String> allTiers = new HashSet<>(Arrays.asList(hotNodes));
84+
Set<String> allTiers = new HashSet<>(Arrays.asList(contentNodes));
85+
allTiers.addAll(Arrays.asList(hotNodes));
7786
allTiers.addAll(Arrays.asList(warmNodes));
7887
allTiers.addAll(Arrays.asList(coldNodes));
7988
allTiers.addAll(Arrays.asList(frozenNodes));
@@ -100,6 +109,7 @@ private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes,
100109
private static List<DiscoveryNode> randomNodes(final int numNodes) {
101110
Set<DiscoveryNodeRole> allRoles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES);
102111
allRoles.remove(DiscoveryNodeRole.DATA_ROLE);
112+
allRoles.add(DataTier.DATA_CONTENT_NODE_ROLE);
103113
allRoles.add(DataTier.DATA_HOT_NODE_ROLE);
104114
allRoles.add(DataTier.DATA_WARM_NODE_ROLE);
105115
allRoles.add(DataTier.DATA_COLD_NODE_ROLE);

0 commit comments

Comments
 (0)