Class BalancedShardsAllocator.Balancer

java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.Balancer
Enclosing class:
BalancedShardsAllocator

public static class BalancedShardsAllocator.Balancer
extends java.lang.Object
  • Constructor Summary

    Constructors
    Constructor Description
    Balancer​(org.apache.logging.log4j.Logger logger, RoutingAllocation allocation, org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.WeightFunction weight, float threshold)  
  • Method Summary

    Modifier and Type Method Description
    float avgShardsPerNode()
    Returns the global average of shards per node
    float avgShardsPerNode​(java.lang.String index)
    Returns the average of shards per node for the given index
    MoveDecision decideMove​(ShardRouting shardRouting)
    Makes a decision on whether to move a started shard to another node.
    void moveShards()
    Move started shards that can not be allocated to a node anymore For each shard to be moved this function executes a move operation to the minimal eligible node with respect to the weight function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Balancer

      public Balancer​(org.apache.logging.log4j.Logger logger, RoutingAllocation allocation, org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.WeightFunction weight, float threshold)
  • Method Details

    • avgShardsPerNode

      public float avgShardsPerNode​(java.lang.String index)
      Returns the average of shards per node for the given index
    • avgShardsPerNode

      public float avgShardsPerNode()
      Returns the global average of shards per node
    • moveShards

      public void moveShards()
      Move started shards that can not be allocated to a node anymore For each shard to be moved this function executes a move operation to the minimal eligible node with respect to the weight function. If a shard is moved the shard will be set to ShardRoutingState.RELOCATING and a shadow instance of this shard is created with an incremented version in the state ShardRoutingState.INITIALIZING.
    • decideMove

      public MoveDecision decideMove​(ShardRouting shardRouting)
      Makes a decision on whether to move a started shard to another node. The following rules apply to the MoveDecision return object: 1. If the shard is not started, no decision will be taken and MoveDecision.isDecisionTaken() will return false. 2. If the shard is allowed to remain on its current node, no attempt will be made to move the shard and MoveDecision.getCanRemainDecision() will have a decision type of YES. All other fields in the object will be null. 3. If the shard is not allowed to remain on its current node, then MoveDecision.getAllocationDecision() will be populated with the decision of moving to another node. If MoveDecision.forceMove() ()} returns true, then AbstractAllocationDecision.getTargetNode() will return a non-null value, otherwise the assignedNodeId will be null. 4. If the method is invoked in explain mode (e.g. from the cluster allocation explain APIs), then AbstractAllocationDecision.getNodeDecisions() will have a non-null value.