java.lang.Object
org.elasticsearch.repositories.RepositoryData
Represents the data in a repository: the snapshots and the indices across all snapshots found in the repository.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA few details of an individual snapshot stored in the top-level index blob, so they are readily accessible without having to load the correspondingSnapshotInfoblob for each snapshot. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe generation value indicating that the repository generation could not be determined.static final RepositoryDataAn instance initialized for an empty repository.static final longThe generation value indicating the repository has no index generational files.static final StringSentinel value for the repository UUID indicating that it is not set.static final longThe generation value indicating that the repository generation is unknown. -
Constructor Summary
ConstructorsConstructorDescriptionRepositoryData(String uuid, long genId, Map<String, SnapshotId> snapshotIds, Map<String, RepositoryData.SnapshotDetails> snapshotsDetails, Map<IndexId, List<SnapshotId>> indexSnapshots, ShardGenerations shardGenerations, IndexMetaDataGenerations indexMetaDataGenerations, String clusterUUID) -
Method Summary
Modifier and TypeMethodDescriptionaddSnapshot(SnapshotId snapshotId, RepositoryData.SnapshotDetails details, FinalizeSnapshotContext.UpdatedShardGenerations updatedShardGenerations, Map<IndexId, String> indexMetaBlobs, Map<String, String> newIdentifiers) Add a snapshot and its indices to the repository; returns a new instance.protected RepositoryDatacopy()booleanlonggetGenId()Gets the generational index file id from which this instance was read.longReturns an unmodifiable map of the index names toIndexIdin the repository.getSnapshotDetails(SnapshotId snapshotId) Returns theRepositoryData.SnapshotDetailsfor the given snapshot.Returns an unmodifiable collection of the snapshot ids.getSnapshots(IndexId indexId) Returns an immutable collection of the snapshot ids for the snapshots that contain the given index.getSnapshotState(SnapshotId snapshotId) Returns theSnapshotStatefor the given snapshot.getUuid()getVersion(SnapshotId snapshotId) Returns theIndexVersionfor the given snapshot ornullif unknown.inthashCode()booleanChecks if any snapshot in this repository contains the specified index inindexNamebooleanhasMissingDetails(SnapshotId snapshotId) indexMetaDataToRemoveAfterRemovingSnapshots(Collection<SnapshotId> snapshotIds) Returns a map ofIndexIdto a collection ofStringcontaining all theIndexIdand theIndexMetadatablob name in it that can be removed after removing the given snapshot from the repository.indicesToUpdateAfterRemovingSnapshot(Collection<SnapshotId> snapshotIds) Returns an iterator overIndexIdthat have their snapshots updated but not removed (because they are still referenced by other snapshots) after removing the given snapshot from the repository.removeSnapshots(Collection<SnapshotId> snapshots, ShardGenerations updatedShardGenerations) Remove snapshots and remove any indices that no longer exist in the repository due to the deletion of the snapshots.resolveIndexId(String indexName) Resolve the index name to the index id specific to the repository, throwing an exception if the index could not be resolved.resolveIndices(List<String> indices) Resolve the given index names to index ids.Resolve the given index names to index ids, creating new index ids for new indices in the repository.static RepositoryDatasnapshotsFromXContent(XContentParser parser, long genId, boolean fixBrokenShardGens) Reads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.snapshotsToXContent(XContentBuilder builder, IndexVersion repoMetaVersion) Writes the snapshots metadata and the related indices metadata to x-content.snapshotsToXContent(XContentBuilder builder, IndexVersion repoMetaVersion, boolean permitMissingUuid) Writes the snapshots metadata and the related indices metadata to x-content.toString()withClusterUuid(String clusterUUID) withExtraDetails(Map<SnapshotId, RepositoryData.SnapshotDetails> extraDetails) Creates a copy of this instance that contains additional details read from the per-snapshot metadata blobswithGenId(long newGeneration) Create a new instance with the given generation and all other fields equal to this instance.Creates a copy of this instance that does not track any shard generations.For test purposes, make a copy of this instance with the cluster- and repository UUIDs removed and all other fields unchanged, as if from an older version.
-
Field Details
-
EMPTY_REPO_GEN
public static final long EMPTY_REPO_GENThe generation value indicating the repository has no index generational files.- See Also:
-
UNKNOWN_REPO_GEN
public static final long UNKNOWN_REPO_GENThe generation value indicating that the repository generation is unknown.- See Also:
-
CORRUPTED_REPO_GEN
public static final long CORRUPTED_REPO_GENThe generation value indicating that the repository generation could not be determined.- See Also:
-
MISSING_UUID
Sentinel value for the repository UUID indicating that it is not set.- See Also:
-
EMPTY
An instance initialized for an empty repository.
-
-
Constructor Details
-
RepositoryData
public RepositoryData(String uuid, long genId, Map<String, SnapshotId> snapshotIds, Map<String, RepositoryData.SnapshotDetails> snapshotsDetails, Map<IndexId, List<SnapshotId>> indexSnapshots, ShardGenerations shardGenerations, IndexMetaDataGenerations indexMetaDataGenerations, String clusterUUID)
-
-
Method Details
-
copy
-
withoutShardGenerations
Creates a copy of this instance that does not track any shard generations.- Returns:
- repository data with empty shard generations
-
withExtraDetails
Creates a copy of this instance that contains additional details read from the per-snapshot metadata blobs- Parameters:
extraDetails- map of snapshot details- Returns:
- copy with updated version data
-
shardGenerations
-
getUuid
- Returns:
- The UUID of this repository, or
MISSING_UUIDif this repository has no UUID because it still supports access from versions earlier thanSnapshotsService.UUIDS_IN_REPO_DATA_VERSION.
-
getClusterUUID
- Returns:
- the cluster UUID of the cluster that wrote this instance to the repository or
MISSING_UUIDif this instance was written by a cluster older thanSnapshotsService.UUIDS_IN_REPO_DATA_VERSION.
-
getGenId
public long getGenId()Gets the generational index file id from which this instance was read. -
getSnapshotIds
Returns an unmodifiable collection of the snapshot ids. -
getIndexSnapshotCount
public long getIndexSnapshotCount()- Returns:
- the number of index snapshots (i.e. the sum of the index count of each snapshot)
-
hasMissingDetails
- Returns:
- whether some of the
RepositoryData.SnapshotDetailsof the given snapshot are missing, due to BwC, so that they must be loaded from theSnapshotInfoblob instead.
-
getSnapshotDetails
Returns theRepositoryData.SnapshotDetailsfor the given snapshot. Returnsnullif there are no details for the snapshot. -
getSnapshotState
Returns theSnapshotStatefor the given snapshot. Returnsnullif there is no state for the snapshot. -
getVersion
Returns theIndexVersionfor the given snapshot ornullif unknown. -
getIndices
Returns an unmodifiable map of the index names toIndexIdin the repository. -
indicesToUpdateAfterRemovingSnapshot
Returns an iterator overIndexIdthat have their snapshots updated but not removed (because they are still referenced by other snapshots) after removing the given snapshot from the repository.- Parameters:
snapshotIds- SnapshotId to remove- Returns:
- Iterator over indices that are changed but not removed
-
indexMetaDataToRemoveAfterRemovingSnapshots
public Map<IndexId,Collection<String>> indexMetaDataToRemoveAfterRemovingSnapshots(Collection<SnapshotId> snapshotIds) Returns a map ofIndexIdto a collection ofStringcontaining all theIndexIdand theIndexMetadatablob name in it that can be removed after removing the given snapshot from the repository. NOTE: Does not return a mapping forIndexIdvalues that will be removed completely from the repository.- Parameters:
snapshotIds- SnapshotIds to remove- Returns:
- map of index to index metadata blob id to delete
-
addSnapshot
public RepositoryData addSnapshot(SnapshotId snapshotId, RepositoryData.SnapshotDetails details, FinalizeSnapshotContext.UpdatedShardGenerations updatedShardGenerations, @Nullable Map<IndexId, String> indexMetaBlobs, @Nullable Map<String, String> newIdentifiers) Add a snapshot and its indices to the repository; returns a new instance. If the snapshot already exists in the repository data, this method throws an IllegalArgumentException.- Parameters:
snapshotId- Id of the new snapshotdetails- Details of the new snapshotupdatedShardGenerations- Updated shard generations in the new snapshot, including both indices that are included in the given snapshot and those got deleted while finalizing.indexMetaBlobs- Map of index metadata blob uuidsnewIdentifiers- Map of new index metadata blob uuids keyed by the identifiers of theIndexMetadatain them
-
withGenId
Create a new instance with the given generation and all other fields equal to this instance.- Parameters:
newGeneration- New Generation- Returns:
- New instance
-
withoutUUIDs
For test purposes, make a copy of this instance with the cluster- and repository UUIDs removed and all other fields unchanged, as if from an older version. -
withClusterUuid
-
removeSnapshots
public RepositoryData removeSnapshots(Collection<SnapshotId> snapshots, ShardGenerations updatedShardGenerations) Remove snapshots and remove any indices that no longer exist in the repository due to the deletion of the snapshots.- Parameters:
snapshots- Snapshot ids to removeupdatedShardGenerations- Shard generations that changed as a result of removing the snapshot. TheString[]passed for eachIndexIdcontains the new shard generation id for each changed shard indexed by its shardId
-
getSnapshots
Returns an immutable collection of the snapshot ids for the snapshots that contain the given index. -
equals
-
hashCode
public int hashCode() -
toString
-
resolveIndexId
Resolve the index name to the index id specific to the repository, throwing an exception if the index could not be resolved. -
resolveIndices
Resolve the given index names to index ids. -
hasIndex
Checks if any snapshot in this repository contains the specified index inindexName -
resolveNewIndices
public Map<String,IndexId> resolveNewIndices(List<String> indicesToResolve, Map<String, IndexId> inFlightIds) Resolve the given index names to index ids, creating new index ids for new indices in the repository.- Parameters:
indicesToResolve- names of indices to resolveinFlightIds- name to index mapping for currently in-flight snapshots not yet in the repository data to fall back to
-
snapshotsToXContent
public XContentBuilder snapshotsToXContent(XContentBuilder builder, IndexVersion repoMetaVersion) throws IOException Writes the snapshots metadata and the related indices metadata to x-content.- Throws:
IOException
-
snapshotsToXContent
public XContentBuilder snapshotsToXContent(XContentBuilder builder, IndexVersion repoMetaVersion, boolean permitMissingUuid) throws IOException Writes the snapshots metadata and the related indices metadata to x-content.- Parameters:
permitMissingUuid- indicates whether we permit the repository- and cluster UUIDs to be missing, e.g. we are serializing for the in-memory cache or running tests- Throws:
IOException
-
indexMetaDataGenerations
-
snapshotsFromXContent
public static RepositoryData snapshotsFromXContent(XContentParser parser, long genId, boolean fixBrokenShardGens) throws IOException Reads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.- Parameters:
fixBrokenShardGens- set totrueto filter out broken shard generations read from theparserviaShardGenerations.fixShardGeneration(org.elasticsearch.repositories.ShardGeneration). Used to disable fixing broken generations when reading from cached bytes that we trust to not contain broken generations.- Throws:
IOException
-