diff --git hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java index 54c5b60..d9dd777 100644 --- hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java +++ hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java @@ -33,7 +33,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; -import org.apache.hadoop.http.HttpConfig; import org.apache.hadoop.mapreduce.JobID; import org.apache.hadoop.mapreduce.JobStatus; import org.apache.hadoop.mapreduce.MRJobConfig; @@ -424,9 +423,6 @@ public JobStatus getJobStatus(JobID oldJobID) throws IOException { String historyTrackingUrl = report.getTrackingUrl(); String url = StringUtils.isNotEmpty(historyTrackingUrl) ? historyTrackingUrl : trackingUrl; - if (!UNAVAILABLE.equals(url)) { - url = HttpConfig.getSchemePrefix() + url; - } jobStatus = TypeConverter.fromYarn(report, url); } return jobStatus; diff --git hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientServiceDelegate.java hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientServiceDelegate.java index 7fbd2ab..7b47711 100644 --- hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientServiceDelegate.java +++ hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestClientServiceDelegate.java @@ -514,7 +514,7 @@ private GetJobReportResponse getJobReportResponseFromHistoryServer() { jobReport.setMapProgress(1.0f); jobReport.setReduceProgress(1.0f); jobReport.setJobFile("TestJobFilePath"); - jobReport.setTrackingUrl("TestTrackingUrl"); + jobReport.setTrackingUrl("http://TestTrackingUrl"); jobReportResponse.setJobReport(jobReport); return jobReportResponse; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java index ede5501..065d680 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java @@ -143,6 +143,21 @@ public static String getNMWebAppURLWithoutScheme(Configuration conf) { return conf.get(YarnConfiguration.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; + } } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java index ae3bc9f..f68a4a5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java @@ -381,7 +381,7 @@ public RMAppAttemptImpl(ApplicationAttemptId appAttemptId, this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); - this.proxiedTrackingUrl = generateProxyUriWithoutScheme(); + this.proxiedTrackingUrl = generateProxyUriWithScheme(null); this.stateMachine = stateMachineFactory.make(this); this.user = user; @@ -470,11 +470,7 @@ public String getWebProxyBase() { } } - private String generateProxyUriWithoutScheme() { - return generateProxyUriWithoutScheme(null); - } - - private String generateProxyUriWithoutScheme( + private String generateProxyUriWithScheme( final String trackingUriWithoutScheme) { this.readLock.lock(); try { @@ -484,8 +480,7 @@ private String generateProxyUriWithoutScheme( URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy); URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri, applicationAttemptId.getApplicationId()); - //We need to strip off the scheme to have it match what was there before - return result.toASCIIString().substring(HttpConfig.getSchemePrefix().length()); + return result.toASCIIString(); } catch (URISyntaxException e) { LOG.warn("Could not proxify "+trackingUriWithoutScheme,e); return trackingUriWithoutScheme; @@ -1006,7 +1001,7 @@ public void transition(RMAppAttemptImpl appAttempt, appAttempt.origTrackingUrl = sanitizeTrackingUrl(registrationEvent.getTrackingurl()); appAttempt.proxiedTrackingUrl = - appAttempt.generateProxyUriWithoutScheme(appAttempt.origTrackingUrl); + appAttempt.generateProxyUriWithScheme(appAttempt.origTrackingUrl); // Let the app know appAttempt.eventHandler.handle(new RMAppEvent(appAttempt @@ -1142,7 +1137,7 @@ public RMAppAttemptState transition(RMAppAttemptImpl appAttempt, appAttempt.origTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getTrackingUrl()); appAttempt.proxiedTrackingUrl = - appAttempt.generateProxyUriWithoutScheme(appAttempt.origTrackingUrl); + appAttempt.generateProxyUriWithScheme(appAttempt.origTrackingUrl); appAttempt.finalStatus = unregisterEvent.getFinalApplicationStatus(); // Tell the app diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java index 7cb126f..21f0271 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/AppInfo.java @@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.Times; +import org.apache.hadoop.yarn.webapp.util.WebAppUtils; @XmlRootElement(name = "app") @XmlAccessorType(XmlAccessType.FIELD) @@ -91,10 +92,13 @@ public AppInfo(RMApp app, Boolean hasAccess) { this.trackingUI = this.trackingUrlIsNotReady ? "UNASSIGNED" : (app .getFinishTime() == 0 ? "ApplicationMaster" : "History"); 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.applicationType = app.getApplicationType(); this.appIdNum = String.valueOf(app.getApplicationId().getId()); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java index a878be1..1f3c506 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java @@ -41,7 +41,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.http.HttpConfig; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod; @@ -277,8 +276,7 @@ private String getProxyUrl(RMAppAttempt appAttempt) { URI proxyUri = ProxyUriUtils.getUriFromAMUrl(proxy); URI result = ProxyUriUtils.getProxyUri(trackingUri, proxyUri, appAttempt.getAppAttemptId().getApplicationId()); - url = result.toASCIIString().substring( - HttpConfig.getSchemePrefix().length()); + url = result.toASCIIString(); } catch (URISyntaxException ex) { Assert.fail(); }