Class BlobStoreRepository
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- LifecycleComponent,- 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 SummaryNested classes/interfaces inherited from interface org.elasticsearch.repositories.RepositoryRepository.Factory
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final BigArraysstatic final Setting<ByteSizeValue>Size hint for the IO buffer size to use when reading from and writing to the repository.protected final intIO buffer size hint for reading and writing to the underlying blob store.Setting to disable caching of the latest repository data.When set to true metadata files are stored in compressed format.static final ChecksumBlobStoreFormat<Metadata>static final Stringstatic final Stringstatic final ChecksumBlobStoreFormat<IndexMetadata>static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshot>static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshots>static final Setting<ByteSizeValue>static final Setting<ByteSizeValue>Setting that defines the maximum number of snapshots to which the repository may grow.protected RepositoryMetadatastatic final Stringstatic final Stringstatic final StringAllBlobStoreRepositoryimplementations can be made read-only by setting this key totruein their settings.static final ChecksumBlobStoreFormat<SnapshotInfo>static final Stringstatic final StringSetting to disable writing theindex.latestblob which enables the contents of this repository to be used with a url-repository.protected final booleanprotected final ThreadPoolstatic final Stringstatic final StringSetting that defines if the repository should be used to recover index files during peer recoveries.Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponentlifecycle
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedBlobStoreRepository(RepositoryMetadata metadata, NamedXContentRegistry namedXContentRegistry, ClusterService clusterService, BigArrays bigArrays, RecoverySettings recoverySettings, BlobPath basePath) Constructs new BlobStoreRepository
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidvoidBlock until all in-flight operations for this repository have completed.basePath()Returns base path of the repository Public for testing.protected 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, ShardGeneration 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, SnapshotDeleteListener 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(FinalizeSnapshotContext finalizeSnapshotContext) Finalizes snapshotting processprotected BlobStoregetBlobStoreIndexShardSnapshots(IndexId indexId, int shardId, ShardGeneration shardGen) Loads all available snapshots in the repository using the givengenerationfor a shard.Returns metadata about this repository.intvoidgetRepositoryData(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 nanosecondsbooleanprotected final 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.AbstractLifecycleComponentaddLifecycleListener, close, lifecycleState, start, stopMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.component.LifecycleComponentaddLifecycleListener, lifecycleState, start, stopMethods inherited from interface org.elasticsearch.core.ReleasablecloseMethods inherited from interface org.elasticsearch.repositories.RepositoryadaptUserMetadata, getSnapshotInfo
- 
Field Details- 
metadata
- 
threadPool
- 
SNAPSHOT_PREFIX- See Also:
 
- 
INDEX_FILE_PREFIX- See Also:
 
- 
INDEX_LATEST_BLOB- See Also:
 
- 
METADATA_PREFIX- See Also:
 
- 
METADATA_NAME_FORMAT- See Also:
 
- 
SNAPSHOT_NAME_FORMAT- See Also:
 
- 
UPLOADED_DATA_BLOB_PREFIX- See Also:
 
- 
URL_REPOSITORY_TYPE- See Also:
 
- 
READONLY_SETTING_KEYAllBlobStoreRepositoryimplementations can be made read-only by setting this key totruein their settings.- See Also:
 
- 
COMPRESS_SETTINGWhen set to true metadata files are stored in compressed format. This setting doesn’t affect index files that are already compressed by default. Changing the setting does not invalidate existing files since reads do not observe the setting, instead they examine the file to see if it is compressed or not.
- 
CACHE_REPOSITORY_DATASetting to disable caching of the latest repository data.
- 
BUFFER_SIZE_SETTINGSize hint for the IO buffer size to use when reading from and writing to the repository.
- 
SUPPORT_URL_REPOSetting to disable writing theindex.latestblob which enables the contents of this repository to be used with a url-repository.
- 
MAX_SNAPSHOTS_SETTINGSetting 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.
- 
USE_FOR_PEER_RECOVERY_SETTINGSetting that defines if the repository should be used to recover index files during peer recoveries.
- 
supportURLRepoprotected final boolean supportURLRepo
- 
GLOBAL_METADATA_FORMAT
- 
INDEX_METADATA_FORMAT
- 
SNAPSHOT_FORMAT
- 
INDEX_SHARD_SNAPSHOT_FORMATpublic static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshot> INDEX_SHARD_SNAPSHOT_FORMAT
- 
INDEX_SHARD_SNAPSHOTS_FORMATpublic static final ChecksumBlobStoreFormat<BlobStoreIndexShardSnapshots> INDEX_SHARD_SNAPSHOTS_FORMAT
- 
MAX_SNAPSHOT_BYTES_PER_SEC
- 
MAX_RESTORE_BYTES_PER_SEC
- 
bigArrays
- 
bufferSizeprotected final int bufferSizeIO buffer size hint for reading and writing to the underlying blob store.
 
- 
- 
Constructor Details- 
BlobStoreRepositoryprotected BlobStoreRepository(RepositoryMetadata metadata, NamedXContentRegistry namedXContentRegistry, ClusterService clusterService, BigArrays bigArrays, RecoverySettings recoverySettings, BlobPath basePath) Constructs new BlobStoreRepository- Parameters:
- metadata- The metadata for this repository including name and settings
- clusterService- ClusterService
 
 
- 
- 
Method Details- 
doStartprotected void doStart()- Specified by:
- doStartin class- AbstractLifecycleComponent
 
- 
doStopprotected void doStop()- Specified by:
- doStopin class- AbstractLifecycleComponent
 
- 
doCloseprotected void doClose()- Specified by:
- doClosein class- AbstractLifecycleComponent
 
- 
awaitIdlepublic void awaitIdle()Description copied from interface:RepositoryBlock until all in-flight operations for this repository have completed. Must only be called after this instance has been closed by a call to stopReleasable.close(). Waiting for ongoing operations should be implemented here instead of inLifecycleComponent.stop()orReleasable.close()hooks of this interface as these are expected to be called on the cluster state applier thread (which must not block) if a repository is removed from the cluster. This method is intended to be called on node shutdown instead as a means to ensure no repository operations are leaked.- Specified by:
- awaitIdlein interface- Repository
 
- 
executeConsistentStateUpdatepublic 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 interface- Repository
- Parameters:
- createUpdateTask- function to supply cluster state update task
- source- the source of the cluster state update task
- onFailure- error handler invoked on failure to get a consistent view of the current- RepositoryData
 
- 
cloneShardSnapshotpublic void cloneShardSnapshot(SnapshotId source, SnapshotId target, RepositoryShardId shardId, @Nullable ShardGeneration shardGeneration, ActionListener<ShardSnapshotResult> listener) Description copied from interface:RepositoryClones a shard snapshot.- Specified by:
- cloneShardSnapshotin interface- Repository
- Parameters:
- source- source snapshot
- target- target snapshot
- shardId- shard id
- shardGeneration- shard generation in repo
- listener- listener to complete with new shard generation once clone has completed
 
- 
canUpdateInPlaceDescription copied from interface:RepositoryCheck if this instancesSettingscan be changed to the provided updated settings without recreating the repository.- Specified by:
- canUpdateInPlacein interface- Repository
- Parameters:
- updatedSettings- new repository settings
- ignoredSettings- setting names to ignore even if changed
- Returns:
- true if the repository can be updated in place
 
- 
updateStateDescription 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 interface- Repository
- Parameters:
- state- new cluster state
 
- 
threadPool
- 
getBlobStore
- 
blobContainermaintains single lazy instance ofBlobContainer
- 
blobStoreMaintains single lazy instance ofBlobStore. Public for testing.
- 
createBlobStoreCreates new BlobStore to read and write data.- Throws:
- Exception
 
- 
basePathReturns base path of the repository Public for testing.
- 
isCompressprotected final boolean isCompress()Returns true if metadata and snapshot files should be compressed- Returns:
- true if compression is needed
 
- 
chunkSizeReturns data file chunk size.This method should return null if no chunking is needed. - Returns:
- chunk size
 
- 
getMetadataDescription copied from interface:RepositoryReturns metadata about this repository.- Specified by:
- getMetadatain interface- Repository
 
- 
statsDescription copied from interface:RepositoryReturns stats on the repository usage- Specified by:
- statsin interface- Repository
 
- 
deleteSnapshotspublic void deleteSnapshots(Collection<SnapshotId> snapshotIds, long repositoryStateId, Version repositoryMetaVersion, SnapshotDeleteListener listener) Description copied from interface:RepositoryDeletes snapshots- Specified by:
- deleteSnapshotsin interface- Repository
- Parameters:
- snapshotIds- snapshot ids
- repositoryStateId- the unique id identifying the state of the repository when the snapshot deletion began
- repositoryMetaVersion- version of the updated repository metadata to write
- listener- completion listener
 
- 
cleanuppublic 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 id
- repositoryMetaVersion- version of the updated repository metadata to write
- listener- Listener to complete when done
 
- Deleting stale indices 
- 
finalizeSnapshotDescription copied from interface:RepositoryFinalizes snapshotting processThis method is called on master after all shards are snapshotted. - Specified by:
- finalizeSnapshotin interface- Repository
- Parameters:
- finalizeSnapshotContext- finalization context
 
- 
getSnapshotInfoDescription copied from interface:RepositoryReads snapshot descriptions from the repository.- Specified by:
- getSnapshotInfoin interface- Repository
- Parameters:
- context- get-snapshot-info-context
 
- 
getSnapshotGlobalMetadataDescription copied from interface:RepositoryReturns global metadata associated with the snapshot.- Specified by:
- getSnapshotGlobalMetadatain interface- Repository
- Parameters:
- snapshotId- the snapshot id to load the global metadata from
- Returns:
- the global metadata about the snapshot
 
- 
getSnapshotIndexMetaDatapublic IndexMetadata getSnapshotIndexMetaData(RepositoryData repositoryData, SnapshotId snapshotId, IndexId index) throws IOException Description copied from interface:RepositoryReturns the index metadata associated with the snapshot.- Specified by:
- getSnapshotIndexMetaDatain interface- Repository
- Parameters:
- repositoryData- current- RepositoryData
- snapshotId- the snapshot id to load the index metadata from
- index- the- IndexIdto load the metadata from
- Returns:
- the index metadata about the given index for the given snapshot
- Throws:
- IOException
 
- 
shardContainer
- 
getSnapshotThrottleTimeInNanospublic long getSnapshotThrottleTimeInNanos()Description copied from interface:RepositoryReturns snapshot throttle time in nanoseconds- Specified by:
- getSnapshotThrottleTimeInNanosin interface- Repository
 
- 
getRestoreThrottleTimeInNanospublic long getRestoreThrottleTimeInNanos()Description copied from interface:RepositoryReturns restore throttle time in nanoseconds- Specified by:
- getRestoreThrottleTimeInNanosin interface- Repository
 
- 
assertSnapshotOrGenericThreadprotected void assertSnapshotOrGenericThread()
- 
startVerificationDescription 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 interface- Repository
- Returns:
- verification token that should be passed to all Index Shard Repositories for additional verification or null
 
- 
endVerificationDescription 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 interface- Repository
- Parameters:
- seed- verification request generated by- Repository.startVerification()command
 
- 
getRepositoryDataDescription 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 interface- Repository
- 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
 
- 
isReadOnlypublic boolean isReadOnly()Description copied from interface:RepositoryReturns true if the repository supports only read operations- Specified by:
- isReadOnlyin interface- Repository
- Returns:
- true if the repository is read/only
 
- 
writeIndexGenprotected 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 write
- expectedGen- expected repository generation at the start of the operation
- version- version of the repository metadata to write
- stateFilter- filter for the last cluster state update executed by this method
- listener- completion listener
 
- 
snapshotShardDescription 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 interface- Repository
- Parameters:
- context- snapshot shard context that must be completed via- SnapshotShardContext.onResponse(org.elasticsearch.repositories.ShardSnapshotResult)or- ActionListener.Delegating.onFailure(java.lang.Exception)
 
- 
restoreShardpublic 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 interface- Repository
- Parameters:
- store- the store to restore the index into
- snapshotId- snapshot id
- indexId- id of the index in the repository from which the restore is occurring
- snapshotShardId- shard id (in the snapshot)
- recoveryState- recovery state
- listener- listener to invoke once done
 
- 
maybeRateLimitRestoresWrap 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().
- 
maybeRateLimitRestorespublic 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().
- 
maybeRateLimitSnapshotsWrap 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().
- 
maybeRateLimitSnapshotspublic 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().
- 
getShardSnapshotStatuspublic IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, IndexId indexId, ShardId shardId) Description copied from interface:RepositoryRetrieve shard snapshot status for the stored snapshot- Specified by:
- getShardSnapshotStatusin interface- Repository
- Parameters:
- snapshotId- snapshot id
- indexId- the snapshotted index id for the shard to get status for
- shardId- shard id
- Returns:
- snapshot status
 
- 
verifyDescription copied from interface:RepositoryVerifies repository settings on data node.- Specified by:
- verifyin interface- Repository
- Parameters:
- seed- value returned by- Repository.startVerification()
- localNode- the local node information, for inclusion in verification errors
 
- 
toString
- 
loadShardSnapshotpublic BlobStoreIndexShardSnapshot loadShardSnapshot(BlobContainer shardContainer, SnapshotId snapshotId) Loads information about shard snapshot
- 
getBlobStoreIndexShardSnapshotspublic BlobStoreIndexShardSnapshots getBlobStoreIndexShardSnapshots(IndexId indexId, int shardId, @Nullable ShardGeneration shardGen) throws IOException Loads all available snapshots in the repository using the givengenerationfor a shard. WhenshardGenis null it tries to load it using the BwC mode, listing the available index- blobs in the shard container.- Throws:
- IOException
 
- 
supportURLRepopublic boolean supportURLRepo()
- 
hasAtomicOverwritespublic 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.
 
- 
getReadBufferSizeInBytespublic int getReadBufferSizeInBytes()
 
-