From eb97badbcd0f47fda23e4ecba894727e58c1e549 Mon Sep 17 00:00:00 2001 From: Bikas Saha Date: Wed, 20 Nov 2013 22:29:16 +0000 Subject: [PATCH] Merge r1543973 from trunk to branch-2 for YARN-1053. Diagnostic message from ContainerExitEvent is ignored in ContainerImpl (Omkar Vinit Joshi via bikas) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1543974 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../containermanager/container/ContainerImpl.java | 9 ++++++++- .../containermanager/container/TestContainer.java | 13 +++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index a84ef33671a..0a6eedf4740 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -146,6 +146,9 @@ Release 2.3.0 - UNRELEASED current attempt instead of the attempt passed as argument (Omkar Vinit Joshi via bikas) + YARN-1053. Diagnostic message from ContainerExitEvent is ignored in + ContainerImpl (Omkar Vinit Joshi via bikas) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java index 34c0cc66dd6..486f3ce00c5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java @@ -18,7 +18,6 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.container; -import java.io.IOException; import java.net.URISyntaxException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -687,6 +686,10 @@ public class ContainerImpl implements Container { public void transition(ContainerImpl container, ContainerEvent event) { ContainerExitEvent exitEvent = (ContainerExitEvent) event; container.exitCode = exitEvent.getExitCode(); + if (exitEvent.getDiagnosticInfo() != null) { + container.diagnostics.append(exitEvent.getDiagnosticInfo()) + .append('\n'); + } // TODO: Add containerWorkDir to the deletion service. // TODO: Add containerOuputDir to the deletion service. @@ -806,6 +809,10 @@ public class ContainerImpl implements Container { public void transition(ContainerImpl container, ContainerEvent event) { ContainerExitEvent exitEvent = (ContainerExitEvent) event; container.exitCode = exitEvent.getExitCode(); + if (exitEvent.getDiagnosticInfo() != null) { + container.diagnostics.append(exitEvent.getDiagnosticInfo()) + .append('\n'); + } // The process/process-grp is killed. Decrement reference counts and // cleanup resources diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java index ebc400abb00..addb28d83a2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java @@ -55,6 +55,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; @@ -844,9 +845,13 @@ public class TestContainer { } public void containerFailed(int exitCode) { + String diagnosticMsg = "Container completed with exit code " + exitCode; c.handle(new ContainerExitEvent(cId, ContainerEventType.CONTAINER_EXITED_WITH_FAILURE, exitCode, - "Container completed with exit code " + exitCode)); + diagnosticMsg)); + ContainerStatus containerStatus = c.cloneAndGetContainerStatus(); + assert containerStatus.getDiagnostics().contains(diagnosticMsg); + assert containerStatus.getExitStatus() == exitCode; drainDispatcherEvents(); } @@ -857,9 +862,13 @@ public class TestContainer { public void containerKilledOnRequest() { int exitCode = ExitCode.FORCE_KILLED.getExitCode(); + String diagnosticMsg = "Container completed with exit code " + exitCode; c.handle(new ContainerExitEvent(cId, ContainerEventType.CONTAINER_KILLED_ON_REQUEST, exitCode, - "Container completed with exit code " + exitCode)); + diagnosticMsg)); + ContainerStatus containerStatus = c.cloneAndGetContainerStatus(); + assert containerStatus.getDiagnostics().contains(diagnosticMsg); + assert containerStatus.getExitStatus() == exitCode; drainDispatcherEvents(); }