jobConf.getPartitionerClass(), jobConf);
int num_reduces = part.getNumPartitions();
JobClient client = new JobClient(jobConf);
ClusterStatus cluster = client.getClusterStatus();
int num_maps = cluster.getTaskTrackers()
* jobConf.getInt("test.sort.maps_per_host", 10);
List <String>otherArgs = new ArrayList<String>();
for (int i = 0; i < args.length; ++i) {
try {
if ("-m".equals(args[i])) {
num_maps = Integer.parseInt(args[++i]);
} else {
otherArgs.add(args[i]);
}
} catch (NumberFormatException except) {
System.out.println("ERROR: Integer expected instead of "
+ args[i]);
printUsage();
} catch (ArrayIndexOutOfBoundsException except) {
System.out.println("ERROR: Required parameter missing from "
+ args[i - 1]);
printUsage(); // exits
}
}
jobConf.setNumMapTasks(num_maps);
jobConf.setNumReduceTasks(num_reduces);
// Make sure there are exactly 2 parameters left.
if (otherArgs.size() != 2) {
System.out.println("ERROR: Wrong number of parameters: "
+ otherArgs.size() + " instead of 2.");
printUsage();
}
jobConf.setInputPath(new Path((String) otherArgs.get(0)));
jobConf.setOutputPath(new Path((String) otherArgs.get(1)));
// Uncomment to run locally in a single process
//job_conf.set("mapred.job.tracker", "local");
System.out.println("Running on " + cluster.getTaskTrackers()
+ " nodes to sort from " + jobConf.getInputPaths()[0]
+ " into " + jobConf.getOutputPath() + " with " + num_reduces
+ " reduces.");
Date startTime = new Date();
System.out.println("Job started: " + startTime);