java.lang.Object
org.elasticsearch.indices.ShardLimitValidator
This class contains the logic used to check the cluster-wide shard limit before shards are created and ensuring that the limit is
updated correctly on setting updates, etc.
NOTE: This is the limit applied at *shard creation time*. If you are looking for the limit applied at *allocation* time, which is
controlled by a different setting,
see
ShardsLimitAllocationDecider
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
A Result object containing enough information to be used by external callers about the state of the cluster from the shard limits perspective. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected final AtomicInteger
protected final AtomicInteger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ShardLimitValidator.Result
checkShardLimitForFrozenNodes
(int maxConfiguredShardsPerNode, int numberOfNewShards, int replicas, ClusterState state) This method checks whether there is enough room in the cluster to add the given number of shards with the given number of replicas without exceeding the "cluster.max_shards_per_node_frozen" setting for _frozen_ nodes.static ShardLimitValidator.Result
checkShardLimitForNormalNodes
(int maxConfiguredShardsPerNode, int numberOfNewShards, int replicas, ClusterState state) This method checks whether there is enough room in the cluster to add the given number of shards with the given number of replicas without exceeding the "cluster.max_shards_per_node" setting for _normal_ nodes.int
Gets the currently configured value of theSETTING_CLUSTER_MAX_SHARDS_PER_NODE
setting.void
validateShardLimit
(ClusterState currentState, Index[] indicesToOpen) Validates whether a list of indices can be opened without going over the cluster shard limit.void
validateShardLimit
(Settings settings, ClusterState state) Checks whether an index can be created without going over the cluster shard limit.void
validateShardLimitOnReplicaUpdate
(ClusterState currentState, Index[] indices, int replicas)
-
Field Details
-
SETTING_CLUSTER_MAX_SHARDS_PER_NODE
-
SETTING_CLUSTER_MAX_SHARDS_PER_NODE_FROZEN
-
FROZEN_GROUP
- See Also:
-
NORMAL_GROUP
- See Also:
-
INDEX_SETTING_SHARD_LIMIT_GROUP
-
shardLimitPerNode
-
shardLimitPerNodeFrozen
-
-
Constructor Details
-
ShardLimitValidator
-
-
Method Details
-
getShardLimitPerNode
public int getShardLimitPerNode()Gets the currently configured value of theSETTING_CLUSTER_MAX_SHARDS_PER_NODE
setting.- Returns:
- the current value of the setting
-
validateShardLimit
Checks whether an index can be created without going over the cluster shard limit.- Parameters:
settings
- the settings of the index to be createdstate
- the current cluster state- Throws:
ValidationException
- if creating this index would put the cluster over the cluster shard limit
-
validateShardLimit
Validates whether a list of indices can be opened without going over the cluster shard limit. Only counts indices which are currently closed and will be opened, ignores indices which are already open.- Parameters:
currentState
- The current cluster state.indicesToOpen
- The indices which are to be opened.- Throws:
ValidationException
- If this operation would take the cluster over the limit and enforcement is enabled.
-
validateShardLimitOnReplicaUpdate
public void validateShardLimitOnReplicaUpdate(ClusterState currentState, Index[] indices, int replicas) -
checkShardLimitForNormalNodes
public static ShardLimitValidator.Result checkShardLimitForNormalNodes(int maxConfiguredShardsPerNode, int numberOfNewShards, int replicas, ClusterState state) This method checks whether there is enough room in the cluster to add the given number of shards with the given number of replicas without exceeding the "cluster.max_shards_per_node" setting for _normal_ nodes. This check does not guarantee that the number of shards can be added, just that there is theoretically room to add them without exceeding the shards per node configuration.- Parameters:
maxConfiguredShardsPerNode
- The maximum available number of shards to be allocated within a nodenumberOfNewShards
- The number of primary shards that we want to be able to add to the clusterreplicas
- The number of replicas of the primary shards that we want to be able to add to the clusterstate
- The cluster state, used to get cluster settings and to get the number of open shards already in the cluster
-
checkShardLimitForFrozenNodes
public static ShardLimitValidator.Result checkShardLimitForFrozenNodes(int maxConfiguredShardsPerNode, int numberOfNewShards, int replicas, ClusterState state) This method checks whether there is enough room in the cluster to add the given number of shards with the given number of replicas without exceeding the "cluster.max_shards_per_node_frozen" setting for _frozen_ nodes. This check does not guarantee that the number of shards can be added, just that there is theoretically room to add them without exceeding the shards per node configuration.- Parameters:
maxConfiguredShardsPerNode
- The maximum available number of shards to be allocated within a nodenumberOfNewShards
- The number of primary shards that we want to be able to add to the clusterreplicas
- The number of replicas of the primary shards that we want to be able to add to the clusterstate
- The cluster state, used to get cluster settings and to get the number of open shards already in the cluster
-