Class ActiveShardCount

java.lang.Object
org.elasticsearch.action.support.ActiveShardCount
All Implemented Interfaces:
Writeable

public final class ActiveShardCount extends Object implements Writeable
A class whose instances represent a value for counting the number of active shard copies for a given shard in an index.
  • Field Details

  • Method Details

    • from

      public static ActiveShardCount from(int value)
      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 use DEFAULT for the default value (which is one shard copy) or ALL to 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

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • readFrom

      public static ActiveShardCount readFrom(StreamInput in) throws IOException
      Throws:
      IOException
    • parseString

      public static ActiveShardCount parseString(String str)
      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 with ActiveShardCount objects created from from(int), or NONE or ONE.
    • enoughShardsActive

      public boolean enoughShardsActive(ClusterState clusterState, 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

      public boolean enoughShardsActive(IndexShardRoutingTable shardRoutingTable)
      Returns true iff the active shard count in the shard routing table is enough to meet the required shard count represented by this instance.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object