Interface Repository
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable,LifecycleComponent,Releasable
- All Known Implementing Classes:
BlobStoreRepository,FilterRepository,FsRepository
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, org.elasticsearch.index.snapshots.IndexShardSnapshotStatus, boolean, org.elasticsearch.action.ActionListener<java.lang.String>)for each shard - When all shard calls return master calls
finalizeSnapshot(org.elasticsearch.snapshots.SnapshotId, org.elasticsearch.repositories.ShardGenerations, long, java.lang.String, int, java.util.List<org.elasticsearch.snapshots.SnapshotShardFailure>, long, boolean, org.elasticsearch.cluster.metadata.MetaData, java.util.Map<java.lang.String, java.lang.Object>, boolean, org.elasticsearch.action.ActionListener<org.elasticsearch.snapshots.SnapshotInfo>)with possible list of failures
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceRepository.FactoryAn factory interface for constructing repositories. -
Method Summary
Modifier and Type Method Description voiddeleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener<java.lang.Void> listener)Deletes snapshotvoidendVerification(java.lang.String verificationToken)Called at the end of repository verification process.voidfinalizeSnapshot(SnapshotId snapshotId, ShardGenerations shardGenerations, long startTime, java.lang.String failure, int totalShards, java.util.List<SnapshotShardFailure> shardFailures, long repositoryStateId, boolean includeGlobalState, MetaData clusterMetaData, java.util.Map<java.lang.String,java.lang.Object> userMetadata, boolean writeShardGens, ActionListener<SnapshotInfo> listener)Finalizes snapshotting processRepositoryMetaDatagetMetadata()Returns metadata about this repository.voidgetRepositoryData(ActionListener<RepositoryData> listener)Returns aRepositoryDatato describe the data in the repository, including the snapshots and the indices across all snapshots found in the repository.longgetRestoreThrottleTimeInNanos()Returns restore throttle time in nanosecondsIndexShardSnapshotStatusgetShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId)Retrieve shard snapshot status for the stored snapshotMetaDatagetSnapshotGlobalMetaData(SnapshotId snapshotId)Returns global metadata associated with the snapshot.IndexMetaDatagetSnapshotIndexMetaData(SnapshotId snapshotId, IndexId index)Returns the index metadata associated with the snapshot.SnapshotInfogetSnapshotInfo(SnapshotId snapshotId)Reads snapshot description from repository.longgetSnapshotThrottleTimeInNanos()Returns snapshot throttle time in nanosecondsvoidinitializeSnapshot(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_VERSIONis present.booleanisReadOnly()Returns true if the repository supports only read operationsvoidrestoreShard(Store store, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState, ActionListener<java.lang.Void> listener)Restores snapshot of the shard.voidsnapshotShard(Store store, MapperService mapperService, SnapshotId snapshotId, IndexId indexId, org.apache.lucene.index.IndexCommit snapshotIndexCommit, IndexShardSnapshotStatus snapshotStatus, boolean writeShardGens, ActionListener<java.lang.String> listener)Creates a snapshot of the shard based on the index commit point.java.lang.StringstartVerification()Verifies repository on the master node and returns the verification token.voidupdateState(ClusterState state)Update the repository with the incoming cluster state.voidverify(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
-
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(SnapshotId snapshotId, IndexId index) throws java.io.IOExceptionReturns the index metadata associated with the snapshot.- Parameters:
snapshotId- the snapshot id to load the index metadata fromindex- theIndexIdto load the metadata from- Returns:
- the index metadata about the given index for the given snapshot
- Throws:
java.io.IOException
-
getRepositoryData
Returns aRepositoryDatato describe the data in the repository, including the snapshots and the indices across all snapshots found in the repository. Throws aRepositoryExceptionif there was an error in reading the data. -
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_VERSIONis present.Starts snapshotting process- Parameters:
snapshotId- snapshot idindices- list of indices to be snapshottedmetaData- cluster metadata
-
finalizeSnapshot
void finalizeSnapshot(SnapshotId snapshotId, ShardGenerations shardGenerations, long startTime, java.lang.String failure, int totalShards, java.util.List<SnapshotShardFailure> shardFailures, long repositoryStateId, boolean includeGlobalState, MetaData clusterMetaData, java.util.Map<java.lang.String,java.lang.Object> userMetadata, boolean writeShardGens, ActionListener<SnapshotInfo> listener)Finalizes snapshotting processThis method is called on master after all shards are snapshotted.
- Parameters:
snapshotId- snapshot idshardGenerations- updated shard generationsstartTime- start time of the snapshotfailure- global failure reason or nulltotalShards- total number of shardsshardFailures- list of shard failuresrepositoryStateId- the unique id identifying the state of the repository when the snapshot beganincludeGlobalState- include cluster global stateclusterMetaData- cluster metadatauserMetadata- user metadatawriteShardGens- if shard generations should be written to the repositorylistener- listener to be called on completion of the snapshot
-
deleteSnapshot
void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener<java.lang.Void> listener)Deletes snapshot- Parameters:
snapshotId- snapshot idrepositoryStateId- the unique id identifying the state of the repository when the snapshot deletion beganwriteShardGens- if shard generations should be written to the repositorylistener- completion listener
-
getSnapshotThrottleTimeInNanos
long getSnapshotThrottleTimeInNanos()Returns snapshot throttle time in nanoseconds -
getRestoreThrottleTimeInNanos
long getRestoreThrottleTimeInNanos()Returns restore throttle time in nanoseconds -
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, IndexShardSnapshotStatus snapshotStatus, boolean writeShardGens, 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
IndexShardSnapshotStatusobject 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 pointsnapshotStatus- snapshot statuslistener- 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
shardIdandsnapshotShardIdare 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 theClusterStatethat is passed here.- Parameters:
state- new cluster state
-