AWS SDK for Java 2.0
repository·master·Indexed 25 days ago
https://github.com/aws/aws-sdk-java-v2A complete rewrite of the Java SDK designed for improved performance via non-blocking IO and pluggable HTTP implementations. It includes Maven archetypes for quickstarting client applications (archetype-app-quickstart) and Lambda functions (archetype-lambda), support for GraalVM Native Image, and an alternate syntax for event streaming APIs to simplify bi-directional communication over HTTP/2.
What's inside aws-sdk-java-v2
- The DynamoDB Enhanced Client is a mid-level mapper and abstraction layer for Amazon DynamoDB built on top of the AWS SDK for Java v2. It allows developers to map Java data classes to DynamoDB tables, simplifying common operations through a more object-oriented approach.
Request Presigners for delayed request execution
masterRequest Presigners are a released feature that allow you to sign requests to be executed at a later time.Understand SDK Metrics module structure
masterThe SDK metrics system is split into two primary modules:
- metrics-spi: Contains metrics interfaces and default implementations. This is a sub-module of
core. Becausesdk-coredepends onmetrics-spi, it is included automatically in your project. - metrics-publishers: Contains implementations of all supported publishers. This module contains sub-modules for each specific publisher (e.g.,
cloudwatch-publisher,csm-publisher). You must add these dependencies manually to use them.
- metrics-spi: Contains metrics interfaces and default implementations. This is a sub-module of
Use the DynamoDB Enhanced Client for idiomatic Java development
masterThe DynamoDB Enhanced Client is a high-level library designed to provide a more idiomatic Java experience compared to the standard
DynamoDbClient. It simplifies data access by handling conversions between Java objects (POJOs) and DynamoDB items, supporting common Java data types (likeInstantorNumber) that the standard client requires manual conversion for.Key capabilities include:
- Object Mapping: Automatic conversion between Java objects and DynamoDB items.
- Data-Plane Operations: Direct support for all DynamoDB data-plane operations using the same verbs and nouns as the service.
- Testing Support: Ability to create tables using the same models used for data-plane operations.
- Reduced Boilerplate: Eliminates the need to manually convert types or map objects to item representations.
Note: This client is a 'Level 2' library, meaning it is service-specific and built on top of the generated
DynamoDbClient. For full implementation details and usage, refer to the DynamoDb Enhanced Public Preview Library.Use S3TransferManager for high-level S3 object transfers
masterThe
S3TransferManageris a high-level, asynchronous, and non-blocking library built on top of the standard S3 client. It is designed to be the preferred solution for uploading and downloading S3 objects because it is more intuitive and generally more performant than using the low-level S3 client directly.Key features include:
- Asynchronous API: Conforms to SDK norms for non-blocking operations.
- Parallelism: Supports parallel downloads of any object (not just those uploaded via Multipart API).
- Resource Efficiency: Designed to make efficient use of system resources.
- Advanced Transfer Capabilities:
- Bandwidth limiting for uploads and downloads.
- Support for uploads/downloads to and from memory.
- Support for uploading to and downloading from pre-signed URLs.
- Support for progress listeners.
- Support for canned ACL policies.
- Trailing checksums for parallel transfers.
Use the {Service}BatchManager utility
masterThe SDK provides a batching utility named{Service}BatchManager(e.g.,SQSBatchManager) to facilitate batch operations on low-level service clients. This utility is separate from the standard service client and operates similarly toTransferManager. It is designed to handle batching logic, including manual flushing and buffer management, without replacing the core client methods.Design Overview: v2 Transfer Manager Progress Listeners
masterThe AWS SDK for Java v2 is introducing a new progress listener mechanism for
TransferManager-initiated uploads and downloads. This feature aims to provide an intuitive way to track transfer progress (e.g., for displaying progress bars) without the confusing overloaded parameters found in the Java SDK v1ProgressListener.Key goals for this implementation include:
- Creating an intuitive interface for tracking upload/download progress.
- Facilitating common progress bar logic.
- Designing for reuse across different use cases beyond
TransferManager. - Ensuring extensibility and minimal performance impact.
- Avoiding unnecessary overlap with the existing
ExecutionInterceptorsystem.
S3 Transfer Manager for simplified S3 operations
masterThe S3 Transfer Manager is a feature designed to simplify the process of uploading and downloading objects to and from Amazon S3. It is currently in development.Understand the AWS SDK for Java v2 versioning scheme
masterThe SDK uses a
MAJOR.MINOR.PATCH[-QUALIFIER]versioning format. Unlike strict semantic versioning,PATCHreleases may include new features. Use the version components to assess upgrade risk:- MAJOR: High risk. Expect API incompatibilities and breaking changes.
- MINOR: Medium risk. Upgrading should generally work, but check release notes. Changes may include incrementing minimum Java versions, deprecating APIs, or significant core runtime changes.
- PATCH: Low risk. Contains bug fixes and new features.
- QUALIFIER: Optional (e.g.,
PREVIEW).
Understand Request Presigners
masterRequest presigning allows a signature creator to use their secret signing credentials to generate an AWS request. This presigned request can then be executed by a separate signature user within a fixed time period without requiring additional authentication.
There is a distinction between a presigned request and a presigned URL:
- Presigned Request: Any request signed using query parameter signing intended for another entity to execute later. This may require the user to provide specific headers and payloads.
- Presigned URL: A specific type of presigned request that is easily executable by a browser. To qualify as a presigned URL, the request must:
- Use the
GETHTTP method. - Not include a payload.
- Not include
content-typeorx-amz-*headers.
- Use the
For example, an S3
GetObjectRequestis only a presigned URL if it excludes specific headers likex-amz-server-side-encryption-customer-algorithm,x-amz-server-side-encryption-customer-key,x-amz-server-side-encryption-customer-key-MD5, orx-amz-request-payer. Including these would cause a signature mismatch in a browser because the browser would not send those headers.DynamoDB Enhanced Client for object mapping
masterThe DynamoDB Enhanced Client is a released feature that simplifies writing and reading Java objects to and from Amazon DynamoDB, providing a higher-level abstraction than the standard client.Presign S3 operations using S3Presigner
masterTo generate presigned URLs for S3 operations (like
GetObjectorPutObject), use the{Service}Presignerpattern. The SDK provides specific request and response shapes for each operation to ensure type safety and ease of use. You can use either a builder pattern or a lambda-basedConsumerapproach to configure the presign request.// Using the Builder pattern s3.presignGetObject(GetObjectPresignRequest.builder() .getObject(GetObjectRequest.builder().bucket("bucket").key("key").build()) .signatureDuration(Duration.ofMinutes(15)) .build()); // Using the Consumer pattern s3.presignGetObject(r -> r.signatureDuration(Duration.ofMinutes(15)) .getObject(go -> go.bucket("bucket").key("key")));