forked from gavinmcnair/kafka-connect-s3
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CXP-3043: Update kafka-connect-s3 to use AWS Java SDK 2
- Loading branch information
Showing
12 changed files
with
316 additions
and
388 deletions.
There are no files selected for viewing
This file contains 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 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
25 changes: 12 additions & 13 deletions
25
common/src/main/java/com/spredfast/kafka/connect/s3/S3.java
This file contains 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 |
---|---|---|
@@ -1,32 +1,31 @@ | ||
package com.spredfast.kafka.connect.s3; | ||
|
||
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import java.net.URI; | ||
import java.util.Map; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.S3ClientBuilder; | ||
|
||
public class S3 { | ||
|
||
public static AmazonS3 s3client(Map<String, String> config) { | ||
public static S3Client s3client(Map<String, String> config) { | ||
|
||
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard(); | ||
S3ClientBuilder builder = S3Client.builder(); | ||
|
||
String s3Region = config.get("s3.region"); | ||
String s3Endpoint = config.get("s3.endpoint"); | ||
|
||
// If worker config sets explicit endpoint override (e.g. for testing) use that | ||
if (s3Endpoint != null) { | ||
if (s3Region == null) { | ||
throw new IllegalArgumentException("s3.region must be set if s3.endpoint is set"); | ||
} | ||
builder = builder.endpointOverride(URI.create(s3Endpoint)); | ||
} | ||
|
||
builder = builder.withEndpointConfiguration(new EndpointConfiguration(s3Endpoint, s3Region)); | ||
} else if (s3Region != null) { | ||
builder = builder.withRegion(s3Region); | ||
if (s3Region != null) { | ||
builder = builder.region(Region.of(s3Region)); | ||
} | ||
|
||
boolean s3PathStyle = Boolean.parseBoolean(config.get("s3.path_style")); | ||
builder = builder.forcePathStyle(Boolean.parseBoolean(config.get("s3.path_style"))); | ||
|
||
return builder.withPathStyleAccessEnabled(s3PathStyle).build(); | ||
return builder.build(); | ||
} | ||
} |
This file contains 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 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 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.