npawar commented on code in PR #10369:
URL: https://github.com/apache/pinot/pull/10369#discussion_r1124074878


##########
pinot-plugins/pinot-file-system/pinot-s3/src/main/java/org/apache/pinot/plugin/filesystem/S3Config.java:
##########
@@ -111,6 +125,54 @@ public S3Config(PinotConfiguration pinotConfig) {
     if (_iamRoleBasedAccess) {
       Preconditions.checkNotNull(_roleArn, "Must provide 'roleArn' if 
iamRoleBasedAccess is enabled");
     }
+    PinotConfiguration httpConfig = 
pinotConfig.subset(HTTP_CLIENT_CONFIG_PREFIX);
+    _httpClientBuilder = httpConfig.isEmpty() ? null : 
createHttpClientBuilder(httpConfig);
+  }
+
+  private static ApacheHttpClient.Builder 
createHttpClientBuilder(PinotConfiguration config) {
+    ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder();
+    String value = config.getProperty(HTTP_CLIENT_CONFIG_MAX_CONNECTIONS);
+    if (value != null) {
+      int pv = Integer.parseInt(value);
+      LOGGER.debug("Set maxConnections to {} for http client builder", pv);
+      httpClientBuilder.maxConnections(pv);
+    }
+    value = config.getProperty(HTTP_CLIENT_CONFIG_SOCKET_TIMEOUT);
+    if (value != null) {
+      Duration pv = parseDuration(value);
+      httpClientBuilder.socketTimeout(pv);
+      LOGGER.debug("Set socketTimeout to {}sec for http client builder", 
pv.toSeconds());
+    }
+    value = config.getProperty(HTTP_CLIENT_CONFIG_CONNECTION_TIMEOUT);
+    if (value != null) {
+      Duration pv = parseDuration(value);
+      httpClientBuilder.connectionTimeout(pv);
+      LOGGER.debug("Set connectionTimeout to {}sec for http client builder", 
pv.toSeconds());
+    }
+    value = config.getProperty(HTTP_CLIENT_CONFIG_CONNECTION_TIME_TO_LIVE);
+    if (value != null) {
+      Duration pv = parseDuration(value);
+      httpClientBuilder.connectionTimeToLive(pv);
+      LOGGER.debug("Set connectionTimeToLive to {}sec for http client 
builder", pv.toSeconds());
+    }
+    value = 
config.getProperty(HTTP_CLIENT_CONFIG_CONNECTION_ACQUISITION_TIMEOUT);
+    if (value != null) {
+      Duration pv = parseDuration(value);
+      httpClientBuilder.connectionAcquisitionTimeout(pv);
+      LOGGER.debug("Set connectionAcquisitionTimeout to {}sec for http client 
builder", pv.toSeconds());
+    }
+    return httpClientBuilder;
+  }
+
+  @VisibleForTesting
+  static Duration parseDuration(String durStr) {
+    try {
+      // try format like '1hr20s'
+      return Duration.ofMillis(TimeUtils.convertPeriodToMillis(durStr));
+    } catch (Exception ignore) {
+    }
+    // try format like 'PT1H20S'
+    return Duration.parse(durStr);

Review Comment:
   nit: catch exception here too, and put error log message telling user that 
they need one of the 2 formats



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to