Class PriorityComparator

java.lang.Object
org.elasticsearch.gateway.PriorityComparator
All Implemented Interfaces:
java.util.Comparator<ShardRouting>

public abstract class PriorityComparator
extends java.lang.Object
implements java.util.Comparator<ShardRouting>
A comparator that compares ShardRouting instances based on various properties. Instances are ordered as follows.
  1. First, system indices are ordered before non-system indices
  2. Then indices are ordered by their priority, in descending order (index.priority)
  3. Then newer indices are ordered before older indices, based on their creation date. This benefits time-series indices, where newer indices are considered more urgent (index.creation_date)
  4. Lastly the index names are compared, which is useful when a date is baked into the index name, e.g. logstash-2015.05.03
  • Constructor Summary

    Constructors
    Constructor Description
    PriorityComparator()  
  • Method Summary

    Modifier and Type Method Description
    int compare​(ShardRouting o1, ShardRouting o2)  
    static PriorityComparator getAllocationComparator​(RoutingAllocation allocation)
    Returns a PriorityComparator that uses the RoutingAllocation index metadata to access the index setting per index.
    protected abstract IndexMetadata getMetadata​(Index index)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Comparator

    equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
  • Constructor Details

    • PriorityComparator

      public PriorityComparator()
  • Method Details

    • compare

      public final int compare​(ShardRouting o1, ShardRouting o2)
      Specified by:
      compare in interface java.util.Comparator<ShardRouting>
    • getMetadata

      protected abstract IndexMetadata getMetadata​(Index index)
    • getAllocationComparator

      public static PriorityComparator getAllocationComparator​(RoutingAllocation allocation)
      Returns a PriorityComparator that uses the RoutingAllocation index metadata to access the index setting per index.