Class ShardGenerations

java.lang.Object
org.elasticsearch.repositories.ShardGenerations

public final class ShardGenerations extends Object
  • Field Details

    • EMPTY

      public static final ShardGenerations EMPTY
    • NEW_SHARD_GEN

      public static final String NEW_SHARD_GEN
      Special generation that signifies that a shard is new and the repository does not yet contain a valid BlobStoreIndexShardSnapshots blob for it.
      See Also:
      Constant Field Values
    • DELETED_SHARD_GEN

      public static final String DELETED_SHARD_GEN
      Special generation that signifies that the shard has been deleted from the repository. This generation is only used during computations. It should never be written to disk.
      See Also:
      Constant Field Values
  • Method Details

    • fixShardGeneration

      @Nullable public static String fixShardGeneration(@Nullable String shardGeneration)
      Filters out unreliable numeric shard generations read from RepositoryData or IndexShardSnapshotStatus, returning null in their place.
      Parameters:
      shardGeneration - shard generation to fix
      Returns:
      given shard generation or null if it was filtered out or null was passed
      See Also:
      Issue #57988
    • totalShards

      public int totalShards()
      Returns the total number of shards tracked by this instance.
    • indices

      public Collection<IndexId> indices()
      Returns all indices for which shard generations are tracked.
      Returns:
      indices for which shard generations are tracked
    • obsoleteShardGenerations

      public Map<IndexId,Map<Integer,String>> obsoleteShardGenerations(ShardGenerations previous)
      Computes the obsolete shard index generations that can be deleted once this instance was written to the repository. Note: This method should only be used when finalizing a snapshot and we can safely assume that data has only been added but not removed from shard paths.
      Parameters:
      previous - Previous ShardGenerations
      Returns:
      Map of obsolete shard index generations in indices that are still tracked by this instance
    • getShardGen

      @Nullable public String getShardGen(IndexId indexId, int shardId)
      Get the generation of the BlobStoreIndexShardSnapshots blob for a given index and shard. There are three special kinds of generations that can be returned here.
      • DELETED_SHARD_GEN a deleted shard that isn't referenced by any snapshot in the repository any longer
      • NEW_SHARD_GEN a new shard that we know doesn't hold any valid data yet in the repository
      • null unknown state. The shard either does not exist at all or it was created by a node older than SnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSION. If a caller expects a shard to exist in the repository but sees a null return, it should try to recover the generation by falling back to listing the contents of the respective shard directory.
      Parameters:
      indexId - IndexId
      shardId - Shard Id
      Returns:
      generation of the BlobStoreIndexShardSnapshots blob
    • getGens

      public List<String> getGens(IndexId indexId)
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static ShardGenerations.Builder builder()