Package org.apache.hadoop.fs.s3a.impl
Class StoreContext
java.lang.Object
org.apache.hadoop.fs.s3a.impl.StoreContext
- All Implemented Interfaces:
org.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<org.apache.hadoop.fs.store.audit.AuditSpan>
@LimitedPrivate("S3A Filesystem and extensions")
@Unstable
public class StoreContext
extends Object
implements org.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<org.apache.hadoop.fs.store.audit.AuditSpan>
This class provides the core context of the S3A filesystem to subsidiary
components, without exposing the entire parent class.
This is eliminate explicit recursive coupling.
Where methods on the FS are to be invoked, they are referenced
via the
ContextAccessors interface, so tests can implement
their own.
Warning: this really is private and unstable. Do not use
outside the org.apache.hadoop.fs.s3a package, or in extension points
such as DelegationTokens.-
Method Summary
Modifier and TypeMethodDescriptioncreateTempFile(String prefix, long size) Create a temporary file somewhere.Create a new executor with the capacity defined inexecutorCapacity.createThrottledExecutor(int capacity) Create a new executor service with a given capacity.voiddecrementGauge(Statistic statistic, long count) Decrement a gauge by a specific value.fullKey(S3AFileStatus stat) Build the full S3 key for a request from the status entry, possibly adding a "/" if it represents directory and it does not have a trailing slash already.org.apache.hadoop.fs.store.audit.AuditSpanReturn the active audit span.org.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>Get the auditor.Get the location of the bucket.org.apache.hadoop.conf.ConfigurationgetFsURI()Get the statistics context for this StoreContext.org.apache.hadoop.security.UserGroupInformationgetOwner()Get the owner of the filesystem.org.apache.hadoop.fs.impl.FlagSet<PerformanceFlagEnum>Get the performance flags.Get the request factory.Get the storage statistics of this filesystem.voidincrementGauge(Statistic statistic, long count) Increment a gauge by a specific value.voidincrementStatistic(Statistic statistic) Increment a statistic by 1.voidincrementStatistic(Statistic statistic, long count) Increment a statistic by a specific value.booleanreturn if the store context have client side encryption enabled.booleanbooleanorg.apache.hadoop.fs.PathConvert a key to a fully qualified path.org.apache.hadoop.fs.PathmakeQualified(org.apache.hadoop.fs.Path path) Qualify a path.pathToKey(org.apache.hadoop.fs.Path path) Turns a path (relative or otherwise) into an S3 key.<T> CompletableFuture<T>submit(CompletableFuture<T> future, Callable<T> call) Submit a closure for execution in the executor returned bygetExecutor().
-
Method Details
-
getFsURI
-
getBucket
-
getConfiguration
public org.apache.hadoop.conf.Configuration getConfiguration() -
getUsername
-
getExecutor
-
getInvoker
-
getInstrumentation
Get the statistics context for this StoreContext.- Returns:
- the statistics context this store context was created with.
-
getInputPolicy
-
getChangeDetectionPolicy
-
isMultiObjectDeleteEnabled
public boolean isMultiObjectDeleteEnabled() -
isUseListV1
public boolean isUseListV1() -
getContextAccessors
-
keyToPath
Convert a key to a fully qualified path.- Parameters:
key- input key- Returns:
- the fully qualified path including URI scheme and bucket name.
-
pathToKey
Turns a path (relative or otherwise) into an S3 key.- Parameters:
path- input path, may be relative to the working dir- Returns:
- a key excluding the leading "/", or, if it is the root path, ""
-
makeQualified
public org.apache.hadoop.fs.Path makeQualified(org.apache.hadoop.fs.Path path) Qualify a path.- Parameters:
path- path to qualify/normalize- Returns:
- possibly new path.
-
getStorageStatistics
Get the storage statistics of this filesystem.- Returns:
- the storage statistics
-
incrementStatistic
Increment a statistic by 1. This increments both the instrumentation and storage statistics.- Parameters:
statistic- The operation to increment
-
incrementStatistic
Increment a statistic by a specific value. This increments both the instrumentation and storage statistics.- Parameters:
statistic- The operation to incrementcount- the count to increment
-
decrementGauge
Decrement a gauge by a specific value.- Parameters:
statistic- The operation to decrementcount- the count to decrement
-
incrementGauge
Increment a gauge by a specific value.- Parameters:
statistic- The operation to incrementcount- the count to increment
-
createThrottledExecutor
Create a new executor service with a given capacity. This executor submits works to theexecutor, using aSemaphoredDelegatingExecutorto limit the number of requests coming in from a specific client. Because this delegates to an existing thread pool, the cost of creating a new instance here is low. As the throttling is per instance, separate instances should be created for each operation which wishes to execute work in parallel without saturating the base executor. This is important if either the duration of each operation is long or the submission rate of work is high.- Parameters:
capacity- maximum capacity of this executor.- Returns:
- an executor for submitting work.
-
createThrottledExecutor
Create a new executor with the capacity defined inexecutorCapacity.- Returns:
- a new executor for exclusive use by the caller.
-
getOwner
public org.apache.hadoop.security.UserGroupInformation getOwner()Get the owner of the filesystem.- Returns:
- the user who created this filesystem.
-
createTempFile
Create a temporary file somewhere.- Parameters:
prefix- prefix for the temporary filesize- expected size.- Returns:
- a file reference.
- Throws:
IOException- failure.
-
getBucketLocation
Get the location of the bucket.- Returns:
- the bucket location.
- Throws:
IOException- failure.
-
fullKey
Build the full S3 key for a request from the status entry, possibly adding a "/" if it represents directory and it does not have a trailing slash already.- Parameters:
stat- status to build the key from- Returns:
- a key for a delete request
-
submit
Submit a closure for execution in the executor returned bygetExecutor().- Type Parameters:
T- type of future- Parameters:
future- future for the result.call- callable to invoke.- Returns:
- the future passed in
-
getAuditor
Get the auditor.- Returns:
- auditor.
-
getActiveAuditSpan
public org.apache.hadoop.fs.store.audit.AuditSpan getActiveAuditSpan()Return the active audit span. This is thread local -it MUST be passed into workers. To ensure the correct span is used, it SHOULD be collected as early as possible, ideally during construction/ or service init/start.- Specified by:
getActiveAuditSpanin interfaceorg.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<org.apache.hadoop.fs.store.audit.AuditSpan>- Returns:
- active audit span.
-
getRequestFactory
Get the request factory.- Returns:
- the factory for requests.
-
isCSEEnabled
public boolean isCSEEnabled()return if the store context have client side encryption enabled.- Returns:
- boolean indicating if CSE is enabled or not.
-
getPerformanceFlags
Get the performance flags.- Returns:
- FlagSet containing the performance flags.
-