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);
}
}
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;
}
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;
}
}
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);
}
}
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);
}
}
Aggregations