You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2022/08/08 19:29:10 UTC

[hadoop] branch trunk updated: MAPREDUCE-7385. impove JobEndNotifier#httpNotification With recommended methods. (#4403). Contributed by fanshilun.

This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 977f4b61652 MAPREDUCE-7385. impove JobEndNotifier#httpNotification With recommended methods. (#4403). Contributed by fanshilun.
977f4b61652 is described below

commit 977f4b616525d5d6114e550953ad94c9bf6da7e6
Author: slfan1989 <55...@users.noreply.github.com>
AuthorDate: Tue Aug 9 03:29:03 2022 +0800

    MAPREDUCE-7385. impove JobEndNotifier#httpNotification With recommended methods. (#4403). Contributed by fanshilun.
    
    Signed-off-by: Ayush Saxena <ay...@apache.org>
---
 .../java/org/apache/hadoop/mapred/JobEndNotifier.java   | 17 ++++++++++-------
 .../org/apache/hadoop/mapred/TestJobEndNotifier.java    |  2 +-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java
index 1ce525490d1..b2fa79808ca 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java
@@ -26,10 +26,10 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,10 +67,13 @@ public class JobEndNotifier {
 
   private static int httpNotification(String uri, int timeout)
       throws IOException, URISyntaxException {
-    DefaultHttpClient client = new DefaultHttpClient();
-    client.getParams()
-        .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout)
-        .setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, (long) timeout);
+    HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+    httpClientBuilder.setDefaultRequestConfig(
+        RequestConfig.custom()
+        .setConnectionRequestTimeout(timeout)
+        .setSocketTimeout(timeout)
+        .build());
+    HttpClient client = httpClientBuilder.build();
     HttpGet httpGet = new HttpGet(new URI(uri));
     httpGet.setHeader("Accept", "*/*");
     return client.execute(httpGet).getStatusLine().getStatusCode();
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java
index e3d1241cdc6..46b581d2d0e 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java
@@ -139,7 +139,7 @@ public class TestJobEndNotifier {
         baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
     JobEndNotifier.localRunnerNotification(jobConf, jobStatus);
 
-    // No need to wait for the notification to go thru since calls are
+    // No need to wait for the notification to go through since calls are
     // synchronous
 
     // Validate params


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org