Search in sources :

Example 6 with TaskModel

use of org.apache.airavata.model.task.TaskModel in project airavata by apache.

the class ExperimentRegistry method updateProcess.

public void updateProcess(ProcessModel process, String processId) throws RegistryException {
    try {
        ExperimentResource experimentResource = new ExperimentResource();
        ProcessResource processResource = experimentResource.getProcess(processId);
        processResource.setProcessId(process.getProcessId());
        processResource.setExperimentId(process.getExperimentId());
        processResource.setCreationTime(AiravataUtils.getTime(process.getCreationTime()));
        processResource.setLastUpdateTime(AiravataUtils.getTime(process.getLastUpdateTime()));
        processResource.setProcessDetail(process.getProcessDetail());
        processResource.setApplicationInterfaceId(process.getApplicationInterfaceId());
        processResource.setTaskDag(process.getTaskDag());
        processResource.setGatewayExecutionId(process.getGatewayExecutionId());
        processResource.setComputeResourceId(process.getComputeResourceId());
        processResource.setApplicationDeploymentId(process.getApplicationDeploymentId());
        processResource.setStorageResourceId(process.getStorageResourceId());
        processResource.setUserDn(process.getUserDn());
        processResource.setGenerateCert(process.isGenerateCert());
        processResource.setExperimentDataDir(process.getExperimentDataDir());
        processResource.setUserName(process.getUserName());
        processResource.setUseUserCRPref(process.isUseUserCRPref());
        if (process.isEnableEmailNotification()) {
            processResource.setEnableEmailNotification(true);
            if (process.getEmailAddresses() != null) {
                processResource.setEmailAddresses(StringUtils.join(process.getEmailAddresses(), ","));
            }
        } else {
            processResource.setEnableEmailNotification(false);
        }
        processResource.save();
        if (process.getProcessResourceSchedule() != null) {
            updateProcessResourceSchedule(process.getProcessResourceSchedule(), process.getProcessId());
        }
        if (process.getProcessInputs() != null && process.getProcessInputs().size() > 0) {
            updateProcessInputs(process.getProcessInputs(), process.getProcessId());
        }
        if (process.getProcessOutputs() != null && process.getProcessOutputs().size() > 0) {
            updateProcessOutputs(process.getProcessOutputs(), process.getProcessId());
        }
        if (process.getProcessStatuses() != null) {
            updateProcessStatus(process.getProcessStatuses().get(0), process.getProcessId());
        }
        if (process.getProcessErrors() != null) {
            updateProcessError(process.getProcessErrors().get(0), process.getProcessId());
        }
        if (process.getTasks() != null && process.getTasks().size() > 0) {
            for (TaskModel task : process.getTasks()) {
                updateTask(task, task.getTaskId());
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating process...", e);
        throw new RegistryException(e);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) TaskModel(org.apache.airavata.model.task.TaskModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 7 with TaskModel

use of org.apache.airavata.model.task.TaskModel in project airavata by apache.

the class ThriftDataModelConversion method getTaskModel.

public static TaskModel getTaskModel(TaskResource taskResource) throws RegistryException {
    TaskModel model = new TaskModel();
    model.setTaskId(taskResource.getTaskId());
    model.setTaskType(TaskTypes.valueOf(taskResource.getTaskType()));
    model.setParentProcessId(taskResource.getParentProcessId());
    model.setCreationTime(taskResource.getCreationTime().getTime());
    model.setLastUpdateTime(taskResource.getLastUpdateTime().getTime());
    model.setTaskDetail(taskResource.getTaskDetail());
    model.setSubTaskModel(taskResource.getSubTaskModel());
    TaskStatus taskStatus = getTaskStatus(taskResource.getTaskStatus());
    if (taskStatus != null) {
        List<TaskStatus> taskStatuses = new ArrayList<>();
        taskStatuses.add(taskStatus);
        model.setTaskStatuses(taskStatuses);
    }
    ErrorModel errorModel = getErrorModel(taskResource.getTaskError());
    if (errorModel != null) {
        List<ErrorModel> errors = new ArrayList<>();
        errors.add(errorModel);
        model.setTaskErrors(errors);
    }
    return model;
}
Also used : ArrayList(java.util.ArrayList) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskModel(org.apache.airavata.model.task.TaskModel)

Example 8 with TaskModel

use of org.apache.airavata.model.task.TaskModel in project airavata by apache.

the class RegistryServerHandler method getJobDetails.

/**
 * Get Job Details for all the jobs within an Experiment.
 * This method to be used when need to get the job details for one or many jobs of an Experiment.
 *
 * @param airavataExperimentId@return list of JobDetails
 *                                    Job details.
 */
@Override
public List<JobModel> getJobDetails(String airavataExperimentId) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
            logger.error(airavataExperimentId, "Error while retrieving job details, experiment {} doesn't exist.", airavataExperimentId);
            throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
        }
        List<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
        List<JobModel> jobList = new ArrayList<>();
        if (processModels != null && !processModels.isEmpty()) {
            for (Object process : processModels) {
                ProcessModel processModel = (ProcessModel) process;
                List<TaskModel> tasks = processModel.getTasks();
                if (tasks != null && !tasks.isEmpty()) {
                    for (TaskModel taskModel : tasks) {
                        String taskId = taskModel.getTaskId();
                        List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
                        for (Object jobObject : jobs) {
                            jobList.add((JobModel) jobObject);
                        }
                    }
                }
            }
        }
        logger.debug("Airavata retrieved job models for experiment with experiment id : " + airavataExperimentId);
        return jobList;
    } catch (Exception e) {
        logger.error(airavataExperimentId, "Error while retrieving the job details", e);
        RegistryServiceException exception = new RegistryServiceException();
        exception.setMessage("Error while retrieving the job details. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) JobModel(org.apache.airavata.model.job.JobModel) TaskModel(org.apache.airavata.model.task.TaskModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 9 with TaskModel

use of org.apache.airavata.model.task.TaskModel in project airavata by apache.

the class GFacEngineImpl method saveTaskModel.

/**
 * Persist task model
 */
private void saveTaskModel(TaskContext taskContext) throws GFacException {
    try {
        TaskModel taskModel = taskContext.getTaskModel();
        taskContext.getParentProcessContext().getExperimentCatalog().add(ExpCatChildDataType.TASK, taskModel, taskModel.getParentProcessId());
    } catch (RegistryException e) {
        throw new GFacException("Error while saving task model", e);
    }
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) 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)

Example 10 with TaskModel

use of org.apache.airavata.model.task.TaskModel 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

TaskModel (org.apache.airavata.model.task.TaskModel)11 DataStagingTaskModel (org.apache.airavata.model.task.DataStagingTaskModel)5 EnvironmentSetupTaskModel (org.apache.airavata.model.task.EnvironmentSetupTaskModel)5 JobSubmissionTaskModel (org.apache.airavata.model.task.JobSubmissionTaskModel)5 MonitorTaskModel (org.apache.airavata.model.task.MonitorTaskModel)5 RegistryException (org.apache.airavata.registry.cpi.RegistryException)4 TaskContext (org.apache.airavata.gfac.core.context.TaskContext)3 TaskStatus (org.apache.airavata.model.status.TaskStatus)3 TException (org.apache.thrift.TException)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 GFacException (org.apache.airavata.gfac.core.GFacException)2 JobModel (org.apache.airavata.model.job.JobModel)2 ProcessModel (org.apache.airavata.model.process.ProcessModel)2 JobStatus (org.apache.airavata.model.status.JobStatus)2 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ServerInfo (org.apache.airavata.gfac.core.cluster.ServerInfo)1