List of usage examples for org.apache.hadoop.mapred.jobcontrol JobControl addJobs
public void addJobs(Collection<Job> jobs)
From source file:com.ebay.erl.mobius.core.MobiusJobRunner.java
License:Apache License
/** * Submit the <code>tool</code> with the specified <code>conf</code> and <code>args</code>. * <p>/*from ww w. j ava 2s . c om*/ * * <code>tool</code> can be {@link MobiusJob} or any instance of {@link org.apache.hadoop.util.Tool}. * If <code>tool</code> is an instance of {@link MobiusJob}, it will be submitted using * {@link JobControl}. If it's not an instance of {@link MobiusJob}, then it will be submitted * using <code>ToolRunner.run(conf, tool, args)</code> directly. * */ public static int run(Configuration conf, Tool tool, String[] args) throws Exception { if (tool instanceof MobiusJob) { MobiusJob mobiusJob = (MobiusJob) tool; int exit; try { exit = ToolRunner.run(conf, tool, args); } catch (Throwable t) { t.printStackTrace(); exit = 1; } if (exit == 0) { // setup correctly JobControl control = new JobControl("Mobius Job [" + tool.getClass().getCanonicalName() + "]"); Collection<Job> allJobs = mobiusJob.jobTopology.values(); control.addJobs(allJobs); LOGGER.info(allJobs.size() + " Hadoop job(s) to run."); Thread t = new Thread(control); t.start(); StatusCheckingThread statusChecking = new StatusCheckingThread(tool, allJobs, control); statusChecking.start(); statusChecking.join(); LOGGER.info(" All job(s) done."); statusChecking.complete(); int exitCode = control.getFailedJobs().size() == 0 ? 0 : 1; mobiusJob.deleteTempFiles(); return exitCode; } else { mobiusJob.deleteTempFiles(); return exit; } } else { return ToolRunner.run(conf, tool, args); } }