[ 
https://issues.apache.org/jira/browse/HADOOP-19729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18033183#comment-18033183
 ] 

ASF GitHub Bot commented on HADOOP-19729:
-----------------------------------------

anmolanmol1234 commented on code in PR #8043:
URL: https://github.com/apache/hadoop/pull/8043#discussion_r2465238391


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsApacheHttpClient.java:
##########
@@ -143,6 +173,51 @@ public HttpResponse execute(HttpRequestBase httpRequest,
     return httpClient.execute(httpRequest, abfsHttpClientContext);
   }
 
+  /**
+   * Executes the HTTP request with a deadline. If the request does not 
complete
+   * within the deadline, it is aborted and an IOException is thrown.
+   *
+   * @param httpRequest HTTP request to execute.
+   * @param abfsHttpClientContext HttpClient context.
+   * @param connectTimeout Connection timeout.
+   * @param readTimeout Read timeout.
+   * @param deadlineMillis Deadline in milliseconds.
+   *
+   * @return HTTP response.
+   * @throws IOException network error or deadline exceeded.
+   */
+  public HttpResponse executeWithDeadline(HttpRequestBase httpRequest,
+      final AbfsManagedHttpClientContext abfsHttpClientContext,
+      final int connectTimeout,
+      final int readTimeout,
+      final long deadlineMillis) throws IOException {
+    RequestConfig.Builder requestConfigBuilder = RequestConfig
+        .custom()
+        .setConnectTimeout(connectTimeout)
+        .setSocketTimeout(readTimeout);
+    httpRequest.setConfig(requestConfigBuilder.build());
+    ExecutorService executor = Executors.newSingleThreadExecutor();
+    Future<HttpResponse> future = executor.submit(() ->
+        httpClient.execute(httpRequest, abfsHttpClientContext)
+    );
+
+    try {
+      return future.get(deadlineMillis, TimeUnit.MILLISECONDS);
+    } catch (TimeoutException e) {
+      /* Deadline exceeded, abort the request.
+       * This will also kill the underlying socket exception in the HttpClient.
+       * Connection will be marker stale and won't be returned back to KAC for 
reuse.

Review Comment:
   nit: typo marked





> ABFS: [Perf] Network Profiling of Tailing Requests and Killing Bad 
> Connections Proactively
> ------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-19729
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19729
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: fs/azure
>    Affects Versions: 3.4.2
>            Reporter: Anuj Modi
>            Assignee: Anuj Modi
>            Priority: Major
>              Labels: pull-request-available
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to