MAPREDUCE-4678. Running the Pentomino example with defaults throws java.lang.NegativeArraySizeException. Contributed by Chris McConnell. (harsh)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1433412 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Harsh J 2013-01-15 13:47:53 +00:00
parent 6ca7bde28d
commit 82f03491a6
2 changed files with 23 additions and 6 deletions

View File

@ -539,6 +539,9 @@ Release 0.23.6 - UNRELEASED
MAPREDUCE-4934. Maven RAT plugin is not checking all source files (tgraves)
MAPREDUCE-4678. Running the Pentomino example with defaults throws
java.lang.NegativeArraySizeException (Chris McConnell via harsh)
Release 0.23.5 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -167,16 +167,30 @@ public class DistributedPentomino extends Configured implements Tool {
}
public int run(String[] args) throws Exception {
Configuration conf = getConf();
if (args.length == 0) {
System.out.println("pentomino <output>");
System.out.println("Usage: pentomino <output> [-depth #] [-height #] [-width #]");
ToolRunner.printGenericCommandUsage(System.out);
return 2;
}
Configuration conf = getConf();
int width = conf.getInt(Pentomino.WIDTH, PENT_WIDTH);
int height = conf.getInt(Pentomino.HEIGHT, PENT_HEIGHT);
int depth = conf.getInt(Pentomino.DEPTH, PENT_DEPTH);
// check for passed parameters, otherwise use defaults
int width = PENT_WIDTH;
int height = PENT_HEIGHT;
int depth = PENT_DEPTH;
for (int i = 0; i < args.length; i++) {
if (args[i].equalsIgnoreCase("-depth")) {
depth = Integer.parseInt(args[i++].trim());
} else if (args[i].equalsIgnoreCase("-height")) {
height = Integer.parseInt(args[i++].trim());
} else if (args[i].equalsIgnoreCase("-width") ) {
width = Integer.parseInt(args[i++].trim());
}
}
// now set the values within conf for M/R tasks to read, this
// will ensure values are set preventing MAPREDUCE-4678
conf.setInt(Pentomino.WIDTH, width);
conf.setInt(Pentomino.HEIGHT, height);
conf.setInt(Pentomino.DEPTH, depth);
Class<? extends Pentomino> pentClass = conf.getClass(Pentomino.CLASS,
OneSidedPentomino.class, Pentomino.class);
int numMaps = conf.getInt(MRJobConfig.NUM_MAPS, DEFAULT_MAPS);