if (numTasks == 0) {
numTasks = numSplits;
}
HamaConfiguration conf = new HamaConfiguration(job.getConfiguration());
conf.setInt(Constants.RUNTIME_DESIRED_PEERS_COUNT, numTasks);
if (job.getConfiguration().get(Constants.RUNTIME_PARTITIONING_DIR) != null) {
conf.set(Constants.RUNTIME_PARTITIONING_DIR, job.getConfiguration()
.get(Constants.RUNTIME_PARTITIONING_DIR));
}
if (job.getConfiguration().get(Constants.RUNTIME_PARTITIONING_CLASS) != null) {
conf.set(Constants.RUNTIME_PARTITIONING_CLASS,
job.get(Constants.RUNTIME_PARTITIONING_CLASS));
}
BSPJob partitioningJob = new BSPJob(conf);
LOG.debug("partitioningJob input: " + partitioningJob.get(Constants.JOB_INPUT_DIR));
partitioningJob.setInputFormat(job.getInputFormat().getClass());
partitioningJob.setInputKeyClass(job.getInputKeyClass());
partitioningJob.setInputValueClass(job.getInputValueClass());
partitioningJob.setOutputFormat(NullOutputFormat.class);
partitioningJob.setOutputKeyClass(NullWritable.class);
partitioningJob.setOutputValueClass(NullWritable.class);
partitioningJob.setBspClass(PartitioningRunner.class);
partitioningJob.set("bsp.partitioning.runner.job", "true");
partitioningJob.getConfiguration().setBoolean(
Constants.ENABLE_RUNTIME_PARTITIONING, false);
partitioningJob.setOutputPath(partitionDir);
boolean isPartitioned = false;
try {
isPartitioned = partitioningJob.waitForCompletion(true);
} catch (InterruptedException e) {
LOG.error("Interrupted partitioning run-time.", e);
} catch (ClassNotFoundException e) {
LOG.error("Class not found error partitioning run-time.", e);
}
if (isPartitioned) {
if (job.getConfiguration().get(Constants.RUNTIME_PARTITIONING_DIR) != null) {
job.setInputPath(new Path(conf
.get(Constants.RUNTIME_PARTITIONING_DIR)));
} else {
job.setInputPath(partitionDir);
}
job.setBoolean("input.has.partitioned", true);