Package org.elasticsearch.repositories
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 classShardGenerations.Builder -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDELETED_SHARD_GENSpecial generation that signifies that the shard has been deleted from the repository.static ShardGenerationsEMPTYstatic java.lang.StringNEW_SHARD_GENSpecial generation that signifies that a shard is new and the repository does not yet contain a validBlobStoreIndexShardSnapshotsblob for it. -
Method Summary
Modifier and Type Method Description static ShardGenerations.Builderbuilder()booleanequals(java.lang.Object o)static java.lang.StringfixShardGeneration(java.lang.String shardGeneration)Filters out unreliable numeric shard generations read fromRepositoryDataorIndexShardSnapshotStatus, returningnullin their place.java.util.List<java.lang.String>getGens(IndexId indexId)java.lang.StringgetShardGen(IndexId indexId, int shardId)Get the generation of theBlobStoreIndexShardSnapshotsblob for a given index and shard.inthashCode()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.StringtoString()inttotalShards()Returns the total number of shards tracked by this instance.
-
Field Details
-
EMPTY
-
NEW_SHARD_GEN
public static final java.lang.String NEW_SHARD_GENSpecial generation that signifies that a shard is new and the repository does not yet contain a validBlobStoreIndexShardSnapshotsblob for it.- See Also:
- Constant Field Values
-
DELETED_SHARD_GEN
public static final java.lang.String DELETED_SHARD_GENSpecial 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 java.lang.String fixShardGeneration(@Nullable java.lang.String shardGeneration)Filters out unreliable numeric shard generations read fromRepositoryDataorIndexShardSnapshotStatus, returningnullin their place.- Parameters:
shardGeneration- shard generation to fix- Returns:
- given shard generation or
nullif it was filtered out ornullwas passed - See Also:
- Issue #57988
-
totalShards
public int totalShards()Returns the total number of shards tracked by this instance. -
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- PreviousShardGenerations- Returns:
- Map of obsolete shard index generations in indices that are still tracked by this instance
-
getShardGen
Get the generation of theBlobStoreIndexShardSnapshotsblob for a given index and shard. There are three special kinds of generations that can be returned here.DELETED_SHARD_GENa deleted shard that isn't referenced by any snapshot in the repository any longerNEW_SHARD_GENa new shard that we know doesn't hold any valid data yet in the repositorynullunknown state. The shard either does not exist at all or it was created by a node older thanSnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSION. If a caller expects a shard to exist in the repository but sees anullreturn, it should try to recover the generation by falling back to listing the contents of the respective shard directory.
- Parameters:
indexId- IndexIdshardId- Shard Id- Returns:
- generation of the
BlobStoreIndexShardSnapshotsblob
-
getGens
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
builder
-