Search in sources :

Example 66 with RegistryException

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;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 67 with RegistryException

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;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) TaskModel(org.apache.airavata.model.task.TaskModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 68 with RegistryException

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;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 69 with RegistryException

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;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 70 with RegistryException

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);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

RegistryException (org.apache.airavata.registry.cpi.RegistryException)134 EntityManager (javax.persistence.EntityManager)54 Query (javax.persistence.Query)29 QueryGenerator (org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator)29 ArrayList (java.util.ArrayList)15 List (java.util.List)12 ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)12 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)11 ExperimentCatalogException (org.apache.airavata.registry.cpi.ExperimentCatalogException)8 AiravataException (org.apache.airavata.common.exception.AiravataException)6 GFacException (org.apache.airavata.gfac.core.GFacException)6 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)6 Node (org.apache.airavata.workflow.model.graph.Node)6 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)6 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)6 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)6 Timestamp (java.sql.Timestamp)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)4 HashMap (java.util.HashMap)3