Class ShardGenerations

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

public final class ShardGenerations
extends java.lang.Object
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  ShardGenerations.Builder  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String DELETED_SHARD_GEN
    Special generation that signifies that the shard has been deleted from the repository.
    static ShardGenerations EMPTY  
    static java.lang.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.
  • Method Summary

    Modifier and Type Method Description
    static ShardGenerations.Builder builder()  
    boolean equals​(java.lang.Object o)  
    java.util.List<java.lang.String> getGens​(IndexId indexId)  
    java.lang.String getShardGen​(IndexId indexId, int shardId)
    Get the generation of the BlobStoreIndexShardSnapshots blob for a given index and shard.
    int hashCode()  
    java.util.Collection<IndexId> indices()
    Returns all indices for which shard generations are tracked.
    java.util.Map<IndexId,​java.util.Map<java.lang.Integer,​java.lang.String>> obsoleteShardGenerations​(ShardGenerations previous)
    Computes the obsolete shard index generations that can be deleted once this instance was written to the repository.
    java.lang.String toString()  
    int totalShards()
    Returns the total number of shards tracked by this instance.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Method Details

    • totalShards

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

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

      public java.util.Map<IndexId,​java.util.Map<java.lang.Integer,​java.lang.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 java.lang.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 java.util.List<java.lang.String> getGens​(IndexId indexId)
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

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

      public static ShardGenerations.Builder builder()