Class BalancedShardsAllocator
java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator
- All Implemented Interfaces:
ShardsAllocator
The
BalancedShardsAllocator
re-balances the nodes allocations
within an cluster based on a BalancedShardsAllocator.WeightFunction
. The clusters balance is defined by four parameters which can be set
in the cluster update API that allows changes in real-time:
cluster.routing.allocation.balance.shard
- The shard balance defines the weight factor for shards allocated on aRoutingNode
cluster.routing.allocation.balance.index
- The index balance defines a factor to the number ofShardRouting
s per index allocated on a specific nodecluster.routing.allocation.balance.threshold
- A threshold to set the minimal optimization value of operations that should be performed
These parameters are combined in a BalancedShardsAllocator.WeightFunction
that allows calculation of node weights which
are used to re-balance shards based on global as well as per-index factors.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Field Summary
Modifier and TypeFieldDescription -
Constructor Summary
ConstructorDescriptionBalancedShardsAllocator(Settings settings)
BalancedShardsAllocator(Settings settings, ClusterSettings clusterSettings)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allocate(RoutingAllocation allocation)
Allocates shards to nodes in the cluster.decideShardAllocation(ShardRouting shard, RoutingAllocation allocation)
Returns the decision for where a shard should reside in the cluster.float
Returns the index related weight factor.float
Returns the shard related weight factor.float
Returns the currently configured delta threshold
-
Field Details
-
INDEX_BALANCE_FACTOR_SETTING
-
SHARD_BALANCE_FACTOR_SETTING
-
THRESHOLD_SETTING
-
-
Constructor Details
-
BalancedShardsAllocator
-
BalancedShardsAllocator
-
-
Method Details
-
allocate
Description copied from interface:ShardsAllocator
Allocates shards to nodes in the cluster. An implementation of this method should: - assign unassigned shards - relocate shards that cannot stay on a node anymore - relocate shards to find a good shard balance in the cluster- Specified by:
allocate
in interfaceShardsAllocator
- Parameters:
allocation
- current node allocation
-
decideShardAllocation
public ShardAllocationDecision decideShardAllocation(ShardRouting shard, RoutingAllocation allocation)Description copied from interface:ShardsAllocator
Returns the decision for where a shard should reside in the cluster. If the shard is unassigned, then theAllocateUnassignedDecision
will be non-null. If the shard is not in the unassigned state, then theMoveDecision
will be non-null. This method is primarily used by the cluster allocation explain API to provide detailed explanations for the allocation of a single shard. Implementations of theShardsAllocator.allocate(RoutingAllocation)
method may use the results of this method implementation to decide on allocating shards in the routing table to the cluster. If an implementation of this interface does not support explaining decisions for a single shard through the cluster explain API, then this method should throw aUnsupportedOperationException
.- Specified by:
decideShardAllocation
in interfaceShardsAllocator
-
getThreshold
public float getThreshold()Returns the currently configured delta threshold -
getIndexBalance
public float getIndexBalance()Returns the index related weight factor. -
getShardBalance
public float getShardBalance()Returns the shard related weight factor.
-