converted index.routing.allocation.total_shards_per_node
This commit is contained in:
parent
3902ea439d
commit
cfffa48d91
|
@ -160,7 +160,6 @@ public class ClusterModule extends AbstractModule {
|
||||||
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE, Validator.TIME);
|
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE, Validator.TIME);
|
||||||
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_REFORMAT, Validator.EMPTY);
|
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_REFORMAT, Validator.EMPTY);
|
||||||
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_LEVEL, Validator.EMPTY);
|
registerIndexDynamicSetting(SearchSlowLog.INDEX_SEARCH_SLOWLOG_LEVEL, Validator.EMPTY);
|
||||||
registerIndexDynamicSetting(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE, Validator.INTEGER);
|
|
||||||
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_EXPUNGE_DELETES_ALLOWED, Validator.DOUBLE);
|
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_EXPUNGE_DELETES_ALLOWED, Validator.DOUBLE);
|
||||||
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_FLOOR_SEGMENT, Validator.BYTES_SIZE);
|
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_FLOOR_SEGMENT, Validator.BYTES_SIZE);
|
||||||
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE, Validator.INTEGER_GTE_2);
|
registerIndexDynamicSetting(MergePolicyConfig.INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE, Validator.INTEGER_GTE_2);
|
||||||
|
|
|
@ -32,12 +32,12 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
/**
|
/**
|
||||||
* This {@link AllocationDecider} limits the number of shards per node on a per
|
* This {@link AllocationDecider} limits the number of shards per node on a per
|
||||||
* index or node-wide basis. The allocator prevents a single node to hold more
|
* index or node-wide basis. The allocator prevents a single node to hold more
|
||||||
* than {@value #INDEX_TOTAL_SHARDS_PER_NODE} per index and
|
* than <tt>index.routing.allocation.total_shards_per_node</tt> per index and
|
||||||
* <tt>cluster.routing.allocation.total_shards_per_node</tt> globally during the allocation
|
* <tt>cluster.routing.allocation.total_shards_per_node</tt> globally during the allocation
|
||||||
* process. The limits of this decider can be changed in real-time via a the
|
* process. The limits of this decider can be changed in real-time via a the
|
||||||
* index settings API.
|
* index settings API.
|
||||||
* <p>
|
* <p>
|
||||||
* If {@value #INDEX_TOTAL_SHARDS_PER_NODE} is reset to a negative value shards
|
* If <tt>index.routing.allocation.total_shards_per_node</tt> is reset to a negative value shards
|
||||||
* per index are unlimited per node. Shards currently in the
|
* per index are unlimited per node. Shards currently in the
|
||||||
* {@link ShardRoutingState#RELOCATING relocating} state are ignored by this
|
* {@link ShardRoutingState#RELOCATING relocating} state are ignored by this
|
||||||
* {@link AllocationDecider} until the shard changed its state to either
|
* {@link AllocationDecider} until the shard changed its state to either
|
||||||
|
@ -59,12 +59,13 @@ public class ShardsLimitAllocationDecider extends AllocationDecider {
|
||||||
* Controls the maximum number of shards per index on a single Elasticsearch
|
* Controls the maximum number of shards per index on a single Elasticsearch
|
||||||
* node. Negative values are interpreted as unlimited.
|
* node. Negative values are interpreted as unlimited.
|
||||||
*/
|
*/
|
||||||
public static final String INDEX_TOTAL_SHARDS_PER_NODE = "index.routing.allocation.total_shards_per_node";
|
public static final Setting<Integer> INDEX_TOTAL_SHARDS_PER_NODE_SETTING = Setting.intSetting("index.routing.allocation.total_shards_per_node", -1, -1, true, Setting.Scope.INDEX);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the maximum number of shards per node on a global level.
|
* Controls the maximum number of shards per node on a global level.
|
||||||
* Negative values are interpreted as unlimited.
|
* Negative values are interpreted as unlimited.
|
||||||
*/
|
*/
|
||||||
public static final Setting<Integer> CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING = Setting.intSetting("cluster.routing.allocation.total_shards_per_node", -1, true, Setting.Scope.CLUSTER);
|
public static final Setting<Integer> CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING = Setting.intSetting("cluster.routing.allocation.total_shards_per_node", -1, -1, true, Setting.Scope.CLUSTER);
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -81,7 +82,7 @@ public class ShardsLimitAllocationDecider extends AllocationDecider {
|
||||||
@Override
|
@Override
|
||||||
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||||
IndexMetaData indexMd = allocation.routingNodes().metaData().index(shardRouting.index());
|
IndexMetaData indexMd = allocation.routingNodes().metaData().index(shardRouting.index());
|
||||||
int indexShardLimit = indexMd.getSettings().getAsInt(INDEX_TOTAL_SHARDS_PER_NODE, -1);
|
final int indexShardLimit = INDEX_TOTAL_SHARDS_PER_NODE_SETTING.get(indexMd.getSettings()); // TODO this sucks as it's not taking the node level setting into account
|
||||||
// Capture the limit here in case it changes during this method's
|
// Capture the limit here in case it changes during this method's
|
||||||
// execution
|
// execution
|
||||||
final int clusterShardLimit = this.clusterShardLimit;
|
final int clusterShardLimit = this.clusterShardLimit;
|
||||||
|
@ -118,7 +119,7 @@ public class ShardsLimitAllocationDecider extends AllocationDecider {
|
||||||
@Override
|
@Override
|
||||||
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||||
IndexMetaData indexMd = allocation.routingNodes().metaData().index(shardRouting.index());
|
IndexMetaData indexMd = allocation.routingNodes().metaData().index(shardRouting.index());
|
||||||
int indexShardLimit = indexMd.getSettings().getAsInt(INDEX_TOTAL_SHARDS_PER_NODE, -1);
|
final int indexShardLimit = INDEX_TOTAL_SHARDS_PER_NODE_SETTING.get(indexMd.getSettings()); // TODO this sucks as it's not taking the node level setting into account
|
||||||
// Capture the limit here in case it changes during this method's
|
// Capture the limit here in case it changes during this method's
|
||||||
// execution
|
// execution
|
||||||
final int clusterShardLimit = this.clusterShardLimit;
|
final int clusterShardLimit = this.clusterShardLimit;
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index;
|
||||||
import org.apache.lucene.index.MergePolicy;
|
import org.apache.lucene.index.MergePolicy;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
|
@ -119,7 +120,8 @@ public final class IndexSettings {
|
||||||
IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING,
|
IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING,
|
||||||
IndexSettings.INDEX_WARMER_ENABLED_SETTING,
|
IndexSettings.INDEX_WARMER_ENABLED_SETTING,
|
||||||
IndexSettings.INDEX_REFRESH_INTERVAL_SETTING,
|
IndexSettings.INDEX_REFRESH_INTERVAL_SETTING,
|
||||||
IndexSettings.MAX_RESULT_WINDOW_SETTING
|
IndexSettings.MAX_RESULT_WINDOW_SETTING,
|
||||||
|
ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||||
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)
|
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||||
.put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE, 2)))
|
.put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 2)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RoutingTable routingTable = RoutingTable.builder()
|
RoutingTable routingTable = RoutingTable.builder()
|
||||||
|
@ -212,12 +212,12 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
|
||||||
assertThat(shardRouting.index(), equalTo("test1"));
|
assertThat(shardRouting.index(), equalTo("test1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("update " + ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE + " for test, see that things move");
|
logger.info("update " + ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey() + " for test, see that things move");
|
||||||
metaData = MetaData.builder(metaData)
|
metaData = MetaData.builder(metaData)
|
||||||
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)
|
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||||
.put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE, 3)
|
.put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 3)
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase {
|
||||||
assertAcked(
|
assertAcked(
|
||||||
prepareCreate("test")
|
prepareCreate("test")
|
||||||
// Enforces that only one shard can only be allocated to a single node
|
// Enforces that only one shard can only be allocated to a single node
|
||||||
.setSettings(Settings.builder().put(indexSettings()).put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE, 1))
|
.setSettings(Settings.builder().put(indexSettings()).put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1))
|
||||||
);
|
);
|
||||||
|
|
||||||
List<IndexRequestBuilder> writes = new ArrayList<>();
|
List<IndexRequestBuilder> writes = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue