darenwkt commented on code in PR #39:
URL:
https://github.com/apache/flink-connector-aws/pull/39#discussion_r1051107364
##########
flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSGeneralUtil.java:
##########
@@ -301,6 +303,58 @@ public static SdkAsyncHttpClient createAsyncHttpClient(
return
httpClientBuilder.buildWithDefaults(config.merge(HTTP_CLIENT_DEFAULTS));
}
+ public static SdkHttpClient createSyncHttpClient(final Properties
configProperties) {
+ return createSyncHttpClient(configProperties,
ApacheHttpClient.builder());
+ }
+
+ public static SdkHttpClient createSyncHttpClient(
+ final Properties configProperties, final ApacheHttpClient.Builder
httpClientBuilder) {
+
+ final AttributeMap.Builder clientConfiguration =
+
AttributeMap.builder().put(SdkHttpConfigurationOption.TCP_KEEPALIVE, true);
+
+ Optional.ofNullable(
+ configProperties.getProperty(
+
AWSConfigConstants.HTTP_CLIENT_MAX_CONCURRENCY))
+ .map(Integer::parseInt)
+ .ifPresent(
+ integer ->
+ clientConfiguration.put(
+
SdkHttpConfigurationOption.MAX_CONNECTIONS, integer));
+
+ Optional.ofNullable(
+ configProperties.getProperty(
+
AWSConfigConstants.HTTP_CLIENT_READ_TIMEOUT_MILLIS))
+ .map(Integer::parseInt)
+ .map(Duration::ofMillis)
+ .ifPresent(
+ timeout ->
+ clientConfiguration.put(
+
SdkHttpConfigurationOption.READ_TIMEOUT, timeout));
+
+
Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.TRUST_ALL_CERTIFICATES))
+ .map(Boolean::parseBoolean)
+ .ifPresent(
+ bool ->
+ clientConfiguration.put(
+
SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, bool));
+
+
Optional.ofNullable(configProperties.getProperty(AWSConfigConstants.HTTP_PROTOCOL_VERSION))
+ .map(Protocol::valueOf)
+ .ifPresent(
+ protocol ->
+ clientConfiguration.put(
+ SdkHttpConfigurationOption.PROTOCOL,
protocol));
+
Review Comment:
Done, extracted to common method
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]