kanfade commented on a change in pull request #8444: [FLINK-10190] [Kinesis
Connector] Allow AWS_REGION to be supplied along with custom Kinesis endpoint
URL: https://github.com/apache/flink/pull/8444#discussion_r341400647
##########
File path:
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/util/AWSUtil.java
##########
@@ -84,13 +84,20 @@ public static AmazonKinesis createKinesisClient(Properties
configProps, ClientCo
.withCredentials(AWSUtil.getCredentialsProvider(configProps))
.withClientConfiguration(awsClientConfig);
- if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
- // Set signingRegion as null, to facilitate mocking
Kinesis for local tests
+ if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT) &&
configProps.containsKey(AWSConfigConstants.AWS_REGION)) {
+ // Set signingRegion to the value of AWS_REGION for
region-specific signing on a custom endpoint
builder.withEndpointConfiguration(new
AwsClientBuilder.EndpointConfiguration(
-
configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT),
-
null));
+
configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT),
+
configProps.getProperty(AWSConfigConstants.AWS_REGION)));
} else {
-
builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)));
+ if
(configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
+ // Set signingRegion as null, to facilitate
mocking Kinesis for local tests
+ builder.withEndpointConfiguration(new
AwsClientBuilder.EndpointConfiguration(
+
configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT),
+ null));
+ } else {
+
builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)));
+ }
Review comment:
Can't we just simplify this code part like below ? (assuming
configProps.getProperty() would return null if it is not present. Please
correct me if I am wrong here.)
if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) {
// If an endpoint is specified, we give preference to
using an endpoint and use the region property to
// sign the request.
builder.withEndpointConfiguration(new
AwsClientBuilder.EndpointConfiguration(
configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT),
configProps.getProperty(AWSConfigConstants.AWS_REGION)));
} else {
builder.withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)));
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services