diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java index 9c49bdc..bbaf0b2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java @@ -308,6 +308,9 @@ public boolean init(String[] args) throws ParseException, IOException { Options opts = new Options(); opts.addOption("app_attempt_id", true, "App Attempt ID. Not to be used unless for testing purposes"); + opts.addOption("shell_command", true, + "Shell command to be executed if shell command file does not " + + "exists, this is usually because AM started alone without client"); opts.addOption("shell_script", true, "Location of the shell script to be executed"); opts.addOption("shell_env", true, @@ -388,10 +391,15 @@ public boolean init(String[] args) throws ParseException, IOException { + ", attemptId=" + appAttemptID.getAttemptId()); if (!fileExist(shellCommandPath)) { - throw new IllegalArgumentException( - "No shell command specified to be executed by application master"); + if (cliParser.hasOption("shell_command")) { + shellCommand = cliParser.getOptionValue("shell_command"); + } else { + throw new IllegalArgumentException( + "No shell command specified to be executed by application master"); + } + } else { + shellCommand = readContent(shellCommandPath); } - shellCommand = readContent(shellCommandPath); if (fileExist(shellArgsPath)) { shellArgs = readContent(shellArgsPath);