Class ShardGenerations


public final class ShardGenerations extends Object
Represents the current ShardGeneration for each shard in a repository.
  • Field Details

    • EMPTY

      public static final ShardGenerations EMPTY

      public static final ShardGeneration 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.

      public static final ShardGeneration 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.
  • Method Details

    • fixShardGeneration

      @Nullable public static ShardGeneration fixShardGeneration(@Nullable ShardGeneration shardGeneration)
      Filters out unreliable numeric shard generations read from RepositoryData or IndexShardSnapshotStatus, returning null in their place.
      shardGeneration - shard generation to fix
      given shard generation or null if it was filtered out or null was passed
      See Also:
    • 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.
      indices for which shard generations are tracked
    • obsoleteShardGenerations

      public Map<IndexId,Map<Integer,ShardGeneration>> 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.
      previous - Previous ShardGenerations
      Map of obsolete shard index generations in indices that are still tracked by this instance
    • getShardGen

      @Nullable public ShardGeneration 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.
      indexId - IndexId
      shardId - Shard Id
      generation of the BlobStoreIndexShardSnapshots blob
    • getGens

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

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

      public int hashCode()
      hashCode in class Object
    • toString

      public String toString()
      toString in class Object
    • builder

      public static ShardGenerations.Builder builder()