Class ActiveAuditManagerS3A
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.fs.s3a.audit.impl.ActiveAuditManagerS3A
- All Implemented Interfaces:
Closeable,AutoCloseable,AuditManagerS3A,AWSAuditEventCallbacks,org.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<AuditSpanS3A>,org.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>,org.apache.hadoop.service.Service,software.amazon.awssdk.core.interceptor.ExecutionInterceptor
@Private
public final class ActiveAuditManagerS3A
extends org.apache.hadoop.service.CompositeService
implements AuditManagerS3A
Thread management for the active audit.
This should be created by whatever wants to have active
audit span tracking.
It creates and starts the actual
OperationAuditor for auditing.
It then stores the thread-local span and returns a wrapping
span.
When the wrapper is closed/deactivated it
will deactivate the wrapped span and then
switch the active span to the unbounded span.
This class also implements ExecutionInterceptor and
returns itself in createExecutionInterceptors();
once registered with the S3 client, the implemented methods
will be called during different parts of an SDK request lifecycle,
which then locate the active span and forward the request.
If any such invocation raises an AuditFailureException
then the IOStatistics counter for AUDIT_FAILURE
is incremented.
Uses the WeakReferenceThreadMap to store spans for threads.
Provided a calling class retains a reference to the span,
the active span will be retained.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final org.apache.hadoop.fs.store.LogExactlyOnceOne of logger for warnings about span retrieval.Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
ConstructorsConstructorDescriptionActiveAuditManagerS3A(org.apache.hadoop.fs.statistics.impl.IOStatisticsStore iostatistics) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterExecution(software.amazon.awssdk.core.interceptor.Context.AfterExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to active span.voidafterMarshalling(software.amazon.awssdk.core.interceptor.Context.AfterMarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidafterTransmission(software.amazon.awssdk.core.interceptor.Context.AfterTransmission context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidafterUnmarshalling(software.amazon.awssdk.core.interceptor.Context.AfterUnmarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidbeforeExecution(software.amazon.awssdk.core.interceptor.Context.BeforeExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to the active span.voidbeforeMarshalling(software.amazon.awssdk.core.interceptor.Context.BeforeMarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidbeforeTransmission(software.amazon.awssdk.core.interceptor.Context.BeforeTransmission context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidbeforeUnmarshalling(software.amazon.awssdk.core.interceptor.Context.BeforeUnmarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) booleancheckAccess(org.apache.hadoop.fs.Path path, S3AFileStatus status, org.apache.hadoop.fs.permission.FsAction mode) Check for permission to access a path.List<software.amazon.awssdk.core.interceptor.ExecutionInterceptor>Return a list of execution interceptors for the AWS SDK which relays to this class.createSpan(String operation, String path1, String path2) Start an operation; as well as invoking the audit service to do this, sets the operation as the active operation for this thread.software.amazon.awssdk.transfer.s3.progress.TransferListenerReturn a transfer callback which fixes the active span context to be that in which the transfer listener was created.Return the active wrapped span.Get the auditor; valid once initialized.Get the name of the operation.The Span ID in the audit manager is the ID of the auditor, which can be used in the filesystem toString() method to assist in correlating client logs with S3 logs.software.amazon.awssdk.http.SdkHttpRequestmodifyHttpRequest(software.amazon.awssdk.core.interceptor.Context.ModifyHttpRequest context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) software.amazon.awssdk.http.SdkHttpResponsemodifyHttpResponse(software.amazon.awssdk.core.interceptor.Context.ModifyHttpResponse context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) software.amazon.awssdk.core.SdkRequestmodifyRequest(software.amazon.awssdk.core.interceptor.Context.ModifyRequest context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) software.amazon.awssdk.core.SdkResponsemodifyResponse(software.amazon.awssdk.core.interceptor.Context.ModifyResponse context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) voidonExecutionFailure(software.amazon.awssdk.core.interceptor.Context.FailedExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to active span.voidrequestCreated(software.amazon.awssdk.core.SdkRequest.Builder builder) Audit the creation of a request and retrieve a reference to the active thread span.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidAfter starting the auditor, it is queried for its unbonded span, which is then wrapped and stored for use.protected voidvoidsetAuditFlags(EnumSet<AuditorFlags> flags) Update audit flags, especially the out of span rejection option.toString()Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeServiceMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awssdk.core.interceptor.ExecutionInterceptor
modifyAsyncHttpContent, modifyAsyncHttpResponseContent, modifyException, modifyHttpContent, modifyHttpResponseContentMethods inherited from interface org.apache.hadoop.service.Service
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
WARN_OF_SPAN_TYPE
public static final org.apache.hadoop.fs.store.LogExactlyOnce WARN_OF_SPAN_TYPEOne of logger for warnings about span retrieval. -
AUDIT_MANAGER_OPERATION
- See Also:
-
NOT_A_WRAPPED_SPAN
- See Also:
-
-
Constructor Details
-
ActiveAuditManagerS3A
public ActiveAuditManagerS3A(org.apache.hadoop.fs.statistics.impl.IOStatisticsStore iostatistics) Instantiate.- Parameters:
iostatistics- statistics target
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStart
After starting the auditor, it is queried for its unbonded span, which is then wrapped and stored for use.- Overrides:
serviceStartin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
toString
- Overrides:
toStringin classorg.apache.hadoop.service.AbstractService
-
getAuditor
Description copied from interface:AuditManagerS3AGet the auditor; valid once initialized.- Specified by:
getAuditorin interfaceAuditManagerS3A- Returns:
- the auditor.
-
getActiveAuditSpan
Return the active wrapped span.- Specified by:
getActiveAuditSpanin interfaceorg.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<AuditSpanS3A>- Returns:
- a span.
-
getSpanId
The Span ID in the audit manager is the ID of the auditor, which can be used in the filesystem toString() method to assist in correlating client logs with S3 logs. It is returned here as part of the implementation ofAWSAuditEventCallbacks.- Specified by:
getSpanIdin interfaceAWSAuditEventCallbacks- Returns:
- the unique ID of the FS.
-
getOperationName
Description copied from interface:AWSAuditEventCallbacksGet the name of the operation.- Specified by:
getOperationNamein interfaceAWSAuditEventCallbacks- Returns:
- the operation name.
-
createSpan
public AuditSpanS3A createSpan(String operation, @Nullable String path1, @Nullable String path2) throws IOException Start an operation; as well as invoking the audit service to do this, sets the operation as the active operation for this thread.- Specified by:
createSpanin interfaceorg.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>- Parameters:
operation- operation name.path1- first path of operationpath2- second path of operation- Returns:
- a wrapped audit span
- Throws:
IOException- failure
-
setAuditFlags
Description copied from interface:AuditManagerS3AUpdate audit flags, especially the out of span rejection option.- Specified by:
setAuditFlagsin interfaceAuditManagerS3A- Parameters:
flags- audit flags.
-
createExecutionInterceptors
public List<software.amazon.awssdk.core.interceptor.ExecutionInterceptor> createExecutionInterceptors() throws IOExceptionReturn a list of execution interceptors for the AWS SDK which relays to this class.- Specified by:
createExecutionInterceptorsin interfaceAuditManagerS3A- Returns:
- a list of execution interceptors.
- Throws:
IOException- failure.
-
createTransferListener
public software.amazon.awssdk.transfer.s3.progress.TransferListener createTransferListener()Description copied from interface:AuditManagerS3AReturn a transfer callback which fixes the active span context to be that in which the transfer listener was created. This can be used to audit the creation of the multipart upload initiation request which the transfer manager makes when a file to be copied is split up. This must be invoked/used within the active span.- Specified by:
createTransferListenerin interfaceAuditManagerS3A- Returns:
- a transfer listener.
-
checkAccess
public boolean checkAccess(org.apache.hadoop.fs.Path path, S3AFileStatus status, org.apache.hadoop.fs.permission.FsAction mode) throws IOException Description copied from interface:AuditManagerS3ACheck for permission to access a path. The path is fully qualified and the status is the status of the path. This is called from theFileSystem.access()command and is a soft permission check used by Hive.- Specified by:
checkAccessin interfaceAuditManagerS3A- Parameters:
path- path to checkstatus- status of the path.mode- access mode.- Returns:
- true if access is allowed.
- Throws:
IOException- failure
-
requestCreated
public void requestCreated(software.amazon.awssdk.core.SdkRequest.Builder builder) Audit the creation of a request and retrieve a reference to the active thread span.- Specified by:
requestCreatedin interfaceAWSAuditEventCallbacks- Parameters:
builder- the request builder.
-
beforeExecution
public void beforeExecution(software.amazon.awssdk.core.interceptor.Context.BeforeExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to the active span. All invocations increment the statistics counter forStatistic.AUDIT_REQUEST_EXECUTION; failures will also incrementStatistic.AUDIT_FAILURE;- Specified by:
beforeExecutionin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
afterExecution
public void afterExecution(software.amazon.awssdk.core.interceptor.Context.AfterExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to active span.- Specified by:
afterExecutionin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
onExecutionFailure
public void onExecutionFailure(software.amazon.awssdk.core.interceptor.Context.FailedExecution context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) Forward to active span.- Specified by:
onExecutionFailurein interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor- Parameters:
context- execution contextexecutionAttributes- the execution attributes
-
modifyRequest
public software.amazon.awssdk.core.SdkRequest modifyRequest(software.amazon.awssdk.core.interceptor.Context.ModifyRequest context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
modifyRequestin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
beforeMarshalling
public void beforeMarshalling(software.amazon.awssdk.core.interceptor.Context.BeforeMarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
beforeMarshallingin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
afterMarshalling
public void afterMarshalling(software.amazon.awssdk.core.interceptor.Context.AfterMarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
afterMarshallingin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
modifyHttpRequest
public software.amazon.awssdk.http.SdkHttpRequest modifyHttpRequest(software.amazon.awssdk.core.interceptor.Context.ModifyHttpRequest context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
modifyHttpRequestin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
beforeTransmission
public void beforeTransmission(software.amazon.awssdk.core.interceptor.Context.BeforeTransmission context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
beforeTransmissionin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
afterTransmission
public void afterTransmission(software.amazon.awssdk.core.interceptor.Context.AfterTransmission context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
afterTransmissionin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
modifyHttpResponse
public software.amazon.awssdk.http.SdkHttpResponse modifyHttpResponse(software.amazon.awssdk.core.interceptor.Context.ModifyHttpResponse context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
modifyHttpResponsein interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
beforeUnmarshalling
public void beforeUnmarshalling(software.amazon.awssdk.core.interceptor.Context.BeforeUnmarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
beforeUnmarshallingin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
afterUnmarshalling
public void afterUnmarshalling(software.amazon.awssdk.core.interceptor.Context.AfterUnmarshalling context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
afterUnmarshallingin interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-
modifyResponse
public software.amazon.awssdk.core.SdkResponse modifyResponse(software.amazon.awssdk.core.interceptor.Context.ModifyResponse context, software.amazon.awssdk.core.interceptor.ExecutionAttributes executionAttributes) - Specified by:
modifyResponsein interfacesoftware.amazon.awssdk.core.interceptor.ExecutionInterceptor
-