YARN-1283. Fixed RM to give a fully-qualified proxy URL for an application so that clients don't need to do scheme-mangling. Contributed by Omkar Vinit Joshi.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1530819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-10-09 22:49:06 +00:00
parent 00395a0064
commit 9b9ddf29e2
7 changed files with 34 additions and 22 deletions

View File

@ -33,7 +33,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.mapreduce.JobID; import org.apache.hadoop.mapreduce.JobID;
import org.apache.hadoop.mapreduce.JobStatus; import org.apache.hadoop.mapreduce.JobStatus;
import org.apache.hadoop.mapreduce.MRJobConfig; import org.apache.hadoop.mapreduce.MRJobConfig;
@ -424,9 +423,6 @@ public class ClientServiceDelegate {
String historyTrackingUrl = report.getTrackingUrl(); String historyTrackingUrl = report.getTrackingUrl();
String url = StringUtils.isNotEmpty(historyTrackingUrl) String url = StringUtils.isNotEmpty(historyTrackingUrl)
? historyTrackingUrl : trackingUrl; ? historyTrackingUrl : trackingUrl;
if (!UNAVAILABLE.equals(url)) {
url = HttpConfig.getSchemePrefix() + url;
}
jobStatus = TypeConverter.fromYarn(report, url); jobStatus = TypeConverter.fromYarn(report, url);
} }
return jobStatus; return jobStatus;

View File

@ -514,7 +514,7 @@ public class TestClientServiceDelegate {
jobReport.setMapProgress(1.0f); jobReport.setMapProgress(1.0f);
jobReport.setReduceProgress(1.0f); jobReport.setReduceProgress(1.0f);
jobReport.setJobFile("TestJobFilePath"); jobReport.setJobFile("TestJobFilePath");
jobReport.setTrackingUrl("TestTrackingUrl"); jobReport.setTrackingUrl("http://TestTrackingUrl");
jobReportResponse.setJobReport(jobReport); jobReportResponse.setJobReport(jobReport);
return jobReportResponse; return jobReportResponse;
} }

View File

@ -91,6 +91,10 @@ Release 2.2.1 - UNRELEASED
YARN-1284. LCE: Race condition leaves dangling cgroups entries for killed YARN-1284. LCE: Race condition leaves dangling cgroups entries for killed
containers. (Alejandro Abdelnur via Sandy Ryza) containers. (Alejandro Abdelnur via Sandy Ryza)
YARN-1283. Fixed RM to give a fully-qualified proxy URL for an application
so that clients don't need to do scheme-mangling. (Omkar Vinit Joshi via
vinodkv)
Release 2.2.0 - 2013-10-13 Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -143,6 +143,21 @@ public class WebAppUtils {
return conf.get(YarnConfiguration.NM_WEBAPP_ADDRESS, return conf.get(YarnConfiguration.NM_WEBAPP_ADDRESS,
YarnConfiguration.DEFAULT_NM_WEBAPP_ADDRESS); YarnConfiguration.DEFAULT_NM_WEBAPP_ADDRESS);
} }
}
/**
* if url has scheme then it will be returned as it is else it will return
* url with scheme.
* @param schemePrefix eg. http:// or https://
* @param url
* @return url with scheme
*/
public static String getURLWithScheme(String schemePrefix, String url) {
// If scheme is provided then it will be returned as it is
if (url.indexOf("://") > 0) {
return url;
} else {
return schemePrefix + url;
}
} }
} }

View File

@ -381,7 +381,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
this.readLock = lock.readLock(); this.readLock = lock.readLock();
this.writeLock = lock.writeLock(); this.writeLock = lock.writeLock();
this.proxiedTrackingUrl = generateProxyUriWithoutScheme(); this.proxiedTrackingUrl = generateProxyUriWithScheme(null);
this.stateMachine = stateMachineFactory.make(this); this.stateMachine = stateMachineFactory.make(this);
this.user = user; this.user = user;
@ -470,11 +470,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
} }
} }
private String generateProxyUriWithoutScheme() { private String generateProxyUriWithScheme(
return generateProxyUriWithoutScheme(null);
}
private String generateProxyUriWithoutScheme(
final String trackingUriWithoutScheme) { final String trackingUriWithoutScheme) {
this.readLock.lock(); this.readLock.lock();
try { try {
@ -484,8 +480,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy); URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy);
URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri, URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri,
applicationAttemptId.getApplicationId()); applicationAttemptId.getApplicationId());
//We need to strip off the scheme to have it match what was there before return result.toASCIIString();
return result.toASCIIString().substring(HttpConfig.getSchemePrefix().length());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
LOG.warn("Could not proxify "+trackingUriWithoutScheme,e); LOG.warn("Could not proxify "+trackingUriWithoutScheme,e);
return trackingUriWithoutScheme; return trackingUriWithoutScheme;
@ -1006,7 +1001,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
appAttempt.origTrackingUrl = appAttempt.origTrackingUrl =
sanitizeTrackingUrl(registrationEvent.getTrackingurl()); sanitizeTrackingUrl(registrationEvent.getTrackingurl());
appAttempt.proxiedTrackingUrl = appAttempt.proxiedTrackingUrl =
appAttempt.generateProxyUriWithoutScheme(appAttempt.origTrackingUrl); appAttempt.generateProxyUriWithScheme(appAttempt.origTrackingUrl);
// Let the app know // Let the app know
appAttempt.eventHandler.handle(new RMAppEvent(appAttempt appAttempt.eventHandler.handle(new RMAppEvent(appAttempt
@ -1142,7 +1137,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
appAttempt.origTrackingUrl = appAttempt.origTrackingUrl =
sanitizeTrackingUrl(unregisterEvent.getTrackingUrl()); sanitizeTrackingUrl(unregisterEvent.getTrackingUrl());
appAttempt.proxiedTrackingUrl = appAttempt.proxiedTrackingUrl =
appAttempt.generateProxyUriWithoutScheme(appAttempt.origTrackingUrl); appAttempt.generateProxyUriWithScheme(appAttempt.origTrackingUrl);
appAttempt.finalStatus = unregisterEvent.getFinalApplicationStatus(); appAttempt.finalStatus = unregisterEvent.getFinalApplicationStatus();
// Tell the app // Tell the app

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Times; import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
@XmlRootElement(name = "app") @XmlRootElement(name = "app")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@ -91,10 +92,13 @@ public class AppInfo {
this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app
.getFinishTime() == 0 ? "ApplicationMaster" : "History"); .getFinishTime() == 0 ? "ApplicationMaster" : "History");
if (!trackingUrlIsNotReady) { if (!trackingUrlIsNotReady) {
this.trackingUrl = join(HttpConfig.getSchemePrefix(), trackingUrl); this.trackingUrl =
WebAppUtils.getURLWithScheme(HttpConfig.getSchemePrefix(),
trackingUrl);
this.trackingUrlPretty = this.trackingUrl;
} else {
this.trackingUrlPretty = "UNASSIGNED";
} }
this.trackingUrlPretty = trackingUrlIsNotReady ? "UNASSIGNED" : join(
HttpConfig.getSchemePrefix(), trackingUrl);
this.applicationId = app.getApplicationId(); this.applicationId = app.getApplicationId();
this.applicationType = app.getApplicationType(); this.applicationType = app.getApplicationType();
this.appIdNum = String.valueOf(app.getApplicationId().getId()); this.appIdNum = String.valueOf(app.getApplicationId().getId());

View File

@ -41,7 +41,6 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod; import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
@ -277,8 +276,7 @@ public class TestRMAppAttemptTransitions {
URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy); URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy);
URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri, URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri,
appAttempt.getAppAttemptId().getApplicationId()); appAttempt.getAppAttemptId().getApplicationId());
url = result.toASCIIString().substring( url = result.toASCIIString();
HttpConfig.getSchemePrefix().length());
} catch (URISyntaxException ex) { } catch (URISyntaxException ex) {
Assert.fail(); Assert.fail();
} }