Record Class AutoExpandReplicas

java.lang.Object
java.lang.Record
org.elasticsearch.cluster.metadata.AutoExpandReplicas

public record AutoExpandReplicas(int minReplicas, int maxReplicas, boolean enabled) extends Record
This class acts as a functional wrapper around the index.auto_expand_replicas setting. This setting or rather it's value is expanded into a min and max value which requires special handling based on the number of datanodes in the cluster. This class handles all the parsing and streamlines the access to these values.
  • Field Details

  • Constructor Details

    • AutoExpandReplicas

      public AutoExpandReplicas(int minReplicas, int maxReplicas, boolean enabled)
      Creates an instance of a AutoExpandReplicas record class.
      Parameters:
      minReplicas - the value for the minReplicas record component
      maxReplicas - the value for the maxReplicas record component
      enabled - the value for the enabled record component
  • Method Details

    • expandToAllNodes

      public boolean expandToAllNodes()
    • getDesiredNumberOfReplicas

      public OptionalInt getDesiredNumberOfReplicas(IndexMetadata indexMetadata, RoutingAllocation allocation)
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • getAutoExpandReplicaChanges

      public static Map<Integer,List<String>> getAutoExpandReplicaChanges(Metadata metadata, Supplier<RoutingAllocation> allocationSupplier)
      Checks if there are replicas with the auto-expand feature that need to be adapted. Returns a map of updates, which maps the indices to be updated to the desired number of replicas. The map has the desired number of replicas as key and the indices to update as value, as this allows the result of this method to be directly applied to RoutingTable.Builder#updateNumberOfReplicas.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • minReplicas

      public int minReplicas()
      Returns the value of the minReplicas record component.
      Returns:
      the value of the minReplicas record component
    • maxReplicas

      public int maxReplicas()
      Returns the value of the maxReplicas record component.
      Returns:
      the value of the maxReplicas record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component