Skip to content
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 @@ -1920,7 +1920,8 @@ private FSDataInputStream executeOpen(
.withCallbacks(createInputStreamCallbacks(auditSpan))
.withContext(readContext.build())
.withObjectAttributes(createObjectAttributes(path, fileStatus))
.withStreamStatistics(inputStreamStats);
.withStreamStatistics(inputStreamStats)
.withEncryptionSecrets(getEncryptionSecrets());
return new FSDataInputStream(getStore().readObject(parameters));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@

import java.io.EOFException;
import java.io.IOException;
import java.util.Optional;

import org.apache.hadoop.fs.s3a.S3AEncryptionMethods;
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecretOperations;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStreamFactory;
import software.amazon.s3.analyticsaccelerator.S3SeekableInputStream;
import software.amazon.s3.analyticsaccelerator.request.EncryptionSecrets;

Check failure on line 30 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/streams/AnalyticsStream.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/impl/streams/AnalyticsStream.java#L30

javadoc: error: cannot find symbol
import software.amazon.s3.analyticsaccelerator.request.ObjectMetadata;
import software.amazon.s3.analyticsaccelerator.util.InputPolicy;
import software.amazon.s3.analyticsaccelerator.util.OpenStreamInformation;
Expand Down Expand Up @@ -205,6 +209,12 @@
.etag(parameters.getObjectAttributes().getETag()).build());
}

if(parameters.getEncryptionSecrets().getEncryptionMethod() == S3AEncryptionMethods.SSE_C) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a space before the {

EncryptionSecretOperations.getSSECustomerKey(parameters.getEncryptionSecrets())
.ifPresent(base64customerKey -> openStreamInformationBuilder.encryptionSecrets(
EncryptionSecrets.builder().sseCustomerKey(Optional.of(base64customerKey)).build()));
}

return openStreamInformationBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hadoop.fs.LocalDirAllocator;
import org.apache.hadoop.fs.s3a.S3AReadOpContext;
import org.apache.hadoop.fs.s3a.S3ObjectAttributes;
import org.apache.hadoop.fs.s3a.auth.delegation.EncryptionSecrets;
import org.apache.hadoop.fs.s3a.statistics.S3AInputStreamStatistics;

import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -69,6 +70,29 @@ public final class ObjectReadParameters {
*/
private LocalDirAllocator directoryAllocator;

/**
* Encryption secrets for this stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a . at the end

*/
private EncryptionSecrets encryptionSecrets;

/**
* Getter.
* @return Encryption secrets.
*/
public EncryptionSecrets getEncryptionSecrets() {
return encryptionSecrets;
}

/**
* Set encryption secrets.
* @param value new value
* @return the builder
*/
public ObjectReadParameters withEncryptionSecrets(final EncryptionSecrets value) {
encryptionSecrets = value;
return this;
}

/**
* @return Read operation context.
*/
Expand Down Expand Up @@ -185,6 +209,7 @@ public ObjectReadParameters validate() {
requireNonNull(directoryAllocator, "directoryAllocator");
requireNonNull(objectAttributes, "objectAttributes");
requireNonNull(streamStatistics, "streamStatistics");
requireNonNull(encryptionSecrets, "encryptionSecrets");
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_KEY;

import static org.apache.hadoop.fs.s3a.S3ATestUtils.assumeStoreAwsHosted;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.enableAnalyticsAccelerator;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.getTestBucketName;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.maybeSkipRootTests;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfAnalyticsAcceleratorEnabled;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;

/**
Expand Down Expand Up @@ -96,8 +96,6 @@ protected Configuration createConfiguration() {
@Override
public void setup() throws Exception {
super.setup();
skipIfAnalyticsAcceleratorEnabled(getConfiguration(),
"Analytics Accelerator currently does not support SSE-C");
assumeEnabled();
// although not a root dir test, this confuses paths enough it shouldn't be run in
// parallel with other jobs
Expand Down Expand Up @@ -327,6 +325,65 @@ public void testChecksumRequiresReadAccess() throws Throwable {
() -> fsKeyB.getFileChecksum(path));
}


/**
* Tests the creation and reading of a file using a different encryption key
* when Analytics Accelerator is enabled.
*
* @throws Exception if any error occurs during the test execution
*/
@Test
public void testCreateFileAndReadWithDifferentEncryptionKeyWithAnalyticsAcceleratorEnabled() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than do it this way, make the entire test suite (i.e. class) something which runs with both the normal and accelerated options.

enableAnalyticsAccelerator(getConfiguration());
testCreateFileAndReadWithDifferentEncryptionKey();
}

/**
* Tests the creation and movement of a file using a different SSE-C key
* when Analytics Accelerator is enabled.
*
* @throws Exception if any error occurs during the test execution
*/
@Test
public void testCreateFileThenMoveWithDifferentSSECKeyWithAnalyticsAcceleratorEnabled() throws Exception {
enableAnalyticsAccelerator(getConfiguration());
testCreateFileThenMoveWithDifferentSSECKey();
}

/**
* Tests create and file rename operation when Analytics Accelerator is enabled.
*
* @throws Exception if any error occurs during the test execution
*/
@Test
public void testCreateFileAndRenameFileWithAnalyticsAcceleratorEnabled() throws Exception {
enableAnalyticsAccelerator(getConfiguration());
testRenameFile();
}

/**
* Tests the creation and listing of encrypted files when Analytics Accelerator is enabled.
*
* @throws Exception if any error occurs during the test execution
*/
@Test
public void testCreateFileAndListStatusEncryptedFileWithAnalyticsAcceleratorEnabled() throws Exception {
enableAnalyticsAccelerator(getConfiguration());
testListStatusEncryptedFile();
}

/**
* Tests the creation and deletion of an encrypted object using a different key
* when Analytics Accelerator is enabled.t.
*
* @throws Exception if any error occurs during the test execution
*/
@Test
public void testCreateFileAndDeleteEncryptedObjectWithDifferentKeyWithAnalyticsAcceleratorEnabled() throws Exception {
enableAnalyticsAccelerator(getConfiguration());
testDeleteEncryptedObjectWithDifferentKey();
}

private S3AFileSystem createNewFileSystemWithSSECKey(String sseCKey) throws
IOException {
Configuration conf = this.createConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_ALGORITHM;
import static org.apache.hadoop.fs.s3a.Constants.SERVER_SIDE_ENCRYPTION_KEY;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfAnalyticsAcceleratorEnabled;
import static org.apache.hadoop.fs.s3a.S3ATestUtils.skipIfEncryptionTestsDisabled;

/**
Expand All @@ -55,8 +54,6 @@ public class ITestS3AHugeFilesSSECDiskBlocks
public void setup() throws Exception {
try {
super.setup();
skipIfAnalyticsAcceleratorEnabled(getConfiguration(),
"Analytics Accelerator currently does not support SSE-C");
} catch (AccessDeniedException | AWSUnsupportedFeatureException e) {
skip("Bucket does not allow " + S3AEncryptionMethods.SSE_C + " encryption method");
}
Expand Down