use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addJob.
public String addJob(JobModel job, String processId) throws RegistryException {
try {
JobResource jobResource = new JobResource();
jobResource.setJobId(job.getJobId());
jobResource.setProcessId(processId);
jobResource.setTaskId(job.getTaskId());
jobResource.setJobDescription(job.getJobDescription());
jobResource.setCreationTime(AiravataUtils.getTime(job.getCreationTime()));
jobResource.setComputeResourceConsumed(job.getComputeResourceConsumed());
jobResource.setJobName(job.getJobName());
jobResource.setWorkingDir(job.getWorkingDir());
jobResource.setExitCode(job.getExitCode());
jobResource.setStdOut(job.getStdOut());
jobResource.setStdErr(job.getStdErr());
jobResource.save();
} catch (Exception e) {
logger.error(processId, "Error while adding task...", e);
throw new RegistryException(e);
}
return processId;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method getTaskList.
public List<TaskModel> getTaskList(String fieldName, Object value) throws RegistryException {
List<TaskModel> tasks = new ArrayList<TaskModel>();
try {
if (fieldName.equals(Constants.FieldConstants.TaskConstants.PARENT_PROCESS_ID)) {
ProcessResource processResource = new ProcessResource();
processResource.setProcessId((String) value);
List<TaskResource> resources = processResource.getTaskList();
for (TaskResource taskResource : resources) {
TaskModel taskModel = ThriftDataModelConversion.getTaskModel(taskResource);
tasks.add(taskModel);
}
return tasks;
} else {
logger.error("Unsupported field name to retrieve task list...");
}
} catch (Exception e) {
logger.error("Error while getting task list...", e);
throw new RegistryException(e);
}
return tasks;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addJobStatus.
public String addJobStatus(JobStatus jobStatus, CompositeIdentifier cis) throws RegistryException {
String taskId = (String) cis.getTopLevelIdentifier();
String jobID = (String) cis.getSecondLevelIdentifier();
try {
JobResource jobResource = new JobResource();
jobResource.setJobId(jobID);
JobStatusResource status = jobResource.getJobStatus();
if (status == null) {
status = new JobStatusResource();
}
status.setStatusId(getStatusID(jobID));
status.setJobId(jobID);
status.setTaskId(taskId);
status.setTimeOfStateChange(AiravataUtils.getTime(jobStatus.getTimeOfStateChange()));
status.setState(jobStatus.getJobState().toString());
status.setReason(jobStatus.getReason());
status.save();
logger.debug(jobID, "Added job {} status to {}.", jobID, jobStatus.toString());
} catch (Exception e) {
logger.error(jobID, "Error while adding job status...", e);
throw new RegistryException(e);
}
return jobID;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addProcessStatus.
public String addProcessStatus(ProcessStatus processStatus, String processID) throws RegistryException {
try {
ProcessResource processResource = new ProcessResource();
processResource.setProcessId(processID);
ProcessStatusResource status = processResource.getProcessStatus();
ProcessState newState = processStatus.getState();
if (status == null) {
status = (ProcessStatusResource) processResource.create(ResourceType.PROCESS_STATUS);
status.setStatusId(getStatusID("PROCESS_STATE"));
} else {
String state = status.getState();
if (newState != null && !state.equals(newState.toString())) {
status.setStatusId(getStatusID("PROCESS_STATE"));
}
}
status.setProcessId(processID);
status.setTimeOfStateChange(AiravataUtils.getTime(processStatus.getTimeOfStateChange()));
if (newState != null) {
status.setState(newState.toString());
}
status.setReason(processStatus.getReason());
status.save();
logger.debug(processID, "Added process {} status to {}.", processID, processStatus.toString());
} catch (Exception e) {
logger.error(processID, "Error while adding process status...", e);
throw new RegistryException(e);
}
return processID;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method removeJob.
public void removeJob(CompositeIdentifier cis) throws RegistryException {
try {
String processId = (String) cis.getTopLevelIdentifier();
String jobId = (String) cis.getSecondLevelIdentifier();
ProcessResource process = new ProcessResource();
process.setProcessId(processId);
process.remove(ResourceType.JOB, jobId);
} catch (Exception e) {
logger.error("Error while removing task details..", e);
throw new RegistryException(e);
}
}
Aggregations