From 7da5847cf10bc61f2131d578f16ee37cb32c4639 Mon Sep 17 00:00:00 2001 From: Harsh J Date: Thu, 21 Apr 2016 17:33:22 +0530 Subject: [PATCH] MAPREDUCE-2398. MRBench: setting the baseDir parameter has no effect. Contributed by Michael Noll and Wilfred Spiegelenburg. --- .../java/org/apache/hadoop/mapred/MRBench.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/MRBench.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/MRBench.java index 20d27fbe51..079fad7497 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/MRBench.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/MRBench.java @@ -41,10 +41,13 @@ public class MRBench extends Configured implements Tool{ private static final Log LOG = LogFactory.getLog(MRBench.class); + private static final String DEFAULT_INPUT_SUB = "mr_input"; + private static final String DEFAULT_OUTPUT_SUB = "mr_output"; + private static Path BASE_DIR = new Path(System.getProperty("test.build.data","/benchmarks/MRBench")); - private static Path INPUT_DIR = new Path(BASE_DIR, "mr_input"); - private static Path OUTPUT_DIR = new Path(BASE_DIR, "mr_output"); + private static Path INPUT_DIR = new Path(BASE_DIR, DEFAULT_INPUT_SUB); + private static Path OUTPUT_DIR = new Path(BASE_DIR, DEFAULT_OUTPUT_SUB); public static enum Order {RANDOM, ASCENDING, DESCENDING}; @@ -243,6 +246,8 @@ public int run(String[] args) throws Exception { numRuns = Integer.parseInt(args[++i]); } else if (args[i].equals("-baseDir")) { BASE_DIR = new Path(args[++i]); + INPUT_DIR = new Path(BASE_DIR, DEFAULT_INPUT_SUB); + OUTPUT_DIR = new Path(BASE_DIR, DEFAULT_OUTPUT_SUB); } else if (args[i].equals("-maps")) { numMaps = Integer.parseInt(args[++i]); } else if (args[i].equals("-reduces")) { @@ -283,14 +288,15 @@ public int run(String[] args) throws Exception { Path inputFile = new Path(INPUT_DIR, "input_" + (new Random()).nextInt() + ".txt"); generateTextFile(fs, inputFile, inputLines, inputSortOrder); - // setup test output directory - fs.mkdirs(BASE_DIR); ArrayList execTimes = new ArrayList(); try { execTimes = runJobInSequence(jobConf, numRuns); } finally { - // delete output -- should we really do this? - fs.delete(BASE_DIR, true); + // delete all generated data -- should we really do this? + // we don't know how much of the path was created for the run but this + // cleans up as much as we can + fs.delete(OUTPUT_DIR, true); + fs.delete(INPUT_DIR, true); } if (verbose) {