use of org.apache.airavata.model.status.TaskState in project airavata by apache.
the class GFacEngineImpl method recoverProcess.
@Override
public void recoverProcess(ProcessContext processContext) throws GFacException {
processContext.setRecovery(true);
String taskDag = processContext.getProcessModel().getTaskDag();
List<String> taskExecutionOrder = GFacUtils.parseTaskDag(taskDag);
processContext.setTaskExecutionOrder(taskExecutionOrder);
Map<String, TaskModel> taskMap = processContext.getTaskMap();
String recoverTaskId = null;
String previousTaskId = null;
TaskModel taskModel = null;
for (String taskId : taskExecutionOrder) {
taskModel = taskMap.get(taskId);
TaskState state = taskModel.getTaskStatuses().get(0).getState();
if (state == TaskState.CREATED || state == TaskState.EXECUTING) {
recoverTaskId = taskId;
break;
}
previousTaskId = taskId;
}
final String rTaskId = recoverTaskId;
final String pTaskId = previousTaskId;
if (recoverTaskId != null) {
if (processContext.isRecoveryWithCancel()) {
cancelJobSubmission(processContext, rTaskId, pTaskId);
}
continueProcess(processContext, recoverTaskId);
} else {
log.error("expId: {}, processId: {}, couldn't find recovery task, mark this as complete ", processContext.getExperimentId(), processContext.getProcessId());
processContext.setComplete(true);
}
}
Aggregations