MAPREDUCE-7385. impove JobEndNotifier#httpNotification With recommended methods. (#4403). Contributed by fanshilun.
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
parent
895f7c51fd
commit
977f4b6165
@ -26,10 +26,10 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
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.methods.HttpGet;
|
||||||
import org.apache.http.client.params.ClientPNames;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
|
||||||
import org.apache.http.params.CoreConnectionPNames;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -67,10 +67,13 @@ private static JobEndStatusInfo createNotification(JobConf conf,
|
|||||||
|
|
||||||
private static int httpNotification(String uri, int timeout)
|
private static int httpNotification(String uri, int timeout)
|
||||||
throws IOException, URISyntaxException {
|
throws IOException, URISyntaxException {
|
||||||
DefaultHttpClient client = new DefaultHttpClient();
|
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||||
client.getParams()
|
httpClientBuilder.setDefaultRequestConfig(
|
||||||
.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout)
|
RequestConfig.custom()
|
||||||
.setLongParameter(ClientPNames.CONN_MANAGER_TIMEOUT, (long) timeout);
|
.setConnectionRequestTimeout(timeout)
|
||||||
|
.setSocketTimeout(timeout)
|
||||||
|
.build());
|
||||||
|
HttpClient client = httpClientBuilder.build();
|
||||||
HttpGet httpGet = new HttpGet(new URI(uri));
|
HttpGet httpGet = new HttpGet(new URI(uri));
|
||||||
httpGet.setHeader("Accept", "*/*");
|
httpGet.setHeader("Accept", "*/*");
|
||||||
return client.execute(httpGet).getStatusLine().getStatusCode();
|
return client.execute(httpGet).getStatusLine().getStatusCode();
|
||||||
|
@ -139,7 +139,7 @@ public void testLocalJobRunnerUriSubstitution() throws InterruptedException {
|
|||||||
baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
|
baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
|
||||||
JobEndNotifier.localRunnerNotification(jobConf, 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
|
// synchronous
|
||||||
|
|
||||||
// Validate params
|
// Validate params
|
||||||
|
Loading…
Reference in New Issue
Block a user