-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17851 Support user specified content encoding for S3A #3312
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
Closed
holdenk
wants to merge
10
commits into
apache:trunk
from
holdenk:add-content-encoding-support-for-s3a
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
83e396a
Add the ability for users to specify the content encoding of the obje…
holdenk 4472112
Add an integration test
holdenk aa18197
Update the ITestS3a*Enc* skip logic to handle nulls, make my ITestS3A…
holdenk 59a593d
Fix setting the content encoding and change the test to a real one
holdenk f924ca3
Fix content encoding config var name to match
holdenk 25b6da0
Fix some linter errors and add a rename op
holdenk bb6cdfe
Switch from using the full s3 client to just using getXattrs
holdenk 939059b
getXattr fix
holdenk 0562940
Code review feedback
holdenk 3d45dc7
Unused import cleanup in test
holdenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AContentEncoding.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.fs.s3a; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.fs.contract.ContractTestUtils; | ||
| import static org.apache.hadoop.fs.s3a.impl.HeaderProcessing.XA_CONTENT_ENCODING; | ||
| import static org.apache.hadoop.fs.s3a.impl.HeaderProcessing.decodeBytes; | ||
| import org.apache.hadoop.fs.s3a.impl.StoreContext; | ||
|
|
||
| import static org.apache.hadoop.fs.s3a.Constants.CONTENT_ENCODING; | ||
|
|
||
| /** | ||
| * Tests of content encoding object meta data. | ||
| */ | ||
| public class ITestS3AContentEncoding extends AbstractS3ATestBase { | ||
|
|
||
| @Override | ||
| protected Configuration createConfiguration() { | ||
| Configuration conf = super.createConfiguration(); | ||
| conf.set(CONTENT_ENCODING, "gzip"); | ||
|
|
||
| return conf; | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreatedObjectsHaveEncoding() throws Throwable { | ||
| S3AFileSystem fs = getFileSystem(); | ||
| Path dir = methodPath(); | ||
| fs.mkdirs(dir); | ||
| Path path = new Path(dir, "1"); | ||
| ContractTestUtils.touch(fs, path); | ||
| assertObjectHasEncoding(path); | ||
| Path path2 = new Path(dir, "2"); | ||
| fs.rename(path, path2); | ||
| assertObjectHasEncoding(path2); | ||
| } | ||
|
|
||
| /** | ||
| * Assert that a given object has gzip encoding specified. | ||
| * @param path path | ||
| */ | ||
| private void assertObjectHasEncoding(Path path) throws Throwable { | ||
| S3AFileSystem fs = getFileSystem(); | ||
|
|
||
| StoreContext storeContext = fs.createStoreContext(); | ||
| Map<String, byte[]> xAttrs = fs.getXAttrs(path); | ||
| String encoding = decodeBytes(xAttrs.get(XA_CONTENT_ENCODING)); | ||
| Assertions.assertThat(encoding) | ||
| .describedAs("Encoding of object %s should be gzip, is %s", path, encoding) | ||
| .isEqualTo("gzip"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,9 @@ public class ITestS3AHugeFilesEncryption extends AbstractSTestS3AHugeFiles { | |
| public void setup() throws Exception { | ||
| Configuration c = new Configuration(); | ||
| String kmsKey = c.get(SERVER_SIDE_ENCRYPTION_KEY); | ||
| if (StringUtils.isBlank(kmsKey) || !c.get(SERVER_SIDE_ENCRYPTION_ALGORITHM) | ||
| .equals(S3AEncryptionMethods.CSE_KMS.name())) { | ||
| String encryptionAlgorithm = c.get(SERVER_SIDE_ENCRYPTION_ALGORITHM); | ||
| if (kmsKey == null || StringUtils.isBlank(kmsKey) || encryptionAlgorithm == null || | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as stated above. |
||
| !encryptionAlgorithm.equals(S3AEncryptionMethods.CSE_KMS.name())) { | ||
| skip(SERVER_SIDE_ENCRYPTION_KEY + " is not set for " + | ||
| SSE_KMS.getMethod() + " or CSE-KMS algorithm is used instead of " | ||
| + "SSE-KMS"); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.