Map<String, PhysicalOperator> leafMap = new HashMap<String, PhysicalOperator>();
for (PhysicalOperator physOp : plan.getLeaves()) {
log.info(physOp);
if (physOp instanceof POStore) {
FileSpec spec = ((POStore) physOp).getSFile();
if (spec != null)
leafMap.put(spec.toString(), physOp);
}
}
try {
PigStats stats = launcher.launchPig(plan, jobName, pigContext);
for (POStore store: launcher.getSucceededFiles()) {
FileSpec spec = store.getSFile();
String alias = leafMap.containsKey(spec.toString()) ? leafMap.get(spec.toString()).getAlias() : null;
jobs.add(new HJob(ExecJob.JOB_STATUS.COMPLETED, pigContext, store, alias, stats));
}
for (POStore store: launcher.getFailedFiles()) {
FileSpec spec = store.getSFile();
String alias = leafMap.containsKey(spec.toString()) ? leafMap.get(spec.toString()).getAlias() : null;
HJob j = new HJob(ExecJob.JOB_STATUS.FAILED, pigContext, store, alias, stats);
j.setException(launcher.getError(spec));
jobs.add(j);
}