Record Class AutoExpandReplicas
java.lang.Object
java.lang.Record
org.elasticsearch.cluster.metadata.AutoExpandReplicas
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 Summary
-
Constructor Summary
ConstructorDescriptionAutoExpandReplicas
(int minReplicas, int maxReplicas, boolean enabled) Creates an instance of aAutoExpandReplicas
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
enabled()
Returns the value of theenabled
record component.final boolean
Indicates whether some other object is "equal to" this one.boolean
getAutoExpandReplicaChanges
(Metadata metadata, Supplier<RoutingAllocation> allocationSupplier) Checks if there are replicas with the auto-expand feature that need to be adapted.getDesiredNumberOfReplicas
(IndexMetadata indexMetadata, RoutingAllocation allocation) final int
hashCode()
Returns a hash code value for this object.int
Returns the value of themaxReplicas
record component.int
Returns the value of theminReplicas
record component.toString()
Returns a string representation of this record class.
-
Field Details
-
SETTING
-
-
Constructor Details
-
AutoExpandReplicas
public AutoExpandReplicas(int minReplicas, int maxReplicas, boolean enabled) Creates an instance of aAutoExpandReplicas
record class.- Parameters:
minReplicas
- the value for theminReplicas
record componentmaxReplicas
- the value for themaxReplicas
record componentenabled
- the value for theenabled
record component
-
-
Method Details
-
expandToAllNodes
public boolean expandToAllNodes() -
getDesiredNumberOfReplicas
public OptionalInt getDesiredNumberOfReplicas(IndexMetadata indexMetadata, RoutingAllocation allocation) -
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. -
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. -
equals
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 '=='. -
minReplicas
public int minReplicas()Returns the value of theminReplicas
record component.- Returns:
- the value of the
minReplicas
record component
-
maxReplicas
public int maxReplicas()Returns the value of themaxReplicas
record component.- Returns:
- the value of the
maxReplicas
record component
-
enabled
public boolean enabled()Returns the value of theenabled
record component.- Returns:
- the value of the
enabled
record component
-