diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java index 4f557922db..924af58f82 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java @@ -39,6 +39,8 @@ import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.TIPStatus; @@ -106,6 +108,7 @@ public int run(String[] argv) throws Exception { int fromEvent = 0; int nEvents = 0; int jpvalue = 0; + String configOutFile = null; boolean getStatus = false; boolean getCounter = false; boolean killJob = false; @@ -121,6 +124,7 @@ public int run(String[] argv) throws Exception { boolean failTask = false; boolean setJobPriority = false; boolean logs = false; + boolean downloadConfig = false; if ("-submit".equals(cmd)) { if (argv.length != 2) { @@ -295,6 +299,14 @@ public int run(String[] argv) throws Exception { displayUsage(cmd); return exitCode; } + } else if ("-config".equals(cmd)) { + downloadConfig = true; + if (argv.length != 3) { + displayUsage(cmd); + return exitCode; + } + jobid = argv[1]; + configOutFile = argv[2]; } else { displayUsage(cmd); return exitCode; @@ -473,6 +485,22 @@ public int run(String[] argv) throws Exception { System.out.println(e.getMessage()); } } + } else if (downloadConfig) { + Job job = getJob(JobID.forName(jobid)); + if (job == null) { + System.out.println("Could not find job " + jobid); + } else { + String jobFile = job.getJobFile(); + if (jobFile == null || jobFile.isEmpty()) { + System.out.println("Config file for job " + jobFile + + " could not be found."); + } else { + Path configPath = new Path(jobFile); + FileSystem fs = FileSystem.get(getConf()); + fs.copyToLocalFile(configPath, new Path(configOutFile)); + exitCode = 0; + } + } } } catch (RemoteException re) { IOException unwrappedException = re.unwrapRemoteException(); @@ -549,7 +577,9 @@ private void displayUsage(String cmd) { } else if ("-logs".equals(cmd)) { System.err.println(prefix + "[" + cmd + " ]. " + - " is optional to get task attempt logs."); + " is optional to get task attempt logs."); + } else if ("-config".equals(cmd)) { + System.err.println(prefix + "[" + cmd + " ]"); } else { System.err.printf(prefix + " %n"); System.err.printf("\t[-submit ]%n"); @@ -571,7 +601,8 @@ private void displayUsage(String cmd) { "Valid values for are " + taskStates); System.err.printf("\t[-kill-task ]%n"); System.err.printf("\t[-fail-task ]%n"); - System.err.printf("\t[-logs ]%n%n"); + System.err.printf("\t[-logs ]%n"); + System.err.printf("\t[-config %n%n"); ToolRunner.printGenericCommandUsage(System.out); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/site/markdown/MapredCommands.md b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/site/markdown/MapredCommands.md index 64589d9cbd..f312d31c5f 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/site/markdown/MapredCommands.md +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/site/markdown/MapredCommands.md @@ -81,7 +81,7 @@ Copy file or directories recursively. More information can be found at Command to interact with Map Reduce Jobs. -Usage: `mapred job | [GENERIC_OPTIONS] | [-submit ] | [-status ] | [-counter ] | [-kill ] | [-events <#-of-events>] | [-history [all] [-outfile ] [-format ]] | [-list [all]] | [-kill-task ] | [-fail-task ] | [-set-priority ] | [-list-active-trackers] | [-list-blacklisted-trackers] | [-list-attempt-ids ] [-logs ]` +Usage: `mapred job | [GENERIC_OPTIONS] | [-submit ] | [-status ] | [-counter ] | [-kill ] | [-events <#-of-events>] | [-history [all] [-outfile ] [-format ]] | [-list [all]] | [-kill-task ] | [-fail-task ] | [-set-priority ] | [-list-active-trackers] | [-list-blacklisted-trackers] | [-list-attempt-ids ] [-logs ] [-config ]` | COMMAND\_OPTION | Description | |:---- |:---- | @@ -99,6 +99,7 @@ Usage: `mapred job | [GENERIC_OPTIONS] | [-submit ] | [-status ", line); + } + /** * print job events list */