Module org.elasticsearch.server
Package org.elasticsearch.action.support
Record Class ActiveShardCount
java.lang.Object
java.lang.Record
org.elasticsearch.action.support.ActiveShardCount
- All Implemented Interfaces:
Writeable
A class whose instances represent a value for counting the number
of active shard copies for a given shard in an index.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord that captures the decision ofenoughShardsActive(IndexShardRoutingTable).Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ActiveShardCountstatic final ActiveShardCountstatic final ActiveShardCountstatic final ActiveShardCount -
Constructor Summary
ConstructorsConstructorDescriptionActiveShardCount(int value) Creates an instance of aActiveShardCountrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanenoughShardsActive(int activeShardCount) Returns true iff the given number of active shards is enough to meet the required shard count represented by this instance.booleanenoughShardsActive(ProjectMetadata projectMetadata, RoutingTable routingTable, String... indices) Returns true iff the given cluster state's routing table contains enough active shards for the given indices to meet the required shard count represented by this instance.enoughShardsActive(IndexShardRoutingTable shardRoutingTable) Returns aActiveShardCount.EnoughShardsrecord where the first value is true iff the active shard count in the shard routing table is enough to meet the required shard count represented by this instance, and the second value is the active shard count.final booleanIndicates whether some other object is "equal to" this one.static ActiveShardCountfrom(int value) Get an ActiveShardCount instance for the given value.final inthashCode()Returns a hash code value for this object.static ActiveShardCountparseString(String str) Parses the active shard count from the given string.static ActiveShardCountreadFrom(StreamInput in) toString()Returns a string representation of this record class.booleanvalidate(int numberOfReplicas) Validates that the instance is valid for the given number of replicas in an index.intvalue()Returns the value of thevaluerecord component.voidwriteTo(StreamOutput out) Write this into the StreamOutput.
-
Field Details
-
DEFAULT
-
ALL
-
NONE
-
ONE
-
-
Constructor Details
-
ActiveShardCount
public ActiveShardCount(int value) Creates an instance of aActiveShardCountrecord class.- Parameters:
value- the value for thevaluerecord component
-
-
Method Details
-
from
Get an ActiveShardCount instance for the given value. The value is first validated to ensure it is a valid shard count and throws an IllegalArgumentException if validation fails. Valid values are any non-negative number. Directly useDEFAULTfor the default value (which is one shard copy) orALLto specify all the shards. -
validate
public boolean validate(int numberOfReplicas) Validates that the instance is valid for the given number of replicas in an index. -
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
readFrom
- Throws:
IOException
-
parseString
Parses the active shard count from the given string. Valid values are "all" for all shard copies, null for the default value (which defaults to one shard copy), or a numeric value greater than or equal to 0. Any other input will throw an IllegalArgumentException. -
enoughShardsActive
public boolean enoughShardsActive(int activeShardCount) Returns true iff the given number of active shards is enough to meet the required shard count represented by this instance. This method should only be invoked withActiveShardCountobjects created fromfrom(int), orNONEorONE. -
enoughShardsActive
public boolean enoughShardsActive(@Nullable ProjectMetadata projectMetadata, @Nullable RoutingTable routingTable, String... indices) Returns true iff the given cluster state's routing table contains enough active shards for the given indices to meet the required shard count represented by this instance. -
enoughShardsActive
Returns aActiveShardCount.EnoughShardsrecord where the first value is true iff the active shard count in the shard routing table is enough to meet the required shard count represented by this instance, and the second value is the active shard count. -
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. -
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 '=='. -
value
public int value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-