You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-commits@hadoop.apache.org by ac...@apache.org on 2013/04/20 21:19:17 UTC
svn commit: r1470217 - in
/hadoop/common/branches/branch-2/hadoop-mapreduce-project: ./
hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/
hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/j...
Author: acmurthy
Date: Sat Apr 20 19:19:16 2013
New Revision: 1470217
URL: http://svn.apache.org/r1470217
Log:
Merge -c 1470216 from trunk to branch-2 to fix MAPREDUCE-5066. Added a timeout for the job.end.notification.url. Contributed by Ivan Mitic.
Added:
hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java
- copied unchanged from r1470216, hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestJobEndNotifier.java
Modified:
hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/JobEndNotifier.java
hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java
hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java
Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt?rev=1470217&r1=1470216&r2=1470217&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/CHANGES.txt Sat Apr 20 19:19:16 2013
@@ -168,6 +168,9 @@ Release 2.0.5-beta - UNRELEASED
MAPREDUCE-5163. Update MR App to not use API utility methods for collections
after YARN-441. (Xuan Gong via vinodkv)
+ MAPREDUCE-5066. Added a timeout for the job.end.notification.url. (Ivan
+ Mitic via acmurthy)
+
Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES
Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/JobEndNotifier.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/JobEndNotifier.java?rev=1470217&r1=1470216&r2=1470217&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/JobEndNotifier.java (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/JobEndNotifier.java Sat Apr 20 19:19:16 2013
@@ -27,6 +27,7 @@ import java.net.URL;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapred.JobContext;
import org.apache.hadoop.mapreduce.MRJobConfig;
import org.apache.hadoop.mapreduce.v2.api.records.JobReport;
import org.mortbay.log.Log;
@@ -54,6 +55,7 @@ public class JobEndNotifier implements C
protected String proxyConf;
protected int numTries; //Number of tries to attempt notification
protected int waitInterval; //Time (ms) to wait between retrying notification
+ protected int timeout; // Timeout (ms) on the connection and notification
protected URL urlToNotify; //URL to notify read from the config
protected Proxy proxyToUse = Proxy.NO_PROXY; //Proxy to use for notification
@@ -76,6 +78,9 @@ public class JobEndNotifier implements C
);
waitInterval = (waitInterval < 0) ? 5000 : waitInterval;
+ timeout = conf.getInt(JobContext.MR_JOB_END_NOTIFICATION_TIMEOUT,
+ JobContext.DEFAULT_MR_JOB_END_NOTIFICATION_TIMEOUT);
+
userUrl = conf.get(MRJobConfig.MR_JOB_END_NOTIFICATION_URL);
proxyConf = conf.get(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY);
@@ -112,8 +117,7 @@ public class JobEndNotifier implements C
}
/**
- * Notify the URL just once. Use best effort. Timeout hard coded to 5
- * seconds.
+ * Notify the URL just once. Use best effort.
*/
protected boolean notifyURLOnce() {
boolean success = false;
@@ -121,8 +125,8 @@ public class JobEndNotifier implements C
Log.info("Job end notification trying " + urlToNotify);
HttpURLConnection conn =
(HttpURLConnection) urlToNotify.openConnection(proxyToUse);
- conn.setConnectTimeout(5*1000);
- conn.setReadTimeout(5*1000);
+ conn.setConnectTimeout(timeout);
+ conn.setReadTimeout(timeout);
conn.setAllowUserInteraction(false);
if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
Log.warn("Job end notification to " + urlToNotify +" failed with code: "
Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java?rev=1470217&r1=1470216&r2=1470217&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java Sat Apr 20 19:19:16 2013
@@ -73,6 +73,13 @@ public class TestJobEndNotifier extends
+ waitInterval, waitInterval == 5000);
}
+ private void testTimeout(Configuration conf) {
+ conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_TIMEOUT, "1000");
+ setConf(conf);
+ Assert.assertTrue("Expected timeout to be 1000, but was "
+ + timeout, timeout == 1000);
+ }
+
private void testProxyConfiguration(Configuration conf) {
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost");
setConf(conf);
@@ -109,6 +116,7 @@ public class TestJobEndNotifier extends
Configuration conf = new Configuration();
testNumRetries(conf);
testWaitInterval(conf);
+ testTimeout(conf);
testProxyConfiguration(conf);
}
Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java?rev=1470217&r1=1470216&r2=1470217&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobEndNotifier.java Sat Apr 20 19:19:16 2013
@@ -44,9 +44,10 @@ public class JobEndNotifier {
JobEndStatusInfo notification = null;
String uri = conf.getJobEndNotificationURI();
if (uri != null) {
- // +1 to make logic for first notification identical to a retry
- int retryAttempts = conf.getInt(JobContext.MR_JOB_END_RETRY_ATTEMPTS, 0) + 1;
+ int retryAttempts = conf.getInt(JobContext.MR_JOB_END_RETRY_ATTEMPTS, 0);
long retryInterval = conf.getInt(JobContext.MR_JOB_END_RETRY_INTERVAL, 30000);
+ int timeout = conf.getInt(JobContext.MR_JOB_END_NOTIFICATION_TIMEOUT,
+ JobContext.DEFAULT_MR_JOB_END_NOTIFICATION_TIMEOUT);
if (uri.contains("$jobId")) {
uri = uri.replace("$jobId", status.getJobID().toString());
}
@@ -56,17 +57,22 @@ public class JobEndNotifier {
(status.getRunState() == JobStatus.FAILED) ? "FAILED" : "KILLED";
uri = uri.replace("$jobStatus", statusStr);
}
- notification = new JobEndStatusInfo(uri, retryAttempts, retryInterval);
+ notification = new JobEndStatusInfo(
+ uri, retryAttempts, retryInterval, timeout);
}
return notification;
}
- private static int httpNotification(String uri) throws IOException {
+ private static int httpNotification(String uri, int timeout)
+ throws IOException {
URI url = new URI(uri, false);
- HttpClient m_client = new HttpClient();
+ HttpClient httpClient = new HttpClient();
+ httpClient.getParams().setSoTimeout(timeout);
+ httpClient.getParams().setConnectionManagerTimeout(timeout);
+
HttpMethod method = new GetMethod(url.getEscapedURI());
method.setRequestHeader("Accept", "*/*");
- return m_client.executeMethod(method);
+ return httpClient.executeMethod(method);
}
// for use by the LocalJobRunner, without using a thread&queue,
@@ -74,9 +80,10 @@ public class JobEndNotifier {
public static void localRunnerNotification(JobConf conf, JobStatus status) {
JobEndStatusInfo notification = createNotification(conf, status);
if (notification != null) {
- while (notification.configureForRetry()) {
+ do {
try {
- int code = httpNotification(notification.getUri());
+ int code = httpNotification(notification.getUri(),
+ notification.getTimeout());
if (code != 200) {
throw new IOException("Invalid response status code: " + code);
}
@@ -96,7 +103,7 @@ public class JobEndNotifier {
catch (InterruptedException iex) {
LOG.error("Notification retry error [" + notification + "]", iex);
}
- }
+ } while (notification.configureForRetry());
}
}
@@ -105,12 +112,15 @@ public class JobEndNotifier {
private int retryAttempts;
private long retryInterval;
private long delayTime;
+ private int timeout;
- JobEndStatusInfo(String uri, int retryAttempts, long retryInterval) {
+ JobEndStatusInfo(String uri, int retryAttempts, long retryInterval,
+ int timeout) {
this.uri = uri;
this.retryAttempts = retryAttempts;
this.retryInterval = retryInterval;
this.delayTime = System.currentTimeMillis();
+ this.timeout = timeout;
}
public String getUri() {
@@ -125,6 +135,10 @@ public class JobEndNotifier {
return retryInterval;
}
+ public int getTimeout() {
+ return timeout;
+ }
+
public boolean configureForRetry() {
boolean retry = false;
if (getRetryAttempts() > 0) {
Modified: hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java?rev=1470217&r1=1470216&r2=1470217&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java (original)
+++ hadoop/common/branches/branch-2/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java Sat Apr 20 19:19:16 2013
@@ -616,6 +616,9 @@ public interface MRJobConfig {
public static final String MR_JOB_END_NOTIFICATION_PROXY =
"mapreduce.job.end-notification.proxy";
+ public static final String MR_JOB_END_NOTIFICATION_TIMEOUT =
+ "mapreduce.job.end-notification.timeout";
+
public static final String MR_JOB_END_RETRY_ATTEMPTS =
"mapreduce.job.end-notification.retry.attempts";
@@ -628,6 +631,9 @@ public interface MRJobConfig {
public static final String MR_JOB_END_NOTIFICATION_MAX_RETRY_INTERVAL =
"mapreduce.job.end-notification.max.retry.interval";
+ public static final int DEFAULT_MR_JOB_END_NOTIFICATION_TIMEOUT =
+ 5000;
+
/*
* MR AM Service Authorization
*/