try {
Element actionXml = XmlUtils.parseXml(action.getConf());
FileSystem actionFs = getActionFileSystem(context, actionXml);
JobConf jobConf = createBaseHadoopConf(context, actionXml);
jobClient = createJobClient(context, jobConf);
RunningJob runningJob = jobClient.getJob(JobID.forName(action.getExternalId()));
if (runningJob == null) {
context.setExternalStatus(FAILED);
context.setExecutionData(FAILED, null);
throw new ActionExecutorException(ActionExecutorException.ErrorType.FAILED, "JA017",
"Unknown hadoop job [{0}] associated with action [{1}]. Failing this action!", action
.getExternalId(), action.getId());
}
if (runningJob.isComplete()) {
Path actionDir = context.getActionDir();
String user = context.getWorkflow().getUser();
String group = context.getWorkflow().getGroup();
if (LauncherMapper.hasIdSwap(runningJob, user, group, actionDir)) {
String launcherId = action.getExternalId();
Path idSwapPath = LauncherMapper.getIdSwapPath(context.getActionDir());
InputStream is = actionFs.open(idSwapPath);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
Properties props = PropertiesUtils.readProperties(reader, maxActionOutputLen);
reader.close();
String newId = props.getProperty("id");
runningJob = jobClient.getJob(JobID.forName(newId));
if (runningJob == null) {
context.setExternalStatus(FAILED);
throw new ActionExecutorException(ActionExecutorException.ErrorType.FAILED, "JA017",
"Unknown hadoop job [{0}] associated with action [{1}]. Failing this action!", newId,
action.getId());
}
context.setStartData(newId, action.getTrackerUri(), runningJob.getTrackingURL());
XLog.getLog(getClass()).info(XLog.STD, "External ID swap, old ID [{0}] new ID [{1}]", launcherId,
newId);
}
if (runningJob.isComplete()) {
XLog.getLog(getClass()).info(XLog.STD, "action completed, external ID [{0}]",
action.getExternalId());
if (runningJob.isSuccessful() && LauncherMapper.isMainSuccessful(runningJob)) {
getActionData(actionFs, runningJob, action, context);
XLog.getLog(getClass()).info(XLog.STD, "action produced output");
}
else {
XLog log = XLog.getLog(getClass());