use of org.apache.airavata.gfac.core.context.TaskContext in project airavata by apache.
the class GFacEngineImpl method cancelProcess.
@Override
public void cancelProcess(ProcessContext processContext) throws GFacException {
if (processContext != null) {
switch(processContext.getProcessState()) {
case MONITORING:
case EXECUTING:
// get job submission task and invoke cancel
JobSubmissionTask jobSubmissionTask = Factory.getJobSubmissionTask(processContext.getJobSubmissionProtocol());
TaskContext taskCtx = getJobSubmissionTaskContext(processContext);
executeCancel(taskCtx, jobSubmissionTask);
break;
case COMPLETED:
case FAILED:
case CANCELED:
case CANCELLING:
log.warn("Process cancel trigger for already {} process", processContext.getProcessState().name());
break;
default:
break;
}
}
}
use of org.apache.airavata.gfac.core.context.TaskContext in project airavata by apache.
the class GFacEngineImpl method getTaskContext.
private TaskContext getTaskContext(ProcessContext processContext) {
TaskContext taskCtx = new TaskContext();
taskCtx.setParentProcessContext(processContext);
return taskCtx;
}
use of org.apache.airavata.gfac.core.context.TaskContext 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;
}
Aggregations