}
}
public List<ExecJob> execute(PhysicalPlan plan,
String jobName) throws ExecException {
MapReduceLauncher launcher = new MapReduceLauncher();
List<ExecJob> jobs = new ArrayList<ExecJob>();
try {
PigStats stats = launcher.launchPig(plan, jobName, pigContext);
for (FileSpec spec: launcher.getSucceededFiles()) {
jobs.add(new HJob(ExecJob.JOB_STATUS.COMPLETED, pigContext, spec, stats));
}
for (FileSpec spec: launcher.getFailedFiles()) {
HJob j = new HJob(ExecJob.JOB_STATUS.FAILED, pigContext, spec, stats);
j.setException(launcher.getError(spec));
jobs.add(j);
}
return jobs;
} catch (Exception e) {
// There are a lot of exceptions thrown by the launcher. If this
// is an ExecException, just let it through. Else wrap it.
if (e instanceof ExecException) throw (ExecException)e;
else {
int errCode = 2043;
String msg = "Unexpected error during execution.";
throw new ExecException(msg, errCode, PigException.BUG, e);
}
} finally {
launcher.reset();
}
}