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

svn merge --ignore-ancestry -c 1565394 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1565397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-02-06 18:59:21 +00:00
parent cf173a332b
commit e05f49778b
4 changed files with 23 additions and 18 deletions

View File

@ -604,6 +604,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 class ApplicationMaster {
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 @@ public class ApplicationMaster {
* @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 class ApplicationMaster {
amRMClient.addContainerRequest(containerAsk);
}
numRequestedContainers.set(numTotalContainersToRequest);
return success;
}
@VisibleForTesting
@ -569,7 +567,8 @@ public class ApplicationMaster {
return new NMCallbackHandler(this);
}
protected void finish() {
@VisibleForTesting
protected boolean finish() {
// wait for completion.
while (!done
&& (numCompletedContainers.get() != numTotalContainers)) {
@ -600,7 +599,7 @@ public class ApplicationMaster {
FinalApplicationStatus appStatus;
String appMessage = null;
success = true;
boolean success = true;
if (numFailedContainers.get() == 0 &&
numCompletedContainers.get() == numTotalContainers) {
appStatus = FinalApplicationStatus.SUCCEEDED;
@ -621,6 +620,8 @@ public class ApplicationMaster {
}
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 class ContainerLaunchFailAppMaster extends ApplicationMaster {
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 class TestDSFailedAppMaster extends ApplicationMaster {
// 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 class TestDSFailedAppMaster extends ApplicationMaster {
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 class TestDSFailedAppMaster extends ApplicationMaster {
// fail the first am.
System.exit(100);
}
appMaster.finish();
result = appMaster.finish();
} catch (Throwable t) {
System.exit(1);
}