Search in sources :

Example 16 with TaskStatus

use of org.apache.airavata.model.status.TaskStatus in project airavata by apache.

the class SimpleOrchestratorImpl method getOutputDataStagingTask.

private TaskModel getOutputDataStagingTask(ProcessModel processModel, OutputDataObjectType processOutput, String gatewayId) throws RegistryException, TException, AiravataException {
    try {
        // create new task model for this task
        TaskModel taskModel = new TaskModel();
        taskModel.setParentProcessId(processModel.getProcessId());
        taskModel.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
        taskModel.setLastUpdateTime(taskModel.getCreationTime());
        TaskStatus taskStatus = new TaskStatus(TaskState.CREATED);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskModel.setTaskStatuses(Arrays.asList(taskStatus));
        taskModel.setTaskType(TaskTypes.DATA_STAGING);
        ComputeResourceDescription computeResource = orchestratorContext.getRegistry().getAppCatalog().getComputeResource().getComputeResource(processModel.getComputeResourceId());
        String workingDir = OrchestratorUtils.getScratchLocation(orchestratorContext, processModel, gatewayId) + File.separator + processModel.getProcessId() + File.separator;
        DataStagingTaskModel submodel = new DataStagingTaskModel();
        DataMovementProtocol dataMovementProtocol = OrchestratorUtils.getPreferredDataMovementProtocol(orchestratorContext, processModel, gatewayId);
        URI source = null;
        try {
            String loginUserName = OrchestratorUtils.getLoginUserName(orchestratorContext, processModel, gatewayId);
            if (processOutput != null) {
                submodel.setType(DataStageType.OUPUT);
                submodel.setProcessOutput(processOutput);
                source = new URI(dataMovementProtocol.name(), loginUserName, computeResource.getHostName(), OrchestratorUtils.getDataMovementPort(orchestratorContext, processModel, gatewayId), workingDir + processOutput.getValue(), null, null);
            } else {
                // archive
                submodel.setType(DataStageType.ARCHIVE_OUTPUT);
                source = new URI(dataMovementProtocol.name(), loginUserName, computeResource.getHostName(), OrchestratorUtils.getDataMovementPort(orchestratorContext, processModel, gatewayId), workingDir, null, null);
            }
        } catch (URISyntaxException e) {
            throw new TaskException("Error while constructing source file URI");
        }
        // We don't know destination location at this time, data staging task will set this.
        // because destination is required field we set dummy destination
        submodel.setSource(source.toString());
        // We don't know destination location at this time, data staging task will set this.
        // because destination is required field we set dummy destination
        submodel.setDestination("dummy://temp/file/location");
        taskModel.setSubTaskModel(ThriftUtils.serializeThriftObject(submodel));
        return taskModel;
    } catch (AppCatalogException | TaskException e) {
        throw new RegistryException("Error occurred while retrieving data movement from app catalog", e);
    }
}
Also used : TaskException(org.apache.airavata.gfac.core.task.TaskException) DataMovementProtocol(org.apache.airavata.model.data.movement.DataMovementProtocol) URISyntaxException(java.net.URISyntaxException) TaskStatus(org.apache.airavata.model.status.TaskStatus) URI(java.net.URI)

Example 17 with TaskStatus

use of org.apache.airavata.model.status.TaskStatus in project airavata by apache.

the class SimpleOrchestratorImpl method createAndSaveEnvSetupTask.

private List<String> createAndSaveEnvSetupTask(String gatewayId, ProcessModel processModel, ExperimentCatalog experimentCatalog) throws RegistryException, TException, AiravataException {
    List<String> envTaskIds = new ArrayList<>();
    TaskModel envSetupTask = new TaskModel();
    envSetupTask.setTaskType(TaskTypes.ENV_SETUP);
    envSetupTask.setTaskStatuses(Arrays.asList(new TaskStatus(TaskState.CREATED)));
    envSetupTask.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
    envSetupTask.setParentProcessId(processModel.getProcessId());
    EnvironmentSetupTaskModel envSetupSubModel = new EnvironmentSetupTaskModel();
    envSetupSubModel.setProtocol(OrchestratorUtils.getSecurityProtocol(orchestratorContext, processModel, gatewayId));
    ComputeResourcePreference computeResourcePreference = OrchestratorUtils.getComputeResourcePreference(orchestratorContext, processModel, gatewayId);
    String scratchLocation = OrchestratorUtils.getScratchLocation(orchestratorContext, processModel, gatewayId);
    String workingDir = scratchLocation + File.separator + processModel.getProcessId();
    envSetupSubModel.setLocation(workingDir);
    byte[] envSetupSub = ThriftUtils.serializeThriftObject(envSetupSubModel);
    envSetupTask.setSubTaskModel(envSetupSub);
    String envSetupTaskId = (String) experimentCatalog.add(ExpCatChildDataType.TASK, envSetupTask, processModel.getProcessId());
    envSetupTask.setTaskId(envSetupTaskId);
    envTaskIds.add(envSetupTaskId);
    return envTaskIds;
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) TaskStatus(org.apache.airavata.model.status.TaskStatus)

Example 18 with TaskStatus

use of org.apache.airavata.model.status.TaskStatus in project airavata by apache.

the class SimpleOrchestratorImpl method createAndSaveSubmissionTasks.

private List<String> createAndSaveSubmissionTasks(String gatewayId, JobSubmissionInterface jobSubmissionInterface, ProcessModel processModel, int wallTime) throws TException, RegistryException, OrchestratorException {
    JobSubmissionProtocol jobSubmissionProtocol = jobSubmissionInterface.getJobSubmissionProtocol();
    MonitorMode monitorMode = null;
    if (jobSubmissionProtocol == JobSubmissionProtocol.SSH || jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK) {
        SSHJobSubmission sshJobSubmission = OrchestratorUtils.getSSHJobSubmission(orchestratorContext, jobSubmissionInterface.getJobSubmissionInterfaceId());
        monitorMode = sshJobSubmission.getMonitorMode();
    } else if (jobSubmissionProtocol == JobSubmissionProtocol.UNICORE) {
        monitorMode = MonitorMode.FORK;
    } else if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL) {
        monitorMode = MonitorMode.LOCAL;
    } else if (jobSubmissionProtocol == JobSubmissionProtocol.CLOUD) {
        monitorMode = MonitorMode.CLOUD_JOB_MONITOR;
    } else {
        logger.error("expId : {}, processId : {} :- Unsupported Job submission protocol {}.", processModel.getExperimentId(), processModel.getProcessId(), jobSubmissionProtocol.name());
        throw new OrchestratorException("Unsupported Job Submission Protocol " + jobSubmissionProtocol.name());
    }
    List<String> submissionTaskIds = new ArrayList<>();
    TaskModel taskModel = new TaskModel();
    taskModel.setParentProcessId(processModel.getProcessId());
    taskModel.setCreationTime(new Date().getTime());
    taskModel.setLastUpdateTime(taskModel.getCreationTime());
    TaskStatus taskStatus = new TaskStatus(TaskState.CREATED);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskModel.setTaskStatuses(Arrays.asList(taskStatus));
    taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
    JobSubmissionTaskModel submissionSubTask = new JobSubmissionTaskModel();
    submissionSubTask.setMonitorMode(monitorMode);
    submissionSubTask.setJobSubmissionProtocol(jobSubmissionProtocol);
    submissionSubTask.setWallTime(wallTime);
    byte[] bytes = ThriftUtils.serializeThriftObject(submissionSubTask);
    taskModel.setSubTaskModel(bytes);
    String taskId = (String) orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.TASK, taskModel, processModel.getProcessId());
    taskModel.setTaskId(taskId);
    submissionTaskIds.add(taskModel.getTaskId());
    // create monitor task for this Email based monitor mode job
    if (monitorMode == MonitorMode.JOB_EMAIL_NOTIFICATION_MONITOR || monitorMode == MonitorMode.CLOUD_JOB_MONITOR) {
        TaskModel monitorTaskModel = new TaskModel();
        monitorTaskModel.setParentProcessId(processModel.getProcessId());
        monitorTaskModel.setCreationTime(new Date().getTime());
        monitorTaskModel.setLastUpdateTime(monitorTaskModel.getCreationTime());
        TaskStatus monitorTaskStatus = new TaskStatus(TaskState.CREATED);
        monitorTaskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        monitorTaskModel.setTaskStatuses(Arrays.asList(monitorTaskStatus));
        monitorTaskModel.setTaskType(TaskTypes.MONITORING);
        MonitorTaskModel monitorSubTaskModel = new MonitorTaskModel();
        monitorSubTaskModel.setMonitorMode(monitorMode);
        monitorTaskModel.setSubTaskModel(ThriftUtils.serializeThriftObject(monitorSubTaskModel));
        String mTaskId = (String) orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.TASK, monitorTaskModel, processModel.getProcessId());
        monitorTaskModel.setTaskId(mTaskId);
        submissionTaskIds.add(monitorTaskModel.getTaskId());
    }
    return submissionTaskIds;
}
Also used : OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) TaskStatus(org.apache.airavata.model.status.TaskStatus)

Example 19 with TaskStatus

use of org.apache.airavata.model.status.TaskStatus in project airavata by apache.

the class GFacEngineImpl method executeDataStreaming.

private void executeDataStreaming(TaskContext taskContext, boolean recovery) throws GFacException {
    TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
    try {
        DataStreamingTask dataStreamingTask = new DataStreamingTask();
        taskStatus = executeTask(taskContext, dataStreamingTask, recovery);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
    } catch (Exception e) {
        throw new GFacException(e);
    }
}
Also used : DataStreamingTask(org.apache.airavata.gfac.impl.task.DataStreamingTask) GFacException(org.apache.airavata.gfac.core.GFacException) TaskStatus(org.apache.airavata.model.status.TaskStatus) URISyntaxException(java.net.URISyntaxException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) TaskException(org.apache.airavata.gfac.core.task.TaskException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) TException(org.apache.thrift.TException)

Example 20 with TaskStatus

use of org.apache.airavata.model.status.TaskStatus in project airavata by apache.

the class GFacEngineImpl method configureWorkspace.

private boolean configureWorkspace(TaskContext taskContext, boolean recover) throws GFacException {
    try {
        EnvironmentSetupTaskModel subTaskModel = (EnvironmentSetupTaskModel) taskContext.getSubTaskModel();
        Task envSetupTask = null;
        if (subTaskModel.getProtocol() == SecurityProtocol.SSH_KEYS || subTaskModel.getProtocol() == SecurityProtocol.LOCAL) {
            envSetupTask = new EnvironmentSetupTask();
        } else {
            throw new GFacException("Unsupported security protocol, Airavata doesn't support " + subTaskModel.getProtocol().name() + " protocol yet.");
        }
        TaskStatus status = new TaskStatus(TaskState.EXECUTING);
        status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(status);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        TaskStatus taskStatus = executeTask(taskContext, envSetupTask, recover);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        if (taskStatus.getState() == TaskState.FAILED) {
            log.error("expId: {}, processId: {}, taskId: {} type: {},:- Input staging failed, " + "reason:" + " {}", taskContext.getParentProcessContext().getExperimentId(), taskContext.getParentProcessContext().getProcessId(), taskContext.getTaskId(), envSetupTask.getType().name(), taskStatus.getReason());
            ProcessContext processContext = taskContext.getParentProcessContext();
            String errorMsg = new StringBuilder("expId: ").append(processContext.getExperimentId()).append(", processId: ").append(processContext.getProcessId()).append(", taskId: ").append(taskContext.getTaskId()).append(", type: ").append(taskContext.getTaskType().name()).append(" :- Environment Setup failed. Reason: ").append(taskStatus.getReason()).toString();
            ErrorModel errorModel = new ErrorModel();
            errorModel.setUserFriendlyMessage("Error while environment setup");
            errorModel.setActualErrorMessage(errorMsg);
            GFacUtils.saveTaskError(taskContext, errorModel);
            throw new GFacException("Error while environment setup");
        }
    } catch (TException e) {
        throw new GFacException("Couldn't get environment setup task model", e);
    }
    return false;
}
Also used : TException(org.apache.thrift.TException) EnvironmentSetupTaskModel(org.apache.airavata.model.task.EnvironmentSetupTaskModel) DataStreamingTask(org.apache.airavata.gfac.impl.task.DataStreamingTask) Task(org.apache.airavata.gfac.core.task.Task) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) EnvironmentSetupTask(org.apache.airavata.gfac.impl.task.EnvironmentSetupTask) GFacException(org.apache.airavata.gfac.core.GFacException) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskStatus(org.apache.airavata.model.status.TaskStatus) EnvironmentSetupTask(org.apache.airavata.gfac.impl.task.EnvironmentSetupTask) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext)

Aggregations

TaskStatus (org.apache.airavata.model.status.TaskStatus)22 GFacException (org.apache.airavata.gfac.core.GFacException)13 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)11 ErrorModel (org.apache.airavata.model.commons.ErrorModel)10 URISyntaxException (java.net.URISyntaxException)9 TException (org.apache.thrift.TException)9 DataStagingTaskModel (org.apache.airavata.model.task.DataStagingTaskModel)8 URI (java.net.URI)7 TaskException (org.apache.airavata.gfac.core.task.TaskException)5 JobStatus (org.apache.airavata.model.status.JobStatus)5 IOException (java.io.IOException)4 AiravataException (org.apache.airavata.common.exception.AiravataException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)4 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)4 JobSubmissionTask (org.apache.airavata.gfac.core.task.JobSubmissionTask)4 DataStreamingTask (org.apache.airavata.gfac.impl.task.DataStreamingTask)4 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)4 JobModel (org.apache.airavata.model.job.JobModel)4 EnvironmentSetupTaskModel (org.apache.airavata.model.task.EnvironmentSetupTaskModel)4