diff options
author | Simon Willnauer <simonw@apache.org> | 2017-07-05 22:18:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-05 22:18:23 +0200 |
commit | 6e5cc424a81f27ef3a15ab9bb2d8b158f0b6b9a9 (patch) | |
tree | ad109bb81c0b47f6d9534b6a0bd590c7f9baf2cf /test | |
parent | 26de905f1e53d556087131a26792ff8a57aa45f2 (diff) |
Switch indices read-only if a node runs out of disk space (#25541)test
Today when we run out of disk all kinds of crazy things can happen
and nodes are becoming hard to maintain once out of disk is hit.
While we try to move shards away if we hit watermarks this might not
be possible in many situations. Based on the discussion in #24299
this change monitors disk utilization and adds a flood-stage watermark
that causes all indices that are allocated on a node hitting the flood-stage
mark to be switched read-only (with the option to be deleted). This allows users to react on the low disk
situation while subsequent write requests will be rejected. Users can switch
individual indices read-write once the situation is sorted out. There is no
automatic read-write switch once the node has enough space. This requires
user interaction.
The flood-stage watermark is set to `95%` utilization by default.
Closes #24299
Diffstat (limited to 'test')
-rw-r--r-- | test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java | 6 | ||||
-rw-r--r-- | test/framework/src/main/java/org/elasticsearch/node/MockNode.java | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java index fc45578357..4f6e8bb192 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java @@ -21,6 +21,7 @@ package org.elasticsearch.cluster; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.CountDownLatch; +import java.util.function.Consumer; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; @@ -69,8 +70,9 @@ public class MockInternalClusterInfoService extends InternalClusterInfoService { null, null, null); } - public MockInternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client) { - super(settings, clusterService, threadPool, client); + public MockInternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client, + Consumer<ClusterInfo> listener) { + super(settings, clusterService, threadPool, client, listener); this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); stats[0] = makeStats("node_t1", new DiskUsage("node_t1", "n1", "/dev/null", 100, 100)); stats[1] = makeStats("node_t2", new DiskUsage("node_t2", "n2", "/dev/null", 100, 100)); diff --git a/test/framework/src/main/java/org/elasticsearch/node/MockNode.java b/test/framework/src/main/java/org/elasticsearch/node/MockNode.java index 6195838501..2e0aa98a92 100644 --- a/test/framework/src/main/java/org/elasticsearch/node/MockNode.java +++ b/test/framework/src/main/java/org/elasticsearch/node/MockNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.node; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.cluster.ClusterInfo; import org.elasticsearch.cluster.ClusterInfoService; import org.elasticsearch.cluster.MockInternalClusterInfoService; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -47,6 +48,7 @@ import org.elasticsearch.transport.TransportService; import java.nio.file.Path; import java.util.Collection; import java.util.Collections; +import java.util.function.Consumer; import java.util.function.Function; /** @@ -124,11 +126,11 @@ public class MockNode extends Node { @Override protected ClusterInfoService newClusterInfoService(Settings settings, ClusterService clusterService, - ThreadPool threadPool, NodeClient client) { + ThreadPool threadPool, NodeClient client, Consumer<ClusterInfo> listener) { if (getPluginsService().filterPlugins(MockInternalClusterInfoService.TestPlugin.class).isEmpty()) { - return super.newClusterInfoService(settings, clusterService, threadPool, client); + return super.newClusterInfoService(settings, clusterService, threadPool, client, listener); } else { - return new MockInternalClusterInfoService(settings, clusterService, threadPool, client); + return new MockInternalClusterInfoService(settings, clusterService, threadPool, client, listener); } } } |