YARN-9451. AggregatedLogsBlock shows wrong NM http port. Contributed by Prabhu Joseph

This commit is contained in:
Szilard Nemeth 2019-08-12 15:05:28 +02:00
parent e0517fea33
commit b91099efd6
2 changed files with 17 additions and 3 deletions

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.logaggregation.LogAggregationWebUtils; import org.apache.hadoop.yarn.logaggregation.LogAggregationWebUtils;
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController; import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory; import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock; import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -104,8 +105,9 @@ public class AggregatedLogsBlock extends HtmlBlock {
} catch (Exception fnf) { } catch (Exception fnf) {
html.h1() html.h1()
.__("Logs not available for " + logEntity .__("Logs not available for " + logEntity
+ ". Aggregation may not be complete, " + ". Aggregation may not be complete, Check back later or "
+ "Check back later or try the nodemanager at " + nodeId).__(); + "try to find the container logs in the local directory of "
+ "nodemanager " + nodeId).__();
if(nmApplicationLogUrl != null) { if(nmApplicationLogUrl != null) {
html.h1() html.h1()
.__("Or see application log at " + nmApplicationLogUrl) .__("Or see application log at " + nmApplicationLogUrl)
@ -129,6 +131,14 @@ public class AggregatedLogsBlock extends HtmlBlock {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String scheme = YarnConfiguration.useHttps(this.conf) ? "https://": String scheme = YarnConfiguration.useHttps(this.conf) ? "https://":
"http://"; "http://";
String webAppURLWithoutScheme =
WebAppUtils.getNMWebAppURLWithoutScheme(conf);
if (webAppURLWithoutScheme.contains(":")) {
String httpPort = webAppURLWithoutScheme.split(":")[1];
nodeId = NodeId.fromString(nodeId).getHost() + ":" + httpPort;
}
sb.append(scheme).append(nodeId).append("/node/application/").append(appId); sb.append(scheme).append(nodeId).append("/node/application/").append(appId);
return sb.toString(); return sb.toString();
} }

View File

@ -145,7 +145,11 @@ public class TestAggregatedLogsBlock {
block.getWriter().flush(); block.getWriter().flush();
String out = data.toString(); String out = data.toString();
assertTrue(out assertTrue(out
.contains("Logs not available for entity. Aggregation may not be complete, Check back later or try the nodemanager at localhost:1234")); .contains("Logs not available for entity. Aggregation may not be "
+ "complete, Check back later or try to find the container logs "
+ "in the local directory of nodemanager localhost:1234"));
assertTrue(out
.contains("Or see application log at http://localhost:8042"));
} }