Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support audit header #7273

Open
wants to merge 9 commits into
base: feature-HADOOP-19363-analytics-accelerator-s3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,24 @@
// build the referrer up. so as to find/report problems early
initialHeader = buildHttpReferrer();
}

Check failure on line 181 in hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java#L181

blanks: end of line
/**
* Build the referrer string.
* Copy constructor.
* Creates a deep copy of a HttpReferrerAuditHeader object
*/
public HttpReferrerAuditHeader(HttpReferrerAuditHeader httpReferrerAuditHeader) {

Check failure on line 186 in hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java#L186

javadoc: warning: no @param for httpReferrerAuditHeader
this.contextId = requireNonNull(httpReferrerAuditHeader.contextId);
this.evaluated = new ConcurrentHashMap<>(httpReferrerAuditHeader.evaluated);
this.filter = ImmutableSet.copyOf(httpReferrerAuditHeader.filter);
this.operationName = requireNonNull(httpReferrerAuditHeader.operationName);
this.path1 = httpReferrerAuditHeader.path1;
this.path2 = httpReferrerAuditHeader.path2;
this.spanId = requireNonNull(httpReferrerAuditHeader.spanId);
this.attributes = new ConcurrentHashMap<>(httpReferrerAuditHeader.attributes);
this.initialHeader = httpReferrerAuditHeader.initialHeader;
}

Check failure on line 197 in hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java#L197

blanks: end of line
/* Build the referrer string.
* This includes dynamically evaluating all of the evaluated
* attributes.
* If there is an error creating the string it will be logged once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;

import org.apache.hadoop.fs.s3a.audit.impl.ActiveAuditManagerS3A;
import org.apache.hadoop.fs.s3a.audit.impl.LoggingAuditor;
import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.core.exception.SdkException;
import software.amazon.awssdk.services.s3.S3AsyncClient;
Expand Down Expand Up @@ -227,6 +229,8 @@
import org.apache.hadoop.util.SemaphoredDelegatingExecutor;
import org.apache.hadoop.util.concurrent.HadoopExecutors;
import org.apache.hadoop.util.functional.CallableRaisingIOE;
import software.amazon.s3.analyticsaccelerator.request.StreamContext;

Check failure on line 232 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java#L232

javadoc: error: cannot find symbol
import software.amazon.s3.analyticsaccelerator.request.ObjectClient;

import static java.util.Objects.requireNonNull;
import static org.apache.hadoop.fs.CommonConfigurationKeys.IOSTATISTICS_LOGGING_LEVEL;
Expand Down Expand Up @@ -1953,11 +1957,15 @@
LOG.debug("Opening '{}'", readContext);

if (this.analyticsAcceleratorEnabled) {
ActiveAuditManagerS3A.WrappingAuditSpan wrappingAuditSpan = (ActiveAuditManagerS3A.WrappingAuditSpan) auditSpan;
LoggingAuditor.LoggingAuditSpan loggingAuditSpan = (LoggingAuditor.LoggingAuditSpan) wrappingAuditSpan.getSpan();
StreamContext streamContext = new S3AStreamContext(loggingAuditSpan.getReferrer());
return new FSDataInputStream(
new S3ASeekableStream(
this.bucket,
pathToKey(path),
s3SeekableInputStreamFactory));
s3SeekableInputStreamFactory,
streamContext));
}

if (this.prefetchEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import software.amazon.s3.analyticsaccelerator.S3SeekableInputStream;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStreamFactory;
import software.amazon.s3.analyticsaccelerator.request.StreamContext;

Check failure on line 34 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ASeekableStream.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ASeekableStream.java#L34

javadoc: error: cannot find symbol
import software.amazon.s3.analyticsaccelerator.util.S3URI;

public class S3ASeekableStream extends FSInputStream implements StreamCapabilities {
Expand All @@ -42,9 +43,8 @@

public static final Logger LOG = LoggerFactory.getLogger(S3ASeekableStream.class);

public S3ASeekableStream(String bucket, String key,
S3SeekableInputStreamFactory s3SeekableInputStreamFactory) {
this.inputStream = s3SeekableInputStreamFactory.createStream(S3URI.of(bucket, key));
public S3ASeekableStream(String bucket, String key, S3SeekableInputStreamFactory s3SeekableInputStreamFactory, StreamContext streamContext) {

Check failure on line 46 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ASeekableStream.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3ASeekableStream.java#L46

javadoc: error: cannot find symbol
this.inputStream = s3SeekableInputStreamFactory.createStream(S3URI.of(bucket, key), streamContext);
this.key = key;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.apache.hadoop.fs.s3a;

Check failure on line 1 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java#L1

asflicense: Missing Apache License

import org.apache.hadoop.fs.audit.AuditConstants;
import org.apache.hadoop.fs.store.audit.HttpReferrerAuditHeader;
import software.amazon.s3.analyticsaccelerator.request.GetRequest;
import software.amazon.s3.analyticsaccelerator.request.StreamContext;

Check failure on line 6 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java#L6

javadoc: error: cannot find symbol

public class S3AStreamContext implements StreamContext {

Check failure on line 8 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java#L8

javadoc: error: cannot find symbol

private final HttpReferrerAuditHeader referrer;

public S3AStreamContext(HttpReferrerAuditHeader referrer) {
this.referrer = referrer;
}

@Override
public String modifyAndBuildReferrerHeader(GetRequest getRequestContext) {
HttpReferrerAuditHeader copyReferrer = new HttpReferrerAuditHeader(this.referrer);
copyReferrer.set(AuditConstants.PARAM_RANGE, getRequestContext.getRange().toHttpString());
return copyReferrer.buildHttpReferrer();
}

Check failure on line 21 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AStreamContext.java#L21

blanks: end of line
}
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public SdkResponse modifyResponse(Context.ModifyResponse context,
* Package-private for testing.
*/
@VisibleForTesting
final class WrappingAuditSpan extends AbstractAuditSpanImpl {
public final class WrappingAuditSpan extends AbstractAuditSpanImpl {

/**
* Inner span.
Expand Down Expand Up @@ -797,8 +797,8 @@ public boolean isValidSpan() {
* Get the inner span.
* @return the span.
*/
@VisibleForTesting
AuditSpanS3A getSpan() {

public AuditSpanS3A getSpan() {
return span;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ HttpReferrerAuditHeader getReferrer(AuditSpanS3A span) {
* it is private. This is not true, as it is subclassed in
* the same file.
*/
private class LoggingAuditSpan extends AbstractAuditSpanImpl {
public class LoggingAuditSpan extends AbstractAuditSpanImpl {

private final HttpReferrerAuditHeader referrer;

Expand All @@ -298,7 +298,7 @@ private void attachRangeFromRequest(SdkHttpRequest request,

private final String description;

private LoggingAuditSpan(
public LoggingAuditSpan(
final String spanId,
final String operationName,
final CommonAuditContext context,
Expand Down Expand Up @@ -456,7 +456,7 @@ public String toString() {
* Get the referrer.
* @return the referrer.
*/
private HttpReferrerAuditHeader getReferrer() {
public HttpReferrerAuditHeader getReferrer() {
return referrer;
}

Expand Down
Loading