Package org.elasticsearch.repositories
Class IndexMetaDataGenerations
java.lang.Object
org.elasticsearch.repositories.IndexMetaDataGenerations
public final class IndexMetaDataGenerations
extends java.lang.Object
Tracks the blob uuids of blobs containing
IndexMetadata for snapshots as well an identifier for each of these blobs.
Before writing a new IndexMetadata blob during snapshot finalization in
BlobStoreRepository.finalizeSnapshot(org.elasticsearch.repositories.ShardGenerations, long, org.elasticsearch.cluster.metadata.Metadata, org.elasticsearch.snapshots.SnapshotInfo, org.elasticsearch.Version, java.util.function.Function<org.elasticsearch.cluster.ClusterState, org.elasticsearch.cluster.ClusterState>, org.elasticsearch.action.ActionListener<org.elasticsearch.repositories.RepositoryData>) the identifier for an instance of
IndexMetadata should be computed and then used to check if it already exists in the repository via
getIndexMetaBlobId(String).-
Field Summary
Fields Modifier and Type Field Description static IndexMetaDataGenerationsEMPTY -
Method Summary
Modifier and Type Method Description static java.lang.StringbuildUniqueIdentifier(IndexMetadata indexMetaData)Compute identifier forIndexMetadatafrom its index- and history-uuid as well as its settings-, mapping- and alias-version.booleanequals(java.lang.Object that)java.lang.StringgetIndexMetaBlobId(java.lang.String metaIdentifier)Gets the blob id by the identifier ofIndexMetadata(computed viabuildUniqueIdentifier(org.elasticsearch.cluster.metadata.IndexMetadata)) ornullif none is tracked for the identifier.inthashCode()java.lang.StringindexMetaBlobId(SnapshotId snapshotId, IndexId indexId)Get the blob id bySnapshotIdandIndexIdand fall back to the value ofSnapshotId.getUUID()if none is known to enable backwards compatibility with versions older thanSnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSIONwhich used the snapshot uuid as index metadata blob uuid.booleanisEmpty()java.lang.StringtoString()IndexMetaDataGenerationswithAddedSnapshot(SnapshotId snapshotId, java.util.Map<IndexId,java.lang.String> newLookup, java.util.Map<java.lang.String,java.lang.String> newIdentifiers)Create a new instance with the given snapshot and index metadata uuids and identifiers added.IndexMetaDataGenerationswithRemovedSnapshots(java.util.Collection<SnapshotId> snapshotIds)Create a new instance with the given snapshot removed.
-
Field Details
-
Method Details
-
isEmpty
public boolean isEmpty() -
getIndexMetaBlobId
@Nullable public java.lang.String getIndexMetaBlobId(java.lang.String metaIdentifier)Gets the blob id by the identifier ofIndexMetadata(computed viabuildUniqueIdentifier(org.elasticsearch.cluster.metadata.IndexMetadata)) ornullif none is tracked for the identifier.- Parameters:
metaIdentifier- identifier forIndexMetadata- Returns:
- blob id for the given metadata identifier or
nullif the identifier is not part of the repository yet
-
indexMetaBlobId
Get the blob id bySnapshotIdandIndexIdand fall back to the value ofSnapshotId.getUUID()if none is known to enable backwards compatibility with versions older thanSnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSIONwhich used the snapshot uuid as index metadata blob uuid.- Parameters:
snapshotId- Snapshot IdindexId- Index Id- Returns:
- blob id for the given index metadata
-
withAddedSnapshot
public IndexMetaDataGenerations withAddedSnapshot(SnapshotId snapshotId, java.util.Map<IndexId,java.lang.String> newLookup, java.util.Map<java.lang.String,java.lang.String> newIdentifiers)Create a new instance with the given snapshot and index metadata uuids and identifiers added.- Parameters:
snapshotId- SnapshotIdnewLookup- new mappings of index + snapshot to index metadata identifiernewIdentifiers- new mappings of index metadata identifier to blob id- Returns:
- instance with added snapshot
-
withRemovedSnapshots
Create a new instance with the given snapshot removed.- Parameters:
snapshotIds- SnapshotIds to remove- Returns:
- new instance without the given snapshot
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object that)- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
buildUniqueIdentifier
Compute identifier forIndexMetadatafrom its index- and history-uuid as well as its settings-, mapping- and alias-version. If an index did not see a change in its settings, mappings or aliases between two points in time then the identifier will not change between them either.- Parameters:
indexMetaData- IndexMetaData- Returns:
- identifier string
-