Package org.elasticsearch.repositories
Class RepositoryData
java.lang.Object
org.elasticsearch.repositories.RepositoryData
public final class RepositoryData
extends java.lang.Object
A class that represents the data in a repository, as captured in the
repository's index blob.
-
Field Summary
Fields Modifier and Type Field Description static longCORRUPTED_REPO_GENThe generation value indicating that the repository generation could not be determined.static RepositoryDataEMPTYAn instance initialized for an empty repository.static longEMPTY_REPO_GENThe generation value indicating the repository has no index generational files.static longUNKNOWN_REPO_GENThe generation value indicating that the repository generation is unknown. -
Constructor Summary
Constructors Constructor Description RepositoryData(long genId, java.util.Map<java.lang.String,SnapshotId> snapshotIds, java.util.Map<java.lang.String,SnapshotState> snapshotStates, java.util.Map<java.lang.String,Version> snapshotVersions, java.util.Map<IndexId,java.util.Set<SnapshotId>> indexSnapshots, ShardGenerations shardGenerations) -
Method Summary
Modifier and Type Method Description RepositoryDataaddSnapshot(SnapshotId snapshotId, SnapshotState snapshotState, Version version, ShardGenerations shardGenerations)Add a snapshot and its indices to the repository; returns a new instance.protected RepositoryDatacopy()booleanequals(java.lang.Object obj)longgetGenId()Gets the generational index file id from which this instance was read.java.util.Map<java.lang.String,IndexId>getIndices()Returns an unmodifiable map of the index names toIndexIdin the repository.java.util.Collection<SnapshotId>getSnapshotIds()Returns an unmodifiable collection of the snapshot ids.java.util.Set<SnapshotId>getSnapshots(IndexId indexId)Returns an immutable collection of the snapshot ids for the snapshots that contain the given index.SnapshotStategetSnapshotState(SnapshotId snapshotId)Returns theSnapshotStatefor the given snapshot.VersiongetVersion(SnapshotId snapshotId)Returns theVersionfor the given snapshot ornullif unknown.inthashCode()java.util.List<IndexId>indicesToUpdateAfterRemovingSnapshot(SnapshotId snapshotId)Returns the list ofIndexIdthat have their snapshots updated but not removed (because they are still referenced by other snapshots) after removing the given snapshot from the repository.RepositoryDataremoveSnapshot(SnapshotId snapshotId, ShardGenerations updatedShardGenerations)Remove a snapshot and remove any indices that no longer exist in the repository due to the deletion of the snapshot.IndexIdresolveIndexId(java.lang.String indexName)Resolve the index name to the index id specific to the repository, throwing an exception if the index could not be resolved.java.util.List<IndexId>resolveIndices(java.util.List<java.lang.String> indices)Resolve the given index names to index ids.java.util.List<IndexId>resolveNewIndices(java.util.List<java.lang.String> indicesToResolve)Resolve the given index names to index ids, creating new index ids for new indices in the repository.ShardGenerationsshardGenerations()static RepositoryDatasnapshotsFromXContent(XContentParser parser, long genId)Reads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.XContentBuildersnapshotsToXContent(XContentBuilder builder, boolean shouldWriteShardGens)Writes the snapshots metadata and the related indices metadata to x-content.RepositoryDatawithGenId(long newGeneration)Create a new instance with the given generation and all other fields equal to this instance.RepositoryDatawithVersions(java.util.Map<SnapshotId,Version> versions)Creates a copy of this instance that contains updated version data.
-
Field Details
-
EMPTY_REPO_GEN
public static final long EMPTY_REPO_GENThe generation value indicating the repository has no index generational files.- See Also:
- Constant Field Values
-
UNKNOWN_REPO_GEN
public static final long UNKNOWN_REPO_GENThe generation value indicating that the repository generation is unknown.- See Also:
- Constant Field Values
-
CORRUPTED_REPO_GEN
public static final long CORRUPTED_REPO_GENThe generation value indicating that the repository generation could not be determined.- See Also:
- Constant Field Values
-
EMPTY
An instance initialized for an empty repository.
-
-
Constructor Details
-
RepositoryData
public RepositoryData(long genId, java.util.Map<java.lang.String,SnapshotId> snapshotIds, java.util.Map<java.lang.String,SnapshotState> snapshotStates, java.util.Map<java.lang.String,Version> snapshotVersions, java.util.Map<IndexId,java.util.Set<SnapshotId>> indexSnapshots, ShardGenerations shardGenerations)
-
-
Method Details
-
copy
-
withVersions
Creates a copy of this instance that contains updated version data.- Parameters:
versions- map of snapshot versions- Returns:
- copy with updated version data
-
shardGenerations
-
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. -
getSnapshotState
Returns theSnapshotStatefor the given snapshot. Returnsnullif there is no state for the snapshot. -
getVersion
Returns theVersionfor the given snapshot ornullif unknown. -
getIndices
Returns an unmodifiable map of the index names toIndexIdin the repository. -
indicesToUpdateAfterRemovingSnapshot
Returns the list ofIndexIdthat have their snapshots updated but not removed (because they are still referenced by other snapshots) after removing the given snapshot from the repository.- Parameters:
snapshotId- SnapshotId to remove- Returns:
- List of indices that are changed but not removed
-
addSnapshot
public RepositoryData addSnapshot(SnapshotId snapshotId, SnapshotState snapshotState, Version version, ShardGenerations shardGenerations)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 snapshotsnapshotState- State of the new snapshotshardGenerations- Updated shard generations in the new snapshot. For each index contained in the snapshot an array of new generations indexed by the shard id they correspond to must be supplied.
-
withGenId
Create a new instance with the given generation and all other fields equal to this instance.- Parameters:
newGeneration- New Generation- Returns:
- New instance
-
removeSnapshot
public RepositoryData removeSnapshot(SnapshotId snapshotId, ShardGenerations updatedShardGenerations)Remove a snapshot and remove any indices that no longer exist in the repository due to the deletion of the snapshot.- Parameters:
snapshotId- Snapshot IdupdatedShardGenerations- 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
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
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. -
resolveNewIndices
public java.util.List<IndexId> resolveNewIndices(java.util.List<java.lang.String> indicesToResolve)Resolve the given index names to index ids, creating new index ids for new indices in the repository. -
snapshotsToXContent
public XContentBuilder snapshotsToXContent(XContentBuilder builder, boolean shouldWriteShardGens) throws java.io.IOExceptionWrites the snapshots metadata and the related indices metadata to x-content.- Throws:
java.io.IOException
-
snapshotsFromXContent
public static RepositoryData snapshotsFromXContent(XContentParser parser, long genId) throws java.io.IOExceptionReads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.- Throws:
java.io.IOException
-