|
@@ -42,10 +42,8 @@ import org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
-import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
import static org.elasticsearch.xpack.core.DataTier.DATA_COLD;
|
|
|
import static org.elasticsearch.xpack.core.DataTier.DATA_FROZEN;
|
|
@@ -54,7 +52,6 @@ import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
|
public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
|
|
|
- public static final Set<Setting<?>> ALL_SETTINGS;
|
|
|
private static final DiscoveryNode HOT_NODE = newNode("node-hot", Collections.singleton(DiscoveryNodeRole.DATA_HOT_NODE_ROLE));
|
|
|
private static final DiscoveryNode WARM_NODE = newNode("node-warm", Collections.singleton(DiscoveryNodeRole.DATA_WARM_NODE_ROLE));
|
|
|
private static final DiscoveryNode COLD_NODE = newNode("node-cold", Collections.singleton(DiscoveryNodeRole.DATA_COLD_NODE_ROLE));
|
|
@@ -62,8 +59,8 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
newNode("node-content", Collections.singleton(DiscoveryNodeRole.DATA_CONTENT_NODE_ROLE));
|
|
|
private static final DiscoveryNode DATA_NODE = newNode("node-data", Collections.singleton(DiscoveryNodeRole.DATA_ROLE));
|
|
|
|
|
|
- private final ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ALL_SETTINGS);
|
|
|
- private final DataTierAllocationDecider decider = new DataTierAllocationDecider(Settings.EMPTY, clusterSettings);
|
|
|
+ private final ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
|
|
+ private final DataTierAllocationDecider decider = new DataTierAllocationDecider();
|
|
|
private final AllocationDeciders allocationDeciders = new AllocationDeciders(
|
|
|
Arrays.asList(decider,
|
|
|
new SameShardAllocationDecider(Settings.EMPTY, clusterSettings),
|
|
@@ -75,219 +72,6 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
private final ShardRouting shard = ShardRouting.newUnassigned(new ShardId("myindex", "myindex", 0), true,
|
|
|
RecoverySource.EmptyStoreRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "index created"));
|
|
|
|
|
|
- static {
|
|
|
- Set<Setting<?>> allSettings = new HashSet<>(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
|
|
- allSettings.add(DataTierAllocationDecider.CLUSTER_ROUTING_REQUIRE_SETTING);
|
|
|
- allSettings.add(DataTierAllocationDecider.CLUSTER_ROUTING_INCLUDE_SETTING);
|
|
|
- allSettings.add(DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE_SETTING);
|
|
|
- ALL_SETTINGS = allSettings;
|
|
|
- }
|
|
|
-
|
|
|
- public void testClusterRequires() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"));
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- clusterSettings.applySettings(Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.CLUSTER_ROUTING_REQUIRE, "data_hot")
|
|
|
- .build());
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match all cluster setting [cluster.routing.allocation.require._tier] " +
|
|
|
- "tier filters [data_hot]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match all cluster setting [cluster.routing.allocation.require._tier] " +
|
|
|
- "tier filters [data_hot]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testClusterIncludes() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"));
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- clusterSettings.applySettings(Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.CLUSTER_ROUTING_INCLUDE, "data_warm,data_cold")
|
|
|
- .build());
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any cluster setting [cluster.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any cluster setting [cluster.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public void testClusterExcludes() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"));
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- clusterSettings.applySettings(Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE, "data_warm")
|
|
|
- .build());
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_warm]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_warm]"));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testIndexRequires() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"),
|
|
|
- Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_REQUIRE, "data_hot")
|
|
|
- .build());
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match all index setting [index.routing.allocation.require._tier] tier filters [data_hot]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match all index setting [index.routing.allocation.require._tier] tier filters [data_hot]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testIndexIncludes() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"),
|
|
|
- Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE, "data_warm,data_cold")
|
|
|
- .build());
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testIndexExcludes() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"),
|
|
|
- Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE, "data_warm,data_cold")
|
|
|
- .build());
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null,0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE, COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void testIndexPrefer() {
|
|
|
ClusterState state = ClusterState.builder(service.reroute(ClusterState.EMPTY_STATE, "initial state"))
|
|
|
.nodes(DiscoveryNodes.builder()
|
|
@@ -369,241 +153,6 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void testIndexPreferWithInclude() {
|
|
|
- ClusterState state = ClusterState.builder(service.reroute(ClusterState.EMPTY_STATE, "initial state"))
|
|
|
- .nodes(DiscoveryNodes.builder()
|
|
|
- .add(WARM_NODE)
|
|
|
- .add(COLD_NODE)
|
|
|
- .build())
|
|
|
- .metadata(Metadata.builder()
|
|
|
- .put(IndexMetadata.builder("myindex")
|
|
|
- .settings(Settings.builder()
|
|
|
- .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
|
|
|
- .put(IndexMetadata.SETTING_INDEX_UUID, "myindex")
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE, "data_cold")
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, "data_warm,data_cold")
|
|
|
- .build()))
|
|
|
- .build())
|
|
|
- .build();
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, WARM_NODE, CONTENT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] tier filters [data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] tier filters [data_cold]"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testIndexPreferWithExclude() {
|
|
|
- ClusterState state = ClusterState.builder(service.reroute(ClusterState.EMPTY_STATE, "initial state"))
|
|
|
- .nodes(DiscoveryNodes.builder()
|
|
|
- .add(WARM_NODE)
|
|
|
- .add(COLD_NODE)
|
|
|
- .build())
|
|
|
- .metadata(Metadata.builder()
|
|
|
- .put(IndexMetadata.builder("myindex")
|
|
|
- .settings(Settings.builder()
|
|
|
- .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
|
|
|
- .put(IndexMetadata.SETTING_INDEX_UUID, "myindex")
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE, "data_warm")
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, "data_warm,data_cold")
|
|
|
- .build()))
|
|
|
- .build())
|
|
|
- .build();
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, COLD_NODE, CONTENT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] tier filters [data_warm]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] tier filters [data_warm]"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] tier filters [data_warm]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node matches any index setting [index.routing.allocation.exclude._tier] tier filters [data_warm]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testIndexPreferWithRequire() {
|
|
|
- ClusterState state = ClusterState.builder(service.reroute(ClusterState.EMPTY_STATE, "initial state"))
|
|
|
- .nodes(DiscoveryNodes.builder()
|
|
|
- .add(WARM_NODE)
|
|
|
- .add(COLD_NODE)
|
|
|
- .build())
|
|
|
- .metadata(Metadata.builder()
|
|
|
- .put(IndexMetadata.builder("myindex")
|
|
|
- .settings(Settings.builder()
|
|
|
- .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
|
|
|
- .put(IndexMetadata.SETTING_INDEX_UUID, "myindex")
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_REQUIRE, "data_cold")
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, "data_warm,data_cold")
|
|
|
- .build()))
|
|
|
- .build())
|
|
|
- .build();
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, WARM_NODE, CONTENT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match all index setting [index.routing.allocation.require._tier] tier filters [data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match all index setting [index.routing.allocation.require._tier] tier filters [data_cold]"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(COLD_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] " +
|
|
|
- "and node does not meet the required [data_warm] tier"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void testClusterAndIndex() {
|
|
|
- ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"),
|
|
|
- Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.INDEX_ROUTING_INCLUDE, "data_warm,data_cold")
|
|
|
- .build());
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state,
|
|
|
- null, null,0);
|
|
|
- clusterSettings.applySettings(Settings.builder()
|
|
|
- .put(DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE, "data_cold")
|
|
|
- .build());
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(node.toString(), d.getExplanation(),
|
|
|
- containsString("node does not match any index setting [index.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_warm,data_cold]"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(DATA_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] tier filters [data_cold]"));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(node.toString(), d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] tier filters [data_cold]"));
|
|
|
- }
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(WARM_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = decider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = decider.canRemain(shard, node, allocation);
|
|
|
- assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public void testTierNodesPresent() {
|
|
|
DiscoveryNodes nodes = DiscoveryNodes.builder().build();
|
|
|
|
|
@@ -658,60 +207,6 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
equalTo(Optional.of("data_warm")));
|
|
|
}
|
|
|
|
|
|
- public void testExistedClusterFilters() {
|
|
|
- Settings existedSettings = Settings.builder()
|
|
|
- .put("cluster.routing.allocation.include._tier", "data_hot,data_warm")
|
|
|
- .put("cluster.routing.allocation.exclude._tier", "data_cold")
|
|
|
- .build();
|
|
|
- ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ALL_SETTINGS);
|
|
|
- DataTierAllocationDecider dataTierAllocationDecider = new DataTierAllocationDecider(existedSettings, clusterSettings);
|
|
|
- AllocationDeciders allocationDeciders = new AllocationDeciders(
|
|
|
- List.of(dataTierAllocationDecider));
|
|
|
- AllocationService service = new AllocationService(allocationDeciders,
|
|
|
- new TestGatewayAllocator(), new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE,
|
|
|
- EmptySnapshotsInfoService.INSTANCE);
|
|
|
-
|
|
|
- ClusterState clusterState = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"));
|
|
|
-
|
|
|
- RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState.getRoutingNodes(), clusterState,
|
|
|
- null, null, 0);
|
|
|
- allocation.debugDecision(true);
|
|
|
- Decision d;
|
|
|
- RoutingNode node;
|
|
|
-
|
|
|
- for (DiscoveryNode n : Arrays.asList(HOT_NODE, WARM_NODE)) {
|
|
|
- node = new RoutingNode(n.getId(), n, shard);
|
|
|
- d = dataTierAllocationDecider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- d = dataTierAllocationDecider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.YES));
|
|
|
- }
|
|
|
-
|
|
|
- node = new RoutingNode(DATA_NODE.getId(), DATA_NODE, shard);
|
|
|
- d = dataTierAllocationDecider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_cold]"));
|
|
|
- d = dataTierAllocationDecider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node matches any cluster setting [cluster.routing.allocation.exclude._tier] " +
|
|
|
- "tier filters [data_cold]"));
|
|
|
-
|
|
|
- node = new RoutingNode(COLD_NODE.getId(), COLD_NODE, shard);
|
|
|
- d = dataTierAllocationDecider.canAllocate(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any cluster setting [cluster.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_hot,data_warm]"));
|
|
|
- d = dataTierAllocationDecider.canRemain(shard, node, allocation);
|
|
|
- assertThat(d.type(), equalTo(Decision.Type.NO));
|
|
|
- assertThat(d.getExplanation(),
|
|
|
- containsString("node does not match any cluster setting [cluster.routing.allocation.include._tier] " +
|
|
|
- "tier filters [data_hot,data_warm]"));
|
|
|
- }
|
|
|
-
|
|
|
public void testFrozenIllegalForRegularIndices() {
|
|
|
List<String> tierList = new ArrayList<>(randomSubsetOf(DataTier.ALL_DATA_TIERS));
|
|
|
if (tierList.contains(DATA_FROZEN) == false) {
|
|
@@ -720,7 +215,7 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
Randomness.shuffle(tierList);
|
|
|
|
|
|
String value = Strings.join(tierList, ",");
|
|
|
- Setting<String> setting = randomTierSetting();
|
|
|
+ Setting<String> setting = DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING;
|
|
|
Settings.Builder builder = Settings.builder().put(setting.getKey(), value);
|
|
|
if (randomBoolean()) {
|
|
|
builder.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY);
|
|
@@ -732,7 +227,7 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
}
|
|
|
|
|
|
public void testFrozenLegalForPartialSnapshot() {
|
|
|
- Setting<String> setting = randomTierSetting();
|
|
|
+ Setting<String> setting = DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING;
|
|
|
Settings.Builder builder = Settings.builder().put(setting.getKey(), DATA_FROZEN);
|
|
|
builder.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY);
|
|
|
builder.put(SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING.getKey(), true);
|
|
@@ -803,15 +298,6 @@ public class DataTierAllocationDeciderTests extends ESAllocationTestCase {
|
|
|
assertThat(DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING.get(settings), equalTo(DATA_FROZEN));
|
|
|
}
|
|
|
|
|
|
- public Setting<String> randomTierSetting() {
|
|
|
- //noinspection unchecked
|
|
|
- return randomFrom(
|
|
|
- DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING,
|
|
|
- DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING,
|
|
|
- DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING,
|
|
|
- DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING);
|
|
|
- }
|
|
|
-
|
|
|
private ClusterState prepareState(ClusterState initialState) {
|
|
|
return prepareState(initialState, Settings.EMPTY);
|
|
|
}
|