Search in sources :

Example 21 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method removeUserConfigData.

public void removeUserConfigData(String experimentId) throws RegistryException {
    try {
        ExperimentResource experiment = new ExperimentResource();
        experiment.setExperimentId(experimentId);
        experiment.remove(ResourceType.USER_CONFIGURATION_DATA, experimentId);
    } catch (Exception e) {
        logger.error("Error while removing experiment config..", e);
        throw new RegistryException(e);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 22 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method searchAllAccessibleExperiments.

public List<ExperimentSummaryModel> searchAllAccessibleExperiments(List<String> accessibleIds, Map<String, String> filters, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
    Map<String, String> fil = new HashMap<String, String>();
    if (filters != null && filters.size() != 0) {
        List<ExperimentSummaryModel> experimentSummaries = new ArrayList<>();
        long fromTime = 0;
        long toTime = 0;
        try {
            for (String field : filters.keySet()) {
                if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.EXPERIMENT_NAME, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.USER_NAME, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.PROJECT_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.GATEWAY_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.DESCRIPTION)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.DESCRIPTION, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID)) {
                    fil.put(AbstractExpCatResource.ExperimentConstants.EXECUTION_ID, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS)) {
                    fil.put(AbstractExpCatResource.ExperimentStatusConstants.STATE, filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.FROM_DATE)) {
                    fromTime = Long.parseLong(filters.get(field));
                } else if (field.equals(Constants.FieldConstants.ExperimentConstants.TO_DATE)) {
                    toTime = Long.parseLong(filters.get(field));
                }
            }
            List<ExperimentSummaryResource> experimentSummaryResources;
            if (fromTime != 0 && toTime != 0) {
                experimentSummaryResources = workerResource.searchExperiments(accessibleIds, new Timestamp(fromTime), new Timestamp(toTime), fil, limit, offset, orderByIdentifier, resultOrderType);
            } else {
                experimentSummaryResources = workerResource.searchExperiments(accessibleIds, null, null, fil, limit, offset, orderByIdentifier, resultOrderType);
            }
            if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty()) {
                for (ExperimentSummaryResource ex : experimentSummaryResources) {
                    experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
                }
            }
            return experimentSummaries;
        } catch (Exception e) {
            logger.error("Error while retrieving experiment summary from registry", e);
            throw new RegistryException(e);
        }
    }
    return null;
}
Also used : ExperimentSummaryModel(org.apache.airavata.model.experiment.ExperimentSummaryModel) Timestamp(java.sql.Timestamp) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 23 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method addExperimentStatus.

public String addExperimentStatus(ExperimentStatus experimentStatus, String expId) throws RegistryException {
    try {
        ExperimentResource experiment = new ExperimentResource();
        experiment.setExperimentId(expId);
        ExperimentStatusResource status = experiment.getExperimentStatus();
        ExperimentState newState = experimentStatus.getState();
        if (status == null) {
            status = (ExperimentStatusResource) experiment.create(ResourceType.EXPERIMENT_STATUS);
            status.setStatusId(getStatusID("EXPERIMENT_STATE"));
        } else {
            String state = status.getState();
            if (newState != null && !state.equals(newState.toString())) {
                status.setStatusId(getStatusID("EXPERIMENT_STATE"));
            }
        }
        status.setExperimentId(expId);
        status.setTimeOfStateChange(AiravataUtils.getTime(experimentStatus.getTimeOfStateChange()));
        if (newState != null) {
            status.setState(newState.toString());
        }
        status.setReason(experimentStatus.getReason());
        status.save();
        logger.debug(expId, "Added experiment {} status to {}.", expId, experimentStatus.toString());
    } catch (Exception e) {
        logger.error(expId, "Error while adding experiment status...", e);
        throw new RegistryException(e);
    }
    return expId;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 24 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method addUserConfigData.

public String addUserConfigData(UserConfigurationDataModel configurationData, String experimentId) throws RegistryException {
    try {
        UserConfigurationDataResource configDataResource = new UserConfigurationDataResource();
        configDataResource.setExperimentId(experimentId);
        configDataResource.setAiravataAutoSchedule(configurationData.isAiravataAutoSchedule());
        configDataResource.setOverrideManualScheduledParams(configurationData.isOverrideManualScheduledParams());
        configDataResource.setShareExperimentPublically(configurationData.isShareExperimentPublicly());
        configDataResource.setThrottleResources(configurationData.isThrottleResources());
        configDataResource.setUserDn(configurationData.getUserDN());
        configDataResource.setGenerateCert(configurationData.isGenerateCert());
        configDataResource.setResourceHostId(configurationData.getComputationalResourceScheduling().getResourceHostId());
        configDataResource.setTotalCpuCount(configurationData.getComputationalResourceScheduling().getTotalCPUCount());
        configDataResource.setNodeCount(configurationData.getComputationalResourceScheduling().getNodeCount());
        configDataResource.setNumberOfThreads(configurationData.getComputationalResourceScheduling().getNumberOfThreads());
        configDataResource.setQueueName(configurationData.getComputationalResourceScheduling().getQueueName());
        configDataResource.setWallTimeLimit(configurationData.getComputationalResourceScheduling().getWallTimeLimit());
        configDataResource.setTotalPhysicalMemory(configurationData.getComputationalResourceScheduling().getTotalPhysicalMemory());
        configDataResource.setStaticWorkingDir(configurationData.getComputationalResourceScheduling().getStaticWorkingDir());
        configDataResource.setStorageId(configurationData.getStorageId());
        configDataResource.setExperimentDataDir(configurationData.getExperimentDataDir());
        configDataResource.setUseUserCRPref(configurationData.isUseUserCRPref());
        configDataResource.setOverrideLoginUserName(configurationData.getComputationalResourceScheduling().getOverrideLoginUserName());
        configDataResource.setOverrideScratchLocation(configurationData.getComputationalResourceScheduling().getOverrideScratchLocation());
        configDataResource.setOverrideAllocationProjectNumber(configurationData.getComputationalResourceScheduling().getOverrideAllocationProjectNumber());
        configDataResource.save();
    } catch (Exception e) {
        logger.error("Unable to save user config data", e);
        throw new RegistryException(e);
    }
    return experimentId;
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 25 with RegistryException

use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.

the class ExperimentRegistry method updateJob.

public String updateJob(JobModel job, CompositeIdentifier cis) throws RegistryException {
    String taskId = (String) cis.getTopLevelIdentifier();
    String jobId = (String) cis.getSecondLevelIdentifier();
    try {
        TaskResource taskResource = new TaskResource();
        taskResource.setTaskId(taskId);
        JobResource jobResource = taskResource.getJob(jobId);
        jobResource.setJobId(jobId);
        jobResource.setTaskId(job.getTaskId());
        jobResource.setProcessId(job.getProcessId());
        jobResource.setJobDescription(job.getJobDescription());
        jobResource.setCreationTime(AiravataUtils.getTime(job.getCreationTime()));
        jobResource.setComputeResourceConsumed(job.getComputeResourceConsumed());
        jobResource.setJobName(job.getJobName());
        jobResource.setWorkingDir(job.getWorkingDir());
        jobResource.setStdOut(job.getStdOut());
        jobResource.setStdErr(job.getStdErr());
        jobResource.setExitCode(job.getExitCode());
        jobResource.save();
    } catch (Exception e) {
        logger.error(jobId, "Error while adding job...", e);
        throw new RegistryException(e);
    }
    return jobId;
}
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