Skip to content

Commit

Permalink
MAPREDUCE-7385. impove JobEndNotifier#httpNotification With recommend…
Browse files Browse the repository at this point in the history
…ed methods. (#4403). Contributed by fanshilun.

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
  • Loading branch information
slfan1989 committed Aug 8, 2022
1 parent 895f7c5 commit 977f4b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

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;

Expand Down Expand Up @@ -67,10 +67,13 @@ private static JobEndStatusInfo createNotification(JobConf conf,

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testLocalJobRunnerUriSubstitution() throws InterruptedException {
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
Expand Down

0 comments on commit 977f4b6

Please sign in to comment.