java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.OrderedShardsIterator
All Implemented Interfaces:
Iterator<ShardRouting>

public class OrderedShardsIterator extends Object implements Iterator<ShardRouting>
This class iterates all shards from all nodes. The shard order is defined by (1) allocation recency: shards from the node that had a new shard allocation would appear in the end of iteration. (2) shard priority: for necessary moves data stream write shards, then regular index shards, then the rest for rebalancing the order is inverse
  • Method Details

    • createForNecessaryMoves

      public static OrderedShardsIterator createForNecessaryMoves(RoutingAllocation allocation, NodeAllocationOrdering ordering)
      This iterator will progress through the shards node by node, each node's shards ordered from most write active to least.
      Parameters:
      allocation -
      ordering -
      Returns:
      An iterator over all shards in the RoutingNodes held by allocation (all shards assigned to a node). The iterator will progress node by node, where each node's shards are ordered from data stream write indices, to regular indices and lastly to data stream read indices.
    • createForBalancing

      public static OrderedShardsIterator createForBalancing(RoutingAllocation allocation, NodeAllocationOrdering ordering)
      This iterator will progress through the shards node by node, each node's shards ordered from least write active to most.
      Parameters:
      allocation -
      ordering -
      Returns:
      An iterator over all shards in the RoutingNodes held by allocation (all shards assigned to a node). The iterator will progress node by node, where each node's shards are ordered from data stream read indices, to regular indices and lastly to data stream write indices.
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<ShardRouting>
    • next

      public ShardRouting next()
      Specified by:
      next in interface Iterator<ShardRouting>
    • dePrioritizeNode

      public void dePrioritizeNode(String nodeId)