Search in sources :

Example 1 with TaskState

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);
    }
}
Also used : TaskState(org.apache.airavata.model.status.TaskState) EnvironmentSetupTaskModel(org.apache.airavata.model.task.EnvironmentSetupTaskModel) JobSubmissionTaskModel(org.apache.airavata.model.task.JobSubmissionTaskModel) MonitorTaskModel(org.apache.airavata.model.task.MonitorTaskModel) DataStagingTaskModel(org.apache.airavata.model.task.DataStagingTaskModel) TaskModel(org.apache.airavata.model.task.TaskModel)

Aggregations

TaskState (org.apache.airavata.model.status.TaskState)1 DataStagingTaskModel (org.apache.airavata.model.task.DataStagingTaskModel)1 EnvironmentSetupTaskModel (org.apache.airavata.model.task.EnvironmentSetupTaskModel)1 JobSubmissionTaskModel (org.apache.airavata.model.task.JobSubmissionTaskModel)1 MonitorTaskModel (org.apache.airavata.model.task.MonitorTaskModel)1 TaskModel (org.apache.airavata.model.task.TaskModel)1