Class BlobStoreRepository
- All Implemented Interfaces:
Closeable,AutoCloseable,LifecycleComponent,org.elasticsearch.core.Releasable,Repository
- Direct Known Subclasses:
FsRepository,MeteredBlobStoreRepository
This repository works with any BlobStore implementation. The blobStore could be (and preferred) lazy initialized in
createBlobStore().
org.elasticsearch.repositories.blobstore.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.repositories.Repository
Repository.Factory -
Field Summary
FieldsModifier and TypeFieldDescriptionWhen set totrue,bestEffortConsistencywill be set totrueand concurrent modifications of the repository contents will not result in the repository being marked as corrupted.protected BigArraysstatic Setting<ByteSizeValue>Size hint for the IO buffer size to use when reading from and writing to the repository.protected intIO buffer size hint for reading and writing to the underlying blob store.Setting to disable caching of the latest repository data.static ChecksumBlobStoreFormat<Metadata>static Stringstatic Stringstatic ChecksumBlobStoreFormat<IndexMetadata>static Setting<ByteSizeValue>static Setting<ByteSizeValue>Setting that defines the maximum number of snapshots to which the repository may grow.protected RepositoryMetadatastatic Stringstatic Stringstatic StringAllBlobStoreRepositoryimplementations can be made read-only by setting this key totruein their settings.static ChecksumBlobStoreFormat<SnapshotInfo>static Stringstatic StringSetting to disable writing theindex.latestblob which enables the contents of this repository to be used with a url-repository.protected booleanprotected ThreadPoolstatic Stringstatic StringFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlobStoreRepository(RepositoryMetadata metadata, boolean compress, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, ClusterService clusterService, BigArrays bigArrays, RecoverySettings recoverySettings)Constructs new BlobStoreRepository -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabstract BlobPathbasePath()Returns base path of the repositoryprotected BlobContainermaintains single lazy instance ofBlobContainerMaintains single lazy instance ofBlobStore.booleancanUpdateInPlace(Settings updatedSettings, Set<String> ignoredSettings)Check if this instancesSettingscan be changed to the provided updated settings without recreating the repository.protected ByteSizeValueReturns data file chunk size.voidcleanup(long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryCleanupResult> listener)Runs cleanup actions on the repository.voidcloneShardSnapshot(SnapshotId source, SnapshotId target, RepositoryShardId shardId, String shardGeneration, ActionListener<ShardSnapshotResult> listener)Clones a shard snapshot.protected abstract BlobStoreCreates new BlobStore to read and write data.voiddeleteSnapshots(Collection<SnapshotId> snapshotIds, long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryData> listener)Deletes snapshotsprotected voiddoClose()protected voiddoStart()protected voiddoStop()voidendVerification(String seed)Called at the end of repository verification process.voidexecuteConsistentStateUpdate(Function<RepositoryData,ClusterStateUpdateTask> createUpdateTask, String source, Consumer<Exception> onFailure)Execute a cluster state update with a consistent view of the currentRepositoryData.voidfinalizeSnapshot(ShardGenerations shardGenerations, long repositoryStateId, Metadata clusterMetadata, SnapshotInfo snapshotInfo, Version repositoryMetaVersion, Function<ClusterState,ClusterState> stateTransformer, ActionListener<RepositoryData> listener)Finalizes snapshotting processprotected BlobStoreReturns 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.longReturns restore throttle time in nanosecondsgetShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId)Retrieve shard snapshot status for the stored snapshotgetSnapshotGlobalMetadata(SnapshotId snapshotId)Returns global metadata associated with the snapshot.getSnapshotIndexMetaData(RepositoryData repositoryData, SnapshotId snapshotId, IndexId index)Returns the index metadata associated with the snapshot.voidgetSnapshotInfo(GetSnapshotInfoContext context)Reads snapshot descriptions from the repository.longReturns snapshot throttle time in nanosecondsbooleanvoidinitializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, Metadata clusterMetadata)Starts snapshotting processprotected booleanReturns true if metadata and snapshot files should be compressedbooleanReturns true if the repository supports only read operationsloadShardSnapshot(BlobContainer shardContainer, SnapshotId snapshotId)Loads information about shard snapshotmaybeRateLimitRestores(InputStream stream)Wrap the restore rate limiter (controlled by the repository setting `max_restore_bytes_per_sec` and the cluster setting `indices.recovery.max_bytes_per_sec`) around the given stream.maybeRateLimitRestores(InputStream stream, RateLimitingInputStream.Listener throttleListener)Wrap the restore rate limiter (controlled by the repository setting `max_restore_bytes_per_sec` and the cluster setting `indices.recovery.max_bytes_per_sec`) around the given stream.maybeRateLimitSnapshots(InputStream stream)Wrap the snapshot rate limiter (controlled by the repository setting `max_snapshot_bytes_per_sec`) around the given stream.maybeRateLimitSnapshots(InputStream stream, RateLimitingInputStream.Listener throttleListener)Wrap the snapshot rate limiter (controlled by the repository setting `max_snapshot_bytes_per_sec`) around the given stream.voidrestoreShard(Store store, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState, ActionListener<Void> listener)Restores snapshot of the shard.shardContainer(IndexId indexId, int shardId)voidsnapshotShard(SnapshotShardContext context)Creates a snapshot of the shard referenced by the givenSnapshotShardContext.Verifies repository on the master node and returns the verification token.stats()Returns stats on the repository usagebooleantoString()voidupdateState(ClusterState state)Update the repository with the incoming cluster state.voidverify(String seed, DiscoveryNode localNode)Verifies repository settings on data node.protected voidwriteIndexGen(RepositoryData repositoryData, long expectedGen, Version version, Function<ClusterState,ClusterState> stateFilter, ActionListener<RepositoryData> listener)Writing a new index generation is a three step process.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stopMethods inherited from interface org.elasticsearch.core.Releasable
closeMethods inherited from interface org.elasticsearch.repositories.Repository
adaptUserMetadata, getSnapshotInfo
-
Field Details
-
metadata
-
threadPool
-
SNAPSHOT_PREFIX
- See Also:
- Constant Field Values
-
INDEX_FILE_PREFIX
- See Also:
- Constant Field Values
-
INDEX_LATEST_BLOB
- See Also:
- Constant Field Values
-
METADATA_PREFIX
- See Also:
- Constant Field Values
-
METADATA_NAME_FORMAT
- See Also:
- Constant Field Values
-
SNAPSHOT_NAME_FORMAT
- See Also:
- Constant Field Values
-
UPLOADED_DATA_BLOB_PREFIX
- See Also:
- Constant Field Values
-
URL_REPOSITORY_TYPE
- See Also:
- Constant Field Values
-
READONLY_SETTING_KEY
AllBlobStoreRepositoryimplementations can be made read-only by setting this key totruein their settings.- See Also:
- Constant Field Values
-
ALLOW_CONCURRENT_MODIFICATION
When set totrue,bestEffortConsistencywill be set totrueand concurrent modifications of the repository contents will not result in the repository being marked as corrupted. Note: This setting is intended as a backwards compatibility solution for 7.x and will go away in 8. -
CACHE_REPOSITORY_DATA
Setting to disable caching of the latest repository data. -
BUFFER_SIZE_SETTING
Size hint for the IO buffer size to use when reading from and writing to the repository. -
SUPPORT_URL_REPO
Setting to disable writing theindex.latestblob which enables the contents of this repository to be used with a url-repository. -
MAX_SNAPSHOTS_SETTING
Setting that defines the maximum number of snapshots to which the repository may grow. Trying to create a snapshot into the repository that would move it above this size will throw an exception. -
supportURLRepo
protected final boolean supportURLRepo -
GLOBAL_METADATA_FORMAT
-
INDEX_METADATA_FORMAT
-
SNAPSHOT_FORMAT
-
INDEX_SHARD_SNAPSHOT_FORMAT
public static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshot> INDEX_SHARD_SNAPSHOT_FORMAT -
INDEX_SHARD_SNAPSHOTS_FORMAT
public static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshots> INDEX_SHARD_SNAPSHOTS_FORMAT -
MAX_SNAPSHOT_BYTES_PER_SEC
-
MAX_RESTORE_BYTES_PER_SEC
-
bigArrays
-
bufferSize
protected final int bufferSizeIO buffer size hint for reading and writing to the underlying blob store.
-
-
Constructor Details
-
BlobStoreRepository
protected BlobStoreRepository(RepositoryMetadata metadata, boolean compress, org.elasticsearch.common.xcontent.NamedXContentRegistry namedXContentRegistry, ClusterService clusterService, BigArrays bigArrays, RecoverySettings recoverySettings)Constructs new BlobStoreRepository- Parameters:
metadata- The metadata for this repository including name and settingsclusterService- ClusterService
-
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClosein classAbstractLifecycleComponent
-
executeConsistentStateUpdate
public void executeConsistentStateUpdate(Function<RepositoryData,ClusterStateUpdateTask> createUpdateTask, String source, Consumer<Exception> onFailure)Description copied from interface:RepositoryExecute a cluster state update with a consistent view of the currentRepositoryData. TheClusterStatepassed to the task generated throughcreateUpdateTaskis guaranteed to point at the same state for this repository as the did the state at the time theRepositoryDatawas 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.- Specified by:
executeConsistentStateUpdatein interfaceRepository- 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
public void cloneShardSnapshot(SnapshotId source, SnapshotId target, RepositoryShardId shardId, @Nullable String shardGeneration, ActionListener<ShardSnapshotResult> listener)Description copied from interface:RepositoryClones a shard snapshot.- Specified by:
cloneShardSnapshotin interfaceRepository- Parameters:
source- source snapshottarget- target snapshotshardId- shard idshardGeneration- shard generation in repolistener- listener to complete with new shard generation once clone has completed
-
canUpdateInPlace
Description copied from interface:RepositoryCheck if this instancesSettingscan be changed to the provided updated settings without recreating the repository.- Specified by:
canUpdateInPlacein interfaceRepository- Parameters:
updatedSettings- new repository settingsignoredSettings- setting names to ignore even if changed- Returns:
- true if the repository can be updated in place
-
updateState
Description copied from interface:RepositoryUpdate 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.- Specified by:
updateStatein interfaceRepository- Parameters:
state- new cluster state
-
threadPool
-
getBlobStore
-
blobContainer
maintains single lazy instance ofBlobContainer -
blobStore
Maintains single lazy instance ofBlobStore. Public for testing. -
createBlobStore
Creates new BlobStore to read and write data.- Throws:
Exception
-
basePath
Returns base path of the repository -
isCompress
protected final boolean isCompress()Returns true if metadata and snapshot files should be compressed- Returns:
- true if compression is needed
-
chunkSize
Returns data file chunk size.This method should return null if no chunking is needed.
- Returns:
- chunk size
-
getMetadata
Description copied from interface:RepositoryReturns metadata about this repository.- Specified by:
getMetadatain interfaceRepository
-
stats
Description copied from interface:RepositoryReturns stats on the repository usage- Specified by:
statsin interfaceRepository
-
initializeSnapshot
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, Metadata clusterMetadata)Description copied from interface:RepositoryStarts snapshotting process- Specified by:
initializeSnapshotin interfaceRepository- Parameters:
snapshotId- snapshot idindices- list of indices to be snapshottedclusterMetadata- cluster metadata
-
deleteSnapshots
public void deleteSnapshots(Collection<SnapshotId> snapshotIds, long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryData> listener)Description copied from interface:RepositoryDeletes snapshots- Specified by:
deleteSnapshotsin interfaceRepository- 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
-
cleanup
public void cleanup(long repositoryStateId, Version repositoryMetaVersion, ActionListener<RepositoryCleanupResult> listener)Runs cleanup actions on the repository. Increments the repository state id by one before executing any modifications on the repository. TODO: Add shard level cleanups TODO: Add unreferenced index metadata cleanup- Deleting stale indices
cleanupStaleIndices(java.util.Map<java.lang.String, org.elasticsearch.common.blobstore.BlobContainer>, java.util.Set<java.lang.String>) - Deleting unreferenced root level blobs
cleanupStaleRootFiles(long, java.util.Collection<org.elasticsearch.snapshots.SnapshotId>, java.util.List<java.lang.String>)
- Parameters:
repositoryStateId- Current repository state idrepositoryMetaVersion- version of the updated repository metadata to writelistener- Listener to complete when done
- Deleting stale indices
-
finalizeSnapshot
public void finalizeSnapshot(ShardGenerations shardGenerations, long repositoryStateId, Metadata clusterMetadata, SnapshotInfo snapshotInfo, Version repositoryMetaVersion, Function<ClusterState,ClusterState> stateTransformer, ActionListener<RepositoryData> listener)Description copied from interface:RepositoryFinalizes snapshotting processThis method is called on master after all shards are snapshotted.
- Specified by:
finalizeSnapshotin interfaceRepository- 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 newRepositoryDataafter completing the snapshot
-
getSnapshotInfo
Description copied from interface:RepositoryReads snapshot descriptions from the repository.- Specified by:
getSnapshotInfoin interfaceRepository- Parameters:
context- get-snapshot-info-context
-
getSnapshotGlobalMetadata
Description copied from interface:RepositoryReturns global metadata associated with the snapshot.- Specified by:
getSnapshotGlobalMetadatain interfaceRepository- Parameters:
snapshotId- the snapshot id to load the global metadata from- Returns:
- the global metadata about the snapshot
-
getSnapshotIndexMetaData
public IndexMetadata getSnapshotIndexMetaData(RepositoryData repositoryData, SnapshotId snapshotId, IndexId index) throws IOExceptionDescription copied from interface:RepositoryReturns the index metadata associated with the snapshot.- Specified by:
getSnapshotIndexMetaDatain interfaceRepository- Parameters:
repositoryData- currentRepositoryDatasnapshotId- 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:
IOException
-
shardContainer
-
getSnapshotThrottleTimeInNanos
public long getSnapshotThrottleTimeInNanos()Description copied from interface:RepositoryReturns snapshot throttle time in nanoseconds- Specified by:
getSnapshotThrottleTimeInNanosin interfaceRepository
-
getRestoreThrottleTimeInNanos
public long getRestoreThrottleTimeInNanos()Description copied from interface:RepositoryReturns restore throttle time in nanoseconds- Specified by:
getRestoreThrottleTimeInNanosin interfaceRepository
-
assertSnapshotOrGenericThread
protected void assertSnapshotOrGenericThread() -
startVerification
Description copied from interface:RepositoryVerifies 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
- Specified by:
startVerificationin interfaceRepository- Returns:
- verification token that should be passed to all Index Shard Repositories for additional verification or null
-
endVerification
Description copied from interface:RepositoryCalled at the end of repository verification process.This method should perform all necessary cleanup of the temporary files created in the repository
- Specified by:
endVerificationin interfaceRepository- Parameters:
seed- verification request generated byRepository.startVerification()command
-
getRepositoryData
Description copied from interface:RepositoryReturns 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.- Specified by:
getRepositoryDatain interfaceRepository- 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
-
isReadOnly
public boolean isReadOnly()Description copied from interface:RepositoryReturns true if the repository supports only read operations- Specified by:
isReadOnlyin interfaceRepository- Returns:
- true if the repository is read/only
-
writeIndexGen
protected void writeIndexGen(RepositoryData repositoryData, long expectedGen, Version version, Function<ClusterState,ClusterState> stateFilter, ActionListener<RepositoryData> listener)Writing a new index generation is a three step process. First, theRepositoryMetadataentry for this repository is set into a pending state by incrementing its pending generationPwhile its safe generationNremains unchanged. Second, the updatedRepositoryDatais written to generationP + 1. Lastly, theRepositoryMetadataentry for this repository is updated to the new generationP + 1and thus pending and safe generation are set to the same value marking the end of the update of the repository data.- Parameters:
repositoryData- RepositoryData to writeexpectedGen- expected repository generation at the start of the operationversion- version of the repository metadata to writestateFilter- filter for the last cluster state update executed by this methodlistener- completion listener
-
snapshotShard
Description copied from interface:RepositoryCreates a snapshot of the shard referenced by the givenSnapshotShardContext.As snapshot process progresses, implementation of this method should update
IndexShardSnapshotStatusobject returned bySnapshotShardContext.status()and check itsIndexShardSnapshotStatus.isAborted()to see if the snapshot process should be aborted.- Specified by:
snapshotShardin interfaceRepository- Parameters:
context- snapshot shard context that must be completed viaSnapshotShardContext.onResponse(org.elasticsearch.repositories.ShardSnapshotResult)orActionListener.Delegating.onFailure(java.lang.Exception)
-
restoreShard
public void restoreShard(Store store, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState, ActionListener<Void> listener)Description copied from interface:RepositoryRestores snapshot of the shard.The index can be renamed on restore, hence different
shardIdandsnapshotShardIdare supplied.- Specified by:
restoreShardin interfaceRepository- 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
-
maybeRateLimitRestores
Wrap the restore rate limiter (controlled by the repository setting `max_restore_bytes_per_sec` and the cluster setting `indices.recovery.max_bytes_per_sec`) around the given stream. Any throttling is reported to the given listener and not otherwise recorded in the value returned bygetRestoreThrottleTimeInNanos(). -
maybeRateLimitRestores
public InputStream maybeRateLimitRestores(InputStream stream, RateLimitingInputStream.Listener throttleListener)Wrap the restore rate limiter (controlled by the repository setting `max_restore_bytes_per_sec` and the cluster setting `indices.recovery.max_bytes_per_sec`) around the given stream. Any throttling is recorded in the value returned bygetRestoreThrottleTimeInNanos(). -
maybeRateLimitSnapshots
Wrap the snapshot rate limiter (controlled by the repository setting `max_snapshot_bytes_per_sec`) around the given stream. Any throttling is recorded in the value returned bygetSnapshotThrottleTimeInNanos(). -
maybeRateLimitSnapshots
public InputStream maybeRateLimitSnapshots(InputStream stream, RateLimitingInputStream.Listener throttleListener)Wrap the snapshot rate limiter (controlled by the repository setting `max_snapshot_bytes_per_sec`) around the given stream. Any throttling is reported to the given listener and not otherwise recorded in the value returned bygetSnapshotThrottleTimeInNanos(). -
getShardSnapshotStatus
public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId)Description copied from interface:RepositoryRetrieve shard snapshot status for the stored snapshot- Specified by:
getShardSnapshotStatusin interfaceRepository- Parameters:
snapshotId- snapshot idindexId- the snapshotted index id for the shard to get status forshardId- shard id- Returns:
- snapshot status
-
verify
Description copied from interface:RepositoryVerifies repository settings on data node.- Specified by:
verifyin interfaceRepository- Parameters:
seed- value returned byRepository.startVerification()localNode- the local node information, for inclusion in verification errors
-
toString
-
loadShardSnapshot
public BlobStoreIndexShardSnapshot loadShardSnapshot(BlobContainer shardContainer, SnapshotId snapshotId)Loads information about shard snapshot -
supportURLRepo
public boolean supportURLRepo() -
hasAtomicOverwrites
public boolean hasAtomicOverwrites()- Returns:
- whether this repository performs overwrites atomically. In practice we only overwrite the `index.latest` blob so this is not very important, but the repository analyzer does test that overwrites happen atomically. It will skip those tests if the repository overrides this method to indicate that it does not support atomic overwrites.
-