Class BalancedShardsAllocator.NodeSorter

java.lang.Object
org.apache.lucene.util.Sorter
org.apache.lucene.util.IntroSorter
org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.NodeSorter
Enclosing class:
BalancedShardsAllocator

public static final class BalancedShardsAllocator.NodeSorter extends org.apache.lucene.util.IntroSorter
A NodeSorter sorts the set of nodes for a single partition using the WeightFunction for that partition. In partitioned cluster topologies there will be one for each partition (e.g. search/indexing in stateless). By default, there is a single partition containing a single weight function that applies to all nodes and shards.
See Also:
  • Constructor Details

  • Method Details

    • validSortedCount

      public int validSortedCount()
      If the weight function returns an invalid weight (see BalancedShardsAllocator.nodeWeightIsInvalid(float)). We default the weight to Float.MAX_VALUE. This method returns the number of nodes that returned valid weights last time reset(ProjectIndex) or reset(ProjectIndex, int) was called. This allows iteration of only those nodes that returned valid weights.
      Returns:
      The count of nodes that returned valid weights the last time reset was called
    • reset

      public void reset(BalancedShardsAllocator.ProjectIndex index, int to)
      Resets the sorter, recalculates the weights per node and sorts the nodes by weight, with minimal weight first.
    • recalculateWeightsAndReSort

      public void recalculateWeightsAndReSort(int... nodeIndices)
      Recalculate the weights of the nodes at the specified indices, incrementing the invalid count if any become invalid.
      Parameters:
      nodeIndices - The indices of the nodes whose weights should be recalculated
    • reset

      public void reset(BalancedShardsAllocator.ProjectIndex index)
    • minWeightDelta

      public float minWeightDelta()
    • swap

      protected void swap(int i, int j)
      Specified by:
      swap in class org.apache.lucene.util.Sorter
    • compare

      protected int compare(int i, int j)
      Overrides:
      compare in class org.apache.lucene.util.IntroSorter
    • setPivot

      protected void setPivot(int i)
      Specified by:
      setPivot in class org.apache.lucene.util.IntroSorter
    • comparePivot

      protected int comparePivot(int j)
      Specified by:
      comparePivot in class org.apache.lucene.util.IntroSorter
    • delta

      public float delta()
    • getWeightFunction

      public WeightFunction getWeightFunction()
    • getThreshold

      public float getThreshold()