From afb9394c9103aa9f3dbe36d4067621ed1b986395 Mon Sep 17 00:00:00 2001 From: Junping Du Date: Tue, 22 Jul 2014 13:07:23 +0000 Subject: [PATCH] YARN-2242. Addendum patch. Improve exception information on AM launch crashes. (Contributed by Li Lu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1612565 13f79535-47bb-0310-9956-ffa450edef68 --- .../rmapp/attempt/RMAppAttemptImpl.java | 20 +++++++++++++------ .../attempt/TestRMAppAttemptTransitions.java | 17 ++++++++++++---- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/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 b/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 64657ad7ccf..50a0755be62 100644 --- a/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 +++ b/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 @@ -1294,12 +1294,20 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable { private String getAMContainerCrashedDiagnostics( RMAppAttemptContainerFinishedEvent finishEvent) { ContainerStatus status = finishEvent.getContainerStatus(); - String diagnostics = - "AM Container for " + finishEvent.getApplicationAttemptId() - + " exited with " + " exitCode: " + status.getExitStatus() + ". " - + "Check application tracking page: " + this.getTrackingUrl() - + " . Then, click on links to logs of each attempt for detailed output. "; - return diagnostics; + StringBuilder diagnosticsBuilder = new StringBuilder(); + diagnosticsBuilder.append("AM Container for ").append( + finishEvent.getApplicationAttemptId()).append( + " exited with ").append(" exitCode: ").append(status.getExitStatus()). + append("\n"); + if (this.getTrackingUrl() != null) { + diagnosticsBuilder.append("For more detailed output,").append( + " check application tracking page:").append( + this.getTrackingUrl()).append( + "Then, click on links to logs of each attempt.\n"); + } + diagnosticsBuilder.append("Diagnostics: ").append(status.getDiagnostics()) + .append("Failing this attempt"); + return diagnosticsBuilder.toString(); } private static class FinalTransition extends BaseFinalTransition { diff --git a/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 b/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 ca0fc3960a0..1de35fcfa98 100644 --- a/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 +++ b/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 @@ -823,7 +823,9 @@ public class TestRMAppAttemptTransitions { applicationAttempt.getAppAttemptState()); verifyTokenCount(applicationAttempt.getAppAttemptId(), 1); verifyApplicationAttemptFinished(RMAppAttemptState.FAILED); - verifyAMCrashAtAllocatedDiagnosticInfo(applicationAttempt.getDiagnostics()); + boolean shouldCheckURL = (applicationAttempt.getTrackingUrl() != null); + verifyAMCrashAtAllocatedDiagnosticInfo(applicationAttempt.getDiagnostics(), + exitCode, shouldCheckURL); } @Test @@ -1241,11 +1243,18 @@ public class TestRMAppAttemptTransitions { verifyApplicationAttemptFinished(RMAppAttemptState.FAILED); } - private void verifyAMCrashAtAllocatedDiagnosticInfo(String diagnostics) { - assertTrue("Diagnostic information does not contain application proxy URL", - diagnostics.contains(applicationAttempt.getWebProxyBase())); + private void verifyAMCrashAtAllocatedDiagnosticInfo(String diagnostics, + int exitCode, boolean shouldCheckURL) { assertTrue("Diagnostic information does not point the logs to the users", diagnostics.contains("logs")); + assertTrue("Diagnostic information does not contain application attempt id", + diagnostics.contains(applicationAttempt.getAppAttemptId().toString())); + assertTrue("Diagnostic information does not contain application exit code", + diagnostics.contains("exitCode: " + exitCode)); + if (shouldCheckURL) { + assertTrue("Diagnostic information does not contain application proxy URL", + diagnostics.contains(applicationAttempt.getWebProxyBase())); + } } private void verifyTokenCount(ApplicationAttemptId appAttemptId, int count) {