Search in sources :

Example 21 with TaskStatus

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

the class GFacEngineImpl method executeJobSubmission.

private boolean executeJobSubmission(TaskContext taskContext, boolean recovery) throws GFacException {
    TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
    taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    taskContext.setTaskStatus(taskStatus);
    GFacUtils.saveAndPublishTaskStatus(taskContext);
    try {
        JobSubmissionTaskModel jobSubmissionTaskModel = ((JobSubmissionTaskModel) taskContext.getSubTaskModel());
        JobSubmissionTask jobSubmissionTask = Factory.getJobSubmissionTask(jobSubmissionTaskModel.getJobSubmissionProtocol());
        ProcessContext processContext = taskContext.getParentProcessContext();
        taskStatus = executeTask(taskContext, jobSubmissionTask, recovery);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.setTaskStatus(taskStatus);
        GFacUtils.saveAndPublishTaskStatus(taskContext);
        checkFailures(taskContext, taskStatus, jobSubmissionTask);
        return false;
    } catch (TException e) {
        throw new GFacException(e);
    }
}
Also used : TException(org.apache.thrift.TException) GFacException(org.apache.airavata.gfac.core.GFacException) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) TaskStatus(org.apache.airavata.model.status.TaskStatus) JobSubmissionTaskModel(org.apache.airavata.model.task.JobSubmissionTaskModel) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext)

Example 22 with TaskStatus

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

the class GFacEngineImpl method getDataStagingTaskContext.

private TaskContext getDataStagingTaskContext(ProcessContext processContext, OutputDataObjectType processOutput) throws TException, TaskException, GFacException {
    TaskContext taskCtx = new TaskContext();
    taskCtx.setParentProcessContext(processContext);
    // create new task model for this task
    TaskModel taskModel = new TaskModel();
    taskModel.setParentProcessId(processContext.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);
    // create data staging sub task model
    String remoteOutputDir = processContext.getOutputDir();
    remoteOutputDir = remoteOutputDir.endsWith("/") ? remoteOutputDir : remoteOutputDir + "/";
    DataStagingTaskModel submodel = new DataStagingTaskModel();
    ServerInfo serverInfo = processContext.getComputeResourceServerInfo();
    URI source = null;
    try {
        source = new URI(processContext.getDataMovementProtocol().name(), serverInfo.getHost(), serverInfo.getUserName(), serverInfo.getPort(), remoteOutputDir + processOutput.getValue(), null, null);
    } catch (URISyntaxException e) {
        throw new TaskException("Error while constructing source file URI");
    }
    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));
    taskCtx.setTaskModel(taskModel);
    taskCtx.setProcessOutput(processOutput);
    return taskCtx;
}
Also used : TaskContext(org.apache.airavata.gfac.core.context.TaskContext) TaskException(org.apache.airavata.gfac.core.task.TaskException) ServerInfo(org.apache.airavata.gfac.core.cluster.ServerInfo) DataStagingTaskModel(org.apache.airavata.model.task.DataStagingTaskModel) URISyntaxException(java.net.URISyntaxException) TaskStatus(org.apache.airavata.model.status.TaskStatus) URI(java.net.URI) 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

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