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());
String errorReason;
Path actionError = LauncherMapper.getErrorPath(context.getActionDir());
if (actionFs.exists(actionError)) {
InputStream is = actionFs.open(actionError);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
Properties props = PropertiesUtils.readProperties(reader, -1);
reader.close();
String errorCode = props.getProperty("error.code");
if (errorCode.equals("0")) {
errorCode = "JA018";
}
if (errorCode.equals("-1")) {
errorCode = "JA019";
}
errorReason = props.getProperty("error.reason");
log.warn("Launcher ERROR, reason: {0}", errorReason);
String exMsg = props.getProperty("exception.message");
String errorInfo = (exMsg != null) ? exMsg : errorReason;
context.setErrorInfo(errorCode, errorInfo);
String exStackTrace = props.getProperty("exception.stacktrace");
if (exMsg != null) {
log.warn("Launcher exception: {0}{E}{1}", exMsg, exStackTrace);
}
}
else {
errorReason = XLog.format("LauncherMapper died, check Hadoop log for job [{0}:{1}]", action
.getTrackerUri(), action.getExternalId());
log.warn(errorReason);
}
context.setExecutionData(FAILED_KILLED, null);
}
}
else {
context.setExternalStatus(RUNNING);
XLog.getLog(getClass()).info(XLog.STD, "checking action, external ID [{0}] status [{1}]",
action.getExternalId(), action.getExternalStatus());
}
}
else {
context.setExternalStatus(RUNNING);
XLog.getLog(getClass()).info(XLog.STD, "checking action, external ID [{0}] status [{1}]",
action.getExternalId(), action.getExternalStatus());
}
}
catch (Exception ex) {
XLog.getLog(getClass()).warn("Exception in check(). Message[{0}]", ex.getMessage(), ex);
exception = true;
throw convertException(ex);
}
finally {
if (jobClient != null) {
try {
jobClient.close();
}
catch (Exception e) {
if (exception) {
log.error("JobClient error: ", e);
}
else {
throw convertException(e);
}
}