YARN-1661. Fixed DS ApplicationMaster to write the correct exit log. Contributed by Vinod Kumar Vavilapalli.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1565394 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-02-06 18:56:46 +00:00
parent c4b0ce0ace
commit 6182e7592d
4 changed files with 23 additions and 18 deletions

View File

@ -630,6 +630,9 @@ Release 2.3.0 - UNRELEASED
YARN-1628. Fixed the test failure in TestContainerManagerSecurity. (Vinod
Kumar Vavilapalli via zjshen)
YARN-1661. Fixed DS ApplicationMaster to write the correct exit log. (Vinod
Kumar Vavilapalli via zjshen)
Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES

View File

@ -232,7 +232,6 @@ public class ApplicationMaster {
private static final String shellArgsPath = "shellArgs";
private volatile boolean done;
private volatile boolean success;
private ByteBuffer allTokens;
@ -254,8 +253,8 @@ public static void main(String[] args) {
if (!doRun) {
System.exit(0);
}
result = appMaster.run();
appMaster.finish();
appMaster.run();
result = appMaster.finish();
} catch (Throwable t) {
LOG.fatal("Error running ApplicationMaster", t);
System.exit(1);
@ -480,7 +479,7 @@ private void printUsage(Options opts) {
* @throws IOException
*/
@SuppressWarnings({ "unchecked" })
public boolean run() throws YarnException, IOException {
public void run() throws YarnException, IOException {
LOG.info("Starting ApplicationMaster");
Credentials credentials =
@ -561,7 +560,6 @@ public boolean run() throws YarnException, IOException {
amRMClient.addContainerRequest(containerAsk);
}
numRequestedContainers.set(numTotalContainersToRequest);
return success;
}
@VisibleForTesting
@ -569,7 +567,8 @@ NMCallbackHandler createNMCallbackHandler() {
return new NMCallbackHandler(this);
}
protected void finish() {
@VisibleForTesting
protected boolean finish() {
// wait for completion.
while (!done
&& (numCompletedContainers.get() != numTotalContainers)) {
@ -600,7 +599,7 @@ protected void finish() {
FinalApplicationStatus appStatus;
String appMessage = null;
success = true;
boolean success = true;
if (numFailedContainers.get() == 0 &&
numCompletedContainers.get() == numTotalContainers) {
appStatus = FinalApplicationStatus.SUCCEEDED;
@ -621,6 +620,8 @@ protected void finish() {
}
amRMClient.stop();
return success;
}
private class RMCallbackHandler implements AMRMClientAsync.CallbackHandler {

View File

@ -18,13 +18,13 @@
package org.apache.hadoop.yarn.applications.distributedshell;
import java.nio.ByteBuffer;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.yarn.api.records.ContainerId;
import java.nio.ByteBuffer;
import java.util.Map;
public class ContainerLaunchFailAppMaster extends ApplicationMaster {
private static final Log LOG =
@ -66,8 +66,8 @@ public static void main(String[] args) {
if (!doRun) {
System.exit(0);
}
result = appMaster.run();
appMaster.finish();
appMaster.run();
result = appMaster.finish();
} catch (Throwable t) {
LOG.fatal("Error running ApplicationMaster", t);
System.exit(1);

View File

@ -29,8 +29,8 @@ public class TestDSFailedAppMaster extends ApplicationMaster {
private static final Log LOG = LogFactory.getLog(TestDSFailedAppMaster.class);
@Override
public boolean run() throws YarnException, IOException {
boolean res = super.run();
public void run() throws YarnException, IOException {
super.run();
// for the 2nd attempt.
if (appAttemptID.getAttemptId() == 2) {
@ -39,11 +39,12 @@ public boolean run() throws YarnException, IOException {
// numRequestedContainers should be set to 0.
if (numAllocatedContainers.get() != 1
|| numRequestedContainers.get() != 0) {
LOG.info("Application Master failed. exiting");
LOG.info("NumAllocatedContainers is " + numAllocatedContainers.get()
+ " and NumRequestedContainers is " + numAllocatedContainers.get()
+ ".Application Master failed. exiting");
System.exit(200);
}
}
return res;
}
public static void main(String[] args) {
@ -54,7 +55,7 @@ public static void main(String[] args) {
if (!doRun) {
System.exit(0);
}
result = appMaster.run();
appMaster.run();
if (appMaster.appAttemptID.getAttemptId() == 1) {
try {
// sleep some time, wait for the AM to launch a container.
@ -63,7 +64,7 @@ public static void main(String[] args) {
// fail the first am.
System.exit(100);
}
appMaster.finish();
result = appMaster.finish();
} catch (Throwable t) {
System.exit(1);
}