use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class LSFOutputParser method parseJobStatuses.
@Override
public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws GFacException {
logger.debug(rawOutput);
String[] info = rawOutput.split("\n");
// int lastStop = 0;
for (String jobID : statusMap.keySet()) {
String jobName = jobID.split(",")[1];
boolean found = false;
for (int i = 0; i < info.length; i++) {
if (info[i].contains(jobName.substring(0, 8))) {
// now starts processing this line
logger.info(info[i]);
String correctLine = info[i];
String[] columns = correctLine.split(" ");
List<String> columnList = new ArrayList<String>();
for (String s : columns) {
if (!"".equals(s)) {
columnList.add(s);
}
}
// lastStop = i + 1;
try {
statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(2))));
} catch (IndexOutOfBoundsException e) {
statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
}
found = true;
break;
}
}
if (!found)
logger.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
}
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class SlurmOutputParser method parseJobStatus.
public JobStatus parseJobStatus(String jobID, String rawOutput) throws GFacException {
log.info(rawOutput);
Pattern pattern = Pattern.compile(jobID + "(?=\\s+\\S+\\s+\\S+\\s+\\S+\\s+(?<" + STATUS + ">\\w+))");
Matcher matcher = pattern.matcher(rawOutput);
if (matcher.find()) {
return new JobStatus(JobUtil.getJobState(matcher.group(STATUS)));
}
return null;
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class UGEOutputParser method parseJobStatuses.
public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
log.debug(rawOutput);
String[] info = rawOutput.split("\n");
int lastStop = 0;
for (String jobID : statusMap.keySet()) {
for (int i = lastStop; i < info.length; i++) {
if (jobID.split(",")[0].contains(info[i].split(" ")[0]) && !"".equals(info[i].split(" ")[0])) {
// now starts processing this line
log.info(info[i]);
String correctLine = info[i];
String[] columns = correctLine.split(" ");
List<String> columnList = new ArrayList<String>();
for (String s : columns) {
if (!"".equals(s)) {
columnList.add(s);
}
}
lastStop = i + 1;
if ("E".equals(columnList.get(4))) {
// There is another status with the same letter E other than error status
// to avoid that we make a small tweek to the job status
columnList.set(4, "Er");
}
statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(4))));
break;
}
}
}
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class AuroraJobSubmissionTask method execute.
@Override
public TaskStatus execute(TaskContext taskContext) {
// set to completed.
TaskStatus taskStatus = new TaskStatus(TaskState.COMPLETED);
ProcessContext processContext = taskContext.getParentProcessContext();
JobModel jobModel = processContext.getJobModel();
jobModel.setTaskId(taskContext.getTaskId());
String jobIdAndName = "A" + GFacUtils.generateJobName();
jobModel.setJobName(jobIdAndName);
JobStatus jobStatus = new JobStatus();
jobStatus.setJobState(JobState.SUBMITTED);
try {
JobKeyBean jobKey = new JobKeyBean(AuroraUtils.ENVIRONMENT, AuroraUtils.ROLE, jobIdAndName);
IdentityBean owner = new IdentityBean(AuroraUtils.ROLE);
GroovyMap groovyMap = GFacUtils.createGroovyMap(processContext, taskContext);
groovyMap.add(Script.JOB_SUBMITTER_COMMAND, "sh");
String templateFileName = GFacUtils.getTemplateFileName(ResourceJobManagerType.CLOUD);
String script = GFacUtils.generateScript(groovyMap, templateFileName);
Set<ProcessBean> processes = new LinkedHashSet<>();
ProcessBean process_1 = new ProcessBean("main_process", script, false);
processes.add(process_1);
groovyMap.getStringValue(Script.STANDARD_OUT_FILE).ifPresent(stdout -> {
ProcessBean stdOutProcess = new ProcessBean("stdout_copy_process", "cp .logs/main_process/0/stdout " + stdout, false);
processes.add(stdOutProcess);
});
groovyMap.getStringValue(Script.STANDARD_ERROR_FILE).ifPresent(stderr -> {
ProcessBean stdErrProcess = new ProcessBean("stderr_copy_process", "cp .logs/main_process/0/stderr " + stderr, false);
processes.add(stdErrProcess);
});
ResourceBean resources = new ResourceBean(1.5, 512, 512);
TaskConfigBean taskConfig = new TaskConfigBean("Airavata-Aurora-" + jobIdAndName, processes, resources);
JobConfigBean jobConfig = new JobConfigBean(jobKey, owner, taskConfig, AuroraUtils.CLUSTER);
String executorConfigJson = AuroraThriftClientUtil.getExecutorConfigJson(jobConfig);
log.info("Executor Config for Job {} , {}", jobIdAndName, executorConfigJson);
AuroraThriftClient client = AuroraThriftClient.getAuroraThriftClient();
ResponseBean response = client.createJob(jobConfig);
log.info("Response for job {}, {}", jobIdAndName, response);
jobModel.setJobDescription(resources.toString());
jobModel.setJobId(jobIdAndName);
jobStatus.setReason("Successfully Submitted");
jobModel.setJobStatuses(Arrays.asList(jobStatus));
jobStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
taskContext.getParentProcessContext().setJobModel(jobModel);
GFacUtils.saveJobModel(processContext, jobModel);
GFacUtils.saveJobStatus(processContext, jobModel);
taskStatus.setReason("Successfully submitted job to Aurora");
} catch (Throwable e) {
String msg = "Error occurred while submitting Aurora job";
log.error(msg, e);
taskStatus.setState(TaskState.FAILED);
taskStatus.setReason(msg);
taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
ErrorModel errorModel = new ErrorModel();
errorModel.setActualErrorMessage(e.getMessage());
errorModel.setUserFriendlyMessage(msg);
taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
}
taskContext.setTaskStatus(taskStatus);
try {
GFacUtils.saveAndPublishTaskStatus(taskContext);
} catch (GFacException e) {
log.error("Error while saving task status", e);
}
return taskStatus;
}
use of org.apache.airavata.model.status.JobStatus in project airavata by apache.
the class AuroraJobSubmissionTask method cancel.
@Override
public JobStatus cancel(TaskContext taskcontext) throws TaskException {
JobStatus jobStatus = new JobStatus();
jobStatus.setJobState(JobState.ACTIVE);
return jobStatus;
}
Aggregations