-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Upgrade Glue Client to AWS SDK v2 #17866
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
ShubhamChaurasia
wants to merge
5
commits into
trinodb:master
from
ShubhamChaurasia:aws-sdk-v2-upgrade/glue
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cf8a966
Upgrade Glue Client to AWS SDK v2
ShubhamChaurasia edbbc71
Make use of SDK V2 paginator APIs, deprecate hive.metastore.glue.pin-…
ShubhamChaurasia a754210
Address review comments - change to Glue sync client for iceberg module
ShubhamChaurasia bd6975c
Adds provider for GlueClient, fixes test - TestIcebergPlugin#testGlue…
ShubhamChaurasia b227e82
Dependency fixes after rebase
ShubhamChaurasia 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,26 +15,27 @@ | |
|
|
||
| import com.google.common.collect.AbstractIterator; | ||
| import io.trino.plugin.hive.aws.AwsApiCallStats; | ||
| import io.trino.spi.TrinoException; | ||
| import software.amazon.awssdk.core.async.SdkPublisher; | ||
| import software.amazon.awssdk.services.glue.model.GlueException; | ||
|
|
||
| import java.util.Iterator; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.concurrent.CompletionException; | ||
| import java.util.function.BiConsumer; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static com.google.common.collect.Streams.stream; | ||
| import static io.trino.plugin.hive.HiveErrorCode.HIVE_METASTORE_ERROR; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public final class AwsSdkUtil | ||
| { | ||
| private AwsSdkUtil() {} | ||
|
|
||
| /** | ||
| * Helper method to get all results from a paginated API. | ||
| * | ||
| * @param request request object reused for subsequent requests with | ||
| * {@code setNextToken} being used to set the next token in the request object | ||
| */ | ||
| public static <Request, Result> Stream<Result> getPaginatedResults( | ||
| public static <Request, Result> Stream<Result> getPaginatedResultsForS3( | ||
| Function<Request, Result> submission, | ||
| Request request, | ||
| BiConsumer<Request, String> setNextToken, | ||
|
|
@@ -68,4 +69,56 @@ protected Result computeNext() | |
|
|
||
| return stream(iterator); | ||
| } | ||
|
|
||
| /** | ||
| * Helper method to handle sync request with async client | ||
| */ | ||
| public static <Request, Result> Result awsSyncRequest( | ||
|
||
| Function<Request, CompletableFuture<Result>> submission, | ||
| Request request, | ||
| AwsApiCallStats stats) | ||
| { | ||
| requireNonNull(submission, "submission is null"); | ||
| requireNonNull(request, "request is null"); | ||
| try { | ||
| if (stats != null) { | ||
| return stats.call(() -> submission.apply(request).join()); | ||
| } | ||
|
|
||
| return submission.apply(request).join(); | ||
| } | ||
| catch (CompletionException e) { | ||
| if (e.getCause() instanceof GlueException glueException) { | ||
| throw glueException; | ||
| } | ||
| throw new TrinoException(HIVE_METASTORE_ERROR, e.getCause()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Helper method to handle sync paginated request with async client | ||
| */ | ||
| public static <Result> void awsSyncPaginatedRequest(SdkPublisher<Result> paginator, Consumer<Result> resultConsumer, AwsApiCallStats stats) | ||
| { | ||
| requireNonNull(paginator, "paginator is null"); | ||
| requireNonNull(resultConsumer, "resultConsumer is null"); | ||
| try { | ||
| CompletableFuture<Void> paginationFuture; | ||
| if (stats != null) { | ||
| paginationFuture = stats.call(() -> paginator.subscribe(resultConsumer)); | ||
| } | ||
| else { | ||
| paginationFuture = paginator.subscribe(resultConsumer); | ||
| } | ||
|
|
||
| // for paginator.subscribe() to complete | ||
| paginationFuture.join(); | ||
| } | ||
| catch (CompletionException e) { | ||
| if (e.getCause() instanceof GlueException glueException) { | ||
| throw glueException; | ||
| } | ||
| throw new TrinoException(HIVE_METASTORE_ERROR, e.getCause()); | ||
| } | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use
apache-clientsince we don't need or want async behavior. Please seetrino-filesystem-s3to see how we use it with S3.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few details in this comment.
trino-hivemay not be able to use sync client as mentioned.Should I convert the one in
trino-iceberg(TrinoGlueCatalog) to sync ?