Package org.elasticsearch.repositories
Class RepositoryData
- java.lang.Object
-
- org.elasticsearch.repositories.RepositoryData
-
public final class RepositoryData extends java.lang.ObjectA 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 RepositoryDataEMPTYAn instance initialized for an empty repository.static longEMPTY_REPO_GENThe generation value indicating the repository has no index generational files.
-
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<IndexId,java.util.Set<SnapshotId>> indexSnapshots, java.util.List<SnapshotId> incompatibleSnapshotIds)
-
Method Summary
Modifier and Type Method Description RepositoryDataaddSnapshot(SnapshotId snapshotId, SnapshotState snapshotState, java.util.List<IndexId> snapshottedIndices)Add a snapshot and its indices to the repository; returns a new instance.protected RepositoryDatacopy()booleanequals(java.lang.Object obj)java.util.Collection<SnapshotId>getAllSnapshotIds()Returns an immutable collection of all the snapshot ids in the repository, both active and incompatible snapshots.longgetGenId()Gets the generational index file id from which this instance was read.java.util.Collection<SnapshotId>getIncompatibleSnapshotIds()Returns an immutable collection of the snapshot ids in the repository that are incompatible with the current ES version.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.inthashCode()RepositoryDataincompatibleSnapshotsFromXContent(XContentParser parser)Reads the incompatible snapshot ids from x-content, loading them into a new instance ofRepositoryDatathat is created from the invoking instance, plus the incompatible snapshots that are read from x-content.XContentBuilderincompatibleSnapshotsToXContent(XContentBuilder builder, ToXContent.Params params)Writes the incompatible snapshot ids to x-content.RepositoryDataremoveSnapshot(SnapshotId snapshotId)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.static RepositoryDatasnapshotsFromXContent(XContentParser parser, long genId)Reads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.XContentBuildersnapshotsToXContent(XContentBuilder builder, ToXContent.Params params)Writes the snapshots metadata and the related indices metadata to x-content, omitting the incompatible snapshots.
-
-
-
Field Detail
-
EMPTY_REPO_GEN
public static final long EMPTY_REPO_GEN
The generation value indicating the repository has no index generational files.- See Also:
- Constant Field Values
-
EMPTY
public static final RepositoryData EMPTY
An instance initialized for an empty repository.
-
-
Constructor Detail
-
RepositoryData
public RepositoryData(long genId, java.util.Map<java.lang.String,SnapshotId> snapshotIds, java.util.Map<java.lang.String,SnapshotState> snapshotStates, java.util.Map<IndexId,java.util.Set<SnapshotId>> indexSnapshots, java.util.List<SnapshotId> incompatibleSnapshotIds)
-
-
Method Detail
-
copy
protected RepositoryData copy()
-
getGenId
public long getGenId()
Gets the generational index file id from which this instance was read.
-
getSnapshotIds
public java.util.Collection<SnapshotId> getSnapshotIds()
Returns an unmodifiable collection of the snapshot ids.
-
getIncompatibleSnapshotIds
public java.util.Collection<SnapshotId> getIncompatibleSnapshotIds()
Returns an immutable collection of the snapshot ids in the repository that are incompatible with the current ES version.
-
getAllSnapshotIds
public java.util.Collection<SnapshotId> getAllSnapshotIds()
Returns an immutable collection of all the snapshot ids in the repository, both active and incompatible snapshots.
-
getSnapshotState
@Nullable public SnapshotState getSnapshotState(SnapshotId snapshotId)
Returns theSnapshotStatefor the given snapshot. Returnsnullif there is no state for the snapshot.
-
getIndices
public java.util.Map<java.lang.String,IndexId> getIndices()
Returns an unmodifiable map of the index names toIndexIdin the repository.
-
addSnapshot
public RepositoryData addSnapshot(SnapshotId snapshotId, SnapshotState snapshotState, java.util.List<IndexId> snapshottedIndices)
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.
-
removeSnapshot
public RepositoryData removeSnapshot(SnapshotId snapshotId)
Remove a snapshot and remove any indices that no longer exist in the repository due to the deletion of the snapshot.
-
getSnapshots
public java.util.Set<SnapshotId> getSnapshots(IndexId indexId)
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
public IndexId resolveIndexId(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.
-
resolveIndices
public java.util.List<IndexId> resolveIndices(java.util.List<java.lang.String> indices)
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, ToXContent.Params params) throws java.io.IOException
Writes the snapshots metadata and the related indices metadata to x-content, omitting the incompatible snapshots.- Throws:
java.io.IOException
-
snapshotsFromXContent
public static RepositoryData snapshotsFromXContent(XContentParser parser, long genId) throws java.io.IOException
Reads an instance ofRepositoryDatafrom x-content, loading the snapshots and indices metadata.- Throws:
java.io.IOException
-
incompatibleSnapshotsToXContent
public XContentBuilder incompatibleSnapshotsToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
Writes the incompatible snapshot ids to x-content.- Throws:
java.io.IOException
-
incompatibleSnapshotsFromXContent
public RepositoryData incompatibleSnapshotsFromXContent(XContentParser parser) throws java.io.IOException
Reads the incompatible snapshot ids from x-content, loading them into a new instance ofRepositoryDatathat is created from the invoking instance, plus the incompatible snapshots that are read from x-content.- Throws:
java.io.IOException
-
-