-
Notifications
You must be signed in to change notification settings - Fork 937
Sync streaming compression #4135
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
davidh44
wants to merge
28
commits into
feature/master/request-compression
from
hdavidh/sync-streaming-compression
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
157fc10
Rename DecodedStreamBuffer to UnderlyingStreamBuffer
davidh44 29380ab
Update Compressor
davidh44 228a035
Sync streaming compression
davidh44 280bd38
Fix Checkstyle issues
davidh44 e2d6951
Refactor to common class AwsChunkedInputStream
davidh44 be06647
Refactor Compressor
davidh44 04b5e7c
Merge from feature/master/request-compression
davidh44 5b5641c
Refactor CompressionType
davidh44 7e07424
sync compression
davidh44 ba7e602
Close GZIPOutputStream
davidh44 5b37111
Add compress stage to async http client
davidh44 cd241a6
Add compressed PutMetricData integ test
davidh44 0f4fd59
Merge branch 'feature/master/request-compression' into hdavidh/sync-s…
davidh44 5268c0b
Refactoring
davidh44 d8aa9a5
Add tests
davidh44 37d962e
Add equals and hashCode
davidh44 aab6f62
Add TODO
davidh44 4b52a88
Add tests with retry
davidh44 d9e28d9
Update content length retrieval
davidh44 86ff75a
CompressionType test
davidh44 24d69db
RequestCompressionConfiguration test
davidh44 9dadea3
Fix Spotbugs error
davidh44 95e0383
Rename CompressionType to CompressorType
davidh44 4d1e924
Fix import ordering
davidh44 ebc0c35
Remove chunk headers and trailers
davidh44 1d9bb6f
Update tests
davidh44 36dd8ef
Refactoring
davidh44 518e4c0
Only compress streaming operations that are chunked
davidh44 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
74 changes: 0 additions & 74 deletions
74
core/sdk-core/src/main/java/software/amazon/awssdk/core/compression/CompressionType.java
This file was deleted.
Oops, something went wrong.
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
116 changes: 116 additions & 0 deletions
116
core/sdk-core/src/main/java/software/amazon/awssdk/core/compression/CompressorType.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,116 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.core.compression; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.core.internal.compression.GzipCompressor; | ||
import software.amazon.awssdk.utils.Validate; | ||
|
||
/** | ||
* The supported compression algorithms for operations with the requestCompression trait. Each supported algorithm will have an | ||
* {@link Compressor} implementation. | ||
*/ | ||
@SdkInternalApi | ||
public final class CompressorType { | ||
|
||
public static final CompressorType GZIP = CompressorType.of("gzip"); | ||
|
||
private static Map<String, Compressor> compressorMap = new HashMap<String, Compressor>() {{ | ||
put("gzip", new GzipCompressor()); | ||
}}; | ||
|
||
private final String id; | ||
|
||
private CompressorType(String id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Creates a new {@link CompressorType} of the given value. | ||
*/ | ||
public static CompressorType of(String value) { | ||
Validate.paramNotBlank(value, "compressionType"); | ||
return CompressorTypeCache.put(value); | ||
} | ||
|
||
/** | ||
* Returns the {@link Set} of {@link String}s of compression types supported by the SDK. | ||
*/ | ||
public static Set<String> compressorTypes() { | ||
return compressorMap.keySet(); | ||
} | ||
|
||
/** | ||
* Whether or not the compression type is supported by the SDK. | ||
*/ | ||
public static boolean isSupported(String compressionType) { | ||
return compressorTypes().contains(compressionType); | ||
} | ||
|
||
/** | ||
* Maps the {@link CompressorType} to its corresponding {@link Compressor}. | ||
*/ | ||
public Compressor newCompressor() { | ||
Compressor compressor = compressorMap.getOrDefault(this.id, null); | ||
if (compressor == null) { | ||
throw new UnsupportedOperationException("The compression type " + id + " does not have an implementation of " | ||
+ "Compressor"); | ||
} | ||
return compressor; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
CompressorType that = (CompressorType) o; | ||
return Objects.equals(id, that.id) | ||
&& Objects.equals(compressorMap, that.compressorMap); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = id != null ? id.hashCode() : 0; | ||
result = 31 * result + (compressorMap != null ? compressorMap.hashCode() : 0); | ||
return result; | ||
} | ||
|
||
private static class CompressorTypeCache { | ||
private static final ConcurrentHashMap<String, CompressorType> VALUES = new ConcurrentHashMap<>(); | ||
|
||
private CompressorTypeCache() { | ||
} | ||
|
||
private static CompressorType put(String value) { | ||
return VALUES.computeIfAbsent(value, v -> new CompressorType(value)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
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.