Interface Repository
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,LifecycleComponent
,Releasable
- All Known Implementing Classes:
BlobStoreRepository
,FilterRepository
,FsRepository
,MeteredBlobStoreRepository
public interface Repository extends LifecycleComponent
Implementations are responsible for reading and writing both metadata and shard data to and from a repository backend.
To perform a snapshot:
- Data nodes call
snapshotShard(org.elasticsearch.index.store.Store, org.elasticsearch.index.mapper.MapperService, org.elasticsearch.snapshots.SnapshotId, org.elasticsearch.repositories.IndexId, org.apache.lucene.index.IndexCommit, java.lang.String, org.elasticsearch.index.snapshots.IndexShardSnapshotStatus, org.elasticsearch.Version, java.util.Map<java.lang.String, java.lang.Object>, org.elasticsearch.action.ActionListener<java.lang.String>)
for each shard - When all shard calls return master calls
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>)
with possible list of failures
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Repository.Factory
An factory interface for constructing repositories. -
Method Summary
Modifier and Type Method Description default java.util.Map<java.lang.String,java.lang.Object>
adaptUserMetadata(java.util.Map<java.lang.String,java.lang.Object> userMetadata)
Hook that allows a repository to filter the user supplied snapshot metadata inSnapshotsInProgress.Entry.userMetadata()
during snapshot initialization.void
cloneShardSnapshot(SnapshotId source, SnapshotId target, RepositoryShardId shardId, java.lang.String shardGeneration, ActionListener<java.lang.String> listener)
Clones a shard snapshot.void
deleteSnapshots(java.util.Collection<SnapshotId> snapshotIds, long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryData> listener)
Deletes snapshotsvoid
endVerification(java.lang.String verificationToken)
Called at the end of repository verification process.void
executeConsistentStateUpdate(java.util.function.Function<RepositoryData,ClusterStateUpdateTask> createUpdateTask, java.lang.String source, java.util.function.Consumer<java.lang.Exception> onFailure)
Execute a cluster state update with a consistent view of the currentRepositoryData
.void
finalizeSnapshot(ShardGenerations shardGenerations, long repositoryStateId, Metadata clusterMetadata, SnapshotInfo snapshotInfo, Version repositoryMetaVersion, java.util.function.Function<ClusterState,ClusterState> stateTransformer, ActionListener<RepositoryData> listener)
Finalizes snapshotting processRepositoryMetadata
getMetadata()
Returns metadata about this repository.void
getRepositoryData(ActionListener<RepositoryData> listener)
Returns aRepositoryData
to describe the data in the repository, including the snapshots and the indices across all snapshots found in the repository.long
getRestoreThrottleTimeInNanos()
Returns restore throttle time in nanosecondsIndexShardSnapshotStatus
getShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId)
Retrieve shard snapshot status for the stored snapshotMetadata
getSnapshotGlobalMetadata(SnapshotId snapshotId)
Returns global metadata associated with the snapshot.IndexMetadata
getSnapshotIndexMetaData(RepositoryData repositoryData, SnapshotId snapshotId, IndexId index)
Returns the index metadata associated with the snapshot.SnapshotInfo
getSnapshotInfo(SnapshotId snapshotId)
Reads snapshot description from repository.long
getSnapshotThrottleTimeInNanos()
Returns snapshot throttle time in nanosecondsvoid
initializeSnapshot(SnapshotId snapshotId, java.util.List<IndexId> indices, Metadata metadata)
Deprecated.boolean
isReadOnly()
Returns true if the repository supports only read operationsvoid
restoreShard(Store store, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState, ActionListener<java.lang.Void> listener)
Restores snapshot of the shard.void
snapshotShard(Store store, MapperService mapperService, SnapshotId snapshotId, IndexId indexId, org.apache.lucene.index.IndexCommit snapshotIndexCommit, java.lang.String shardStateIdentifier, IndexShardSnapshotStatus snapshotStatus, Version repositoryMetaVersion, java.util.Map<java.lang.String,java.lang.Object> userMetadata, ActionListener<java.lang.String> listener)
Creates a snapshot of the shard based on the index commit point.java.lang.String
startVerification()
Verifies repository on the master node and returns the verification token.default RepositoryStats
stats()
Returns stats on the repository usagevoid
updateState(ClusterState state)
Update the repository with the incoming cluster state.void
verify(java.lang.String verificationToken, DiscoveryNode localNode)
Verifies repository settings on data node.Methods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stop
Methods inherited from interface org.elasticsearch.common.lease.Releasable
close
-
Method Details
-
getMetadata
RepositoryMetadata getMetadata()Returns metadata about this repository. -
getSnapshotInfo
Reads snapshot description from repository.- Parameters:
snapshotId
- snapshot id- Returns:
- information about snapshot
-
getSnapshotGlobalMetadata
Returns global metadata associated with the snapshot.- Parameters:
snapshotId
- the snapshot id to load the global metadata from- Returns:
- the global metadata about the snapshot
-
getSnapshotIndexMetaData
IndexMetadata getSnapshotIndexMetaData(RepositoryData repositoryData, SnapshotId snapshotId, IndexId index) throws java.io.IOExceptionReturns the index metadata associated with the snapshot.- Parameters:
repositoryData
- currentRepositoryData
snapshotId
- the snapshot id to load the index metadata fromindex
- theIndexId
to load the metadata from- Returns:
- the index metadata about the given index for the given snapshot
- Throws:
java.io.IOException
-
getRepositoryData
Returns aRepositoryData
to describe the data in the repository, including the snapshots and the indices across all snapshots found in the repository. Throws aRepositoryException
if there was an error in reading the data.- Parameters:
listener
- listener that may be resolved on different kinds of threads including transport and cluster state applier threads and therefore must fork to a new thread for executing any long running actions
-
initializeSnapshot
@Deprecated void initializeSnapshot(SnapshotId snapshotId, java.util.List<IndexId> indices, Metadata metadata)Deprecated.this method is only used when taking snapshots in a mixed version cluster where a master node older thanSnapshotsService.NO_REPO_INITIALIZE_VERSION
is present.Starts snapshotting process- Parameters:
snapshotId
- snapshot idindices
- list of indices to be snapshottedmetadata
- cluster metadata
-
finalizeSnapshot
void finalizeSnapshot(ShardGenerations shardGenerations, long repositoryStateId, Metadata clusterMetadata, SnapshotInfo snapshotInfo, Version repositoryMetaVersion, java.util.function.Function<ClusterState,ClusterState> stateTransformer, ActionListener<RepositoryData> listener)Finalizes snapshotting processThis method is called on master after all shards are snapshotted.
- Parameters:
shardGenerations
- updated shard generationsrepositoryStateId
- the unique id identifying the state of the repository when the snapshot beganclusterMetadata
- cluster metadatasnapshotInfo
- SnapshotInfo instance to write for this snapshotrepositoryMetaVersion
- version of the updated repository metadata to writestateTransformer
- a function that filters the last cluster state update that the snapshot finalization will execute and is used to remove any state tracked for the in-progress snapshot from the cluster statelistener
- listener to be invoked with the newRepositoryData
after completing the snapshot
-
deleteSnapshots
void deleteSnapshots(java.util.Collection<SnapshotId> snapshotIds, long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryData> listener)Deletes snapshots- Parameters:
snapshotIds
- snapshot idsrepositoryStateId
- the unique id identifying the state of the repository when the snapshot deletion beganrepositoryMetaVersion
- version of the updated repository metadata to writelistener
- completion listener
-
getSnapshotThrottleTimeInNanos
long getSnapshotThrottleTimeInNanos()Returns snapshot throttle time in nanoseconds -
getRestoreThrottleTimeInNanos
long getRestoreThrottleTimeInNanos()Returns restore throttle time in nanoseconds -
stats
Returns stats on the repository usage -
startVerification
java.lang.String startVerification()Verifies repository on the master node and returns the verification token.If the verification token is not null, it's passed to all data nodes for verification. If it's null - no additional verification is required
- Returns:
- verification token that should be passed to all Index Shard Repositories for additional verification or null
-
endVerification
void endVerification(java.lang.String verificationToken)Called at the end of repository verification process.This method should perform all necessary cleanup of the temporary files created in the repository
- Parameters:
verificationToken
- verification request generated bystartVerification()
command
-
verify
Verifies repository settings on data node.- Parameters:
verificationToken
- value returned bystartVerification()
localNode
- the local node information, for inclusion in verification errors
-
isReadOnly
boolean isReadOnly()Returns true if the repository supports only read operations- Returns:
- true if the repository is read/only
-
snapshotShard
void snapshotShard(Store store, MapperService mapperService, SnapshotId snapshotId, IndexId indexId, org.apache.lucene.index.IndexCommit snapshotIndexCommit, @Nullable java.lang.String shardStateIdentifier, IndexShardSnapshotStatus snapshotStatus, Version repositoryMetaVersion, java.util.Map<java.lang.String,java.lang.Object> userMetadata, ActionListener<java.lang.String> listener)Creates a snapshot of the shard based on the index commit point.The index commit point can be obtained by using
Engine.acquireLastIndexCommit(boolean)
method. Repository implementations shouldn't release the snapshot index commit point. It is done by the method caller.As snapshot process progresses, implementation of this method should update
IndexShardSnapshotStatus
object and checkIndexShardSnapshotStatus.isAborted()
to see if the snapshot process should be aborted.- Parameters:
store
- store to be snapshottedmapperService
- the shards mapper servicesnapshotId
- snapshot idindexId
- id for the index being snapshottedsnapshotIndexCommit
- commit pointshardStateIdentifier
- a unique identifier of the state of the shard that is stored with the shard's snapshot and used to detect if the shard has changed between snapshots. Ifnull
is passed as the identifier snapshotting will be done by inspecting the physical files referenced bysnapshotIndexCommit
snapshotStatus
- snapshot statusrepositoryMetaVersion
- version of the updated repository metadata to writeuserMetadata
- user metadata of the snapshot found inSnapshotsInProgress.Entry.userMetadata()
listener
- listener invoked on completion
-
restoreShard
void restoreShard(Store store, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState, ActionListener<java.lang.Void> listener)Restores snapshot of the shard.The index can be renamed on restore, hence different
shardId
andsnapshotShardId
are supplied.- Parameters:
store
- the store to restore the index intosnapshotId
- snapshot idindexId
- id of the index in the repository from which the restore is occurringsnapshotShardId
- shard id (in the snapshot)recoveryState
- recovery statelistener
- listener to invoke once done
-
getShardSnapshotStatus
IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId)Retrieve shard snapshot status for the stored snapshot- Parameters:
snapshotId
- snapshot idindexId
- the snapshotted index id for the shard to get status forshardId
- shard id- Returns:
- snapshot status
-
updateState
Update the repository with the incoming cluster state. This method is invoked fromRepositoriesService.applyClusterState(org.elasticsearch.cluster.ClusterChangedEvent)
and thus the same semantics as withClusterStateApplier.applyClusterState(org.elasticsearch.cluster.ClusterChangedEvent)
apply for theClusterState
that is passed here.- Parameters:
state
- new cluster state
-
executeConsistentStateUpdate
void executeConsistentStateUpdate(java.util.function.Function<RepositoryData,ClusterStateUpdateTask> createUpdateTask, java.lang.String source, java.util.function.Consumer<java.lang.Exception> onFailure)Execute a cluster state update with a consistent view of the currentRepositoryData
. TheClusterState
passed to the task generated throughcreateUpdateTask
is guaranteed to point at the same state for this repository as the did the state at the time theRepositoryData
was loaded. This allows for operations on the repository that need a consistent view of both the cluster state and the repository contents at one point in time like for example, checking if a snapshot is in the repository before adding the delete operation for it to the cluster state.- Parameters:
createUpdateTask
- function to supply cluster state update tasksource
- the source of the cluster state update taskonFailure
- error handler invoked on failure to get a consistent view of the currentRepositoryData
-
cloneShardSnapshot
void cloneShardSnapshot(SnapshotId source, SnapshotId target, RepositoryShardId shardId, @Nullable java.lang.String shardGeneration, ActionListener<java.lang.String> listener)Clones a shard snapshot.- Parameters:
source
- source snapshottarget
- target snapshotshardId
- shard idshardGeneration
- shard generation in repolistener
- listener to complete with new shard generation once clone has completed
-
adaptUserMetadata
default java.util.Map<java.lang.String,java.lang.Object> adaptUserMetadata(java.util.Map<java.lang.String,java.lang.Object> userMetadata)Hook that allows a repository to filter the user supplied snapshot metadata inSnapshotsInProgress.Entry.userMetadata()
during snapshot initialization.
-
SnapshotsService.NO_REPO_INITIALIZE_VERSION
is present.