YARN-1395. Merging change r1540839 from trunk to branch-2.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1540842 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2013-11-11 20:52:22 +00:00
parent 97dc10bee5
commit 01808fa1b5
3 changed files with 38 additions and 11 deletions

View File

@ -100,6 +100,9 @@ Release 2.3.0 - UNRELEASED
YARN-1374. Changed ResourceManager to start the preemption policy monitors YARN-1374. Changed ResourceManager to start the preemption policy monitors
as active services. (Karthik Kambatla via vinodkv) as active services. (Karthik Kambatla via vinodkv)
YARN-1395. Distributed shell application master launched with debug flag can
hang waiting for external ls process. (cnauroth)
Release 2.2.1 - UNRELEASED Release 2.2.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.applications.distributedshell;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.StringReader;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -46,10 +47,12 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.Credentials;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.yarn.api.ApplicationConstants; import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.api.ApplicationConstants.Environment; import org.apache.hadoop.yarn.api.ApplicationConstants.Environment;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
@ -262,25 +265,20 @@ public class ApplicationMaster {
+ env.getValue()); + env.getValue());
} }
String cmd = "ls -al"; BufferedReader buf = null;
Runtime run = Runtime.getRuntime();
Process pr = null;
try { try {
pr = run.exec(cmd); String lines = Shell.WINDOWS ? Shell.execCommand("cmd", "/c", "dir") :
pr.waitFor(); Shell.execCommand("ls", "-al");
buf = new BufferedReader(new StringReader(lines));
BufferedReader buf = new BufferedReader(new InputStreamReader(
pr.getInputStream()));
String line = ""; String line = "";
while ((line = buf.readLine()) != null) { while ((line = buf.readLine()) != null) {
LOG.info("System CWD content: " + line); LOG.info("System CWD content: " + line);
System.out.println("System CWD content: " + line); System.out.println("System CWD content: " + line);
} }
buf.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InterruptedException e) { } finally {
e.printStackTrace(); IOUtils.cleanup(LOG, buf);
} }
} }

View File

@ -306,5 +306,31 @@ public class TestDistributedShell {
} }
@Test(timeout=90000)
public void testDebugFlag() throws Exception {
String[] args = {
"--jar",
APPMASTER_JAR,
"--num_containers",
"2",
"--shell_command",
Shell.WINDOWS ? "dir" : "ls",
"--master_memory",
"512",
"--master_vcores",
"2",
"--container_memory",
"128",
"--container_vcores",
"1",
"--debug"
};
LOG.info("Initializing DS Client");
Client client = new Client(new Configuration(yarnCluster.getConfig()));
Assert.assertTrue(client.init(args));
LOG.info("Running DS Client");
Assert.assertTrue(client.run());
}
} }