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 4210c54b86..254768b40f 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 @@ -1315,7 +1315,7 @@ private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event, // AFTER the initial saving on app-attempt-start // These fields can be visible from outside only after they are saved in // StateStore - String diags = null; + BoundedAppender diags = new BoundedAppender(diagnostics.limit); // don't leave the tracking URL pointing to a non-existent AM if (conf.getBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, @@ -1329,15 +1329,15 @@ private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event, int exitStatus = ContainerExitStatus.INVALID; switch (event.getType()) { case LAUNCH_FAILED: - diags = event.getDiagnosticMsg(); + diags.append(event.getDiagnosticMsg()); break; case REGISTERED: - diags = getUnexpectedAMRegisteredDiagnostics(); + diags.append(getUnexpectedAMRegisteredDiagnostics()); break; case UNREGISTERED: RMAppAttemptUnregistrationEvent unregisterEvent = (RMAppAttemptUnregistrationEvent) event; - diags = unregisterEvent.getDiagnosticMsg(); + diags.append(unregisterEvent.getDiagnosticMsg()); // reset finalTrackingUrl to url sent by am finalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl()); finalStatus = unregisterEvent.getFinalApplicationStatus(); @@ -1345,16 +1345,16 @@ private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event, case CONTAINER_FINISHED: RMAppAttemptContainerFinishedEvent finishEvent = (RMAppAttemptContainerFinishedEvent) event; - diags = getAMContainerCrashedDiagnostics(finishEvent); + diags.append(getAMContainerCrashedDiagnostics(finishEvent)); exitStatus = finishEvent.getContainerStatus().getExitStatus(); break; case KILL: break; case FAIL: - diags = event.getDiagnosticMsg(); + diags.append(event.getDiagnosticMsg()); break; case EXPIRE: - diags = getAMExpiredDiagnostics(event); + diags.append(getAMExpiredDiagnostics(event)); break; default: break; @@ -1368,7 +1368,7 @@ private void rememberTargetTransitionsAndStoreState(RMAppAttemptEvent event, ApplicationAttemptStateData.newInstance( applicationAttemptId, getMasterContainer(), rmStore.getCredentialsFromAppAttempt(this), - startTime, stateToBeStored, finalTrackingUrl, diags, + startTime, stateToBeStored, finalTrackingUrl, diags.toString(), finalStatus, exitStatus, getFinishTime(), resUsage.getMemorySeconds(), resUsage.getVcoreSeconds(),