java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator
All Implemented Interfaces:
ShardsAllocator

public class BalancedShardsAllocator extends Object implements ShardsAllocator
The BalancedShardsAllocator allocates and balances shards on the cluster nodes using WeightFunction. The balancing attempts to:
  • even shard count across nodes (weighted by cluster.routing.allocation.balance.shard)
  • spread shards of the same index across different nodes (weighted by cluster.routing.allocation.balance.index)
  • even write load of the data streams write indices across nodes (weighted by cluster.routing.allocation.balance.write_load)
  • even disk usage across nodes (weighted by cluster.routing.allocation.balance.disk_usage)
The sensitivity of the algorithm is defined by cluster.routing.allocation.balance.threshold. Allocator takes into account constraints set by AllocationDeciders when allocating and balancing shards.
  • Field Details

    • SHARD_BALANCE_FACTOR_SETTING

      public static final Setting<Float> SHARD_BALANCE_FACTOR_SETTING
    • INDEX_BALANCE_FACTOR_SETTING

      public static final Setting<Float> INDEX_BALANCE_FACTOR_SETTING
    • WRITE_LOAD_BALANCE_FACTOR_SETTING

      public static final Setting<Float> WRITE_LOAD_BALANCE_FACTOR_SETTING
    • DISK_USAGE_BALANCE_FACTOR_SETTING

      public static final Setting<Float> DISK_USAGE_BALANCE_FACTOR_SETTING
    • THRESHOLD_SETTING

      public static final Setting<Float> THRESHOLD_SETTING
  • Constructor Details

  • Method Details

    • allocate

      public void allocate(RoutingAllocation allocation)
      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 interface ShardsAllocator
      Parameters:
      allocation - current node allocation
    • explainShardAllocation

      public ShardAllocationDecision explainShardAllocation(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 the AllocateUnassignedDecision will be non-null. If the shard is not in the unassigned state, then the MoveDecision will be non-null. 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 a UnsupportedOperationException.
      Specified by:
      explainShardAllocation in interface ShardsAllocator