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