Search in sources :

Example 76 with RegistryException

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

the class ExperimentRegistry method updateProcessOutputs.

public void updateProcessOutputs(List<OutputDataObjectType> processOutput, String processID) throws RegistryException {
    try {
        ProcessResource processResource = new ProcessResource();
        processResource.setProcessId(processID);
        List<ProcessOutputResource> existingProcessOutputs = processResource.getProcessOutputs();
        for (OutputDataObjectType output : processOutput) {
            for (ProcessOutputResource resource : existingProcessOutputs) {
                if (resource.getOutputName().equals(output.getName())) {
                    resource.setProcessId(processID);
                    resource.setOutputName(output.getName());
                    resource.setOutputValue(output.getValue());
                    if (output.getType() != null) {
                        resource.setDataType(output.getType().toString());
                    }
                    resource.setIsRequired(output.isIsRequired());
                    resource.setRequiredToAddedToCmd(output.isRequiredToAddedToCommandLine());
                    resource.setDataMovement(output.isDataMovement());
                    resource.setLocation(output.getLocation());
                    resource.setApplicationArgument(output.getApplicationArgument());
                    resource.setSearchQuery(output.getSearchQuery());
                    resource.setOutputStreaming(output.isOutputStreaming());
                    resource.setStorageResourceId(output.getStorageResourceId());
                    resource.save();
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating process outputs", e);
        throw new RegistryException(e);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 77 with RegistryException

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

the class ExperimentRegistry method isJobExist.

public boolean isJobExist(CompositeIdentifier cis) throws RegistryException {
    String taskId = (String) cis.getTopLevelIdentifier();
    String jobId = (String) cis.getSecondLevelIdentifier();
    try {
        TaskResource taskResource = new TaskResource();
        taskResource.setTaskId(taskId);
        return taskResource.isExists(ResourceType.JOB, jobId);
    } catch (Exception e) {
        logger.error("Error while retrieving job.....", e);
        throw new RegistryException(e);
    }
}
Also used : RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 78 with RegistryException

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

the class ExperimentRegistry method updateUserConfigData.

public String updateUserConfigData(UserConfigurationDataModel configurationData, String experimentId) throws RegistryException {
    try {
        ExperimentResource experimentResource = new ExperimentResource();
        experimentResource.setExperimentId(experimentId);
        UserConfigurationDataResource configDataResource = experimentResource.getUserConfigurationDataResource();
        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.setStorageId(configurationData.getStorageId());
        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.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 79 with RegistryException

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

the class ExperimentRegistry method getExperimentList.

public List<ExperimentModel> getExperimentList(String fieldName, Object value) throws RegistryException {
    List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
    try {
        if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
            WorkerResource resource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
            resource.setUser((String) value);
            List<ExperimentResource> resources = resource.getExperiments();
            for (ExperimentResource experimentResource : resources) {
                ExperimentModel experiment = ThriftDataModelConversion.getExperiment(experimentResource);
                experiments.add(experiment);
            }
            return experiments;
        } else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
            ProjectResource project = workerResource.getProject((String) value);
            List<ExperimentResource> resources = project.getExperiments();
            for (ExperimentResource resource : resources) {
                ExperimentModel experiment = ThriftDataModelConversion.getExperiment(resource);
                experiments.add(experiment);
            }
            return experiments;
        } else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID)) {
            List<ExperimentResource> resources = gatewayResource.getExperiments();
            for (ExperimentResource resource : resources) {
                ExperimentModel experiment = ThriftDataModelConversion.getExperiment(resource);
                experiments.add(experiment);
            }
            return experiments;
        } else {
            logger.error("Unsupported field name to retrieve experiment list...");
        }
    } catch (Exception e) {
        logger.error("Error while getting experiment list...", e);
        throw new RegistryException(e);
    }
    return experiments;
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 80 with RegistryException

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

the class ExperimentRegistry method updateExperiment.

// CPI Update Methods
public void updateExperiment(ExperimentModel experiment, String expId) throws RegistryException {
    try {
        if (!workerResource.isProjectExists(experiment.getProjectId())) {
            logger.error("Project does not exist in the system..");
            throw new Exception("Project does not exist in the system, Please create the project first...");
        }
        ExperimentResource existingExperiment = gatewayResource.getExperiment(expId);
        existingExperiment.setExperimentName(experiment.getExperimentName());
        existingExperiment.setUserName(experiment.getUserName());
        existingExperiment.setGatewayId(experiment.getGatewayId());
        existingExperiment.setGatewayExecutionId(experiment.getGatewayExecutionId());
        existingExperiment.setGatewayInstanceId(experiment.getGatewayInstanceId());
        existingExperiment.setProjectId(experiment.getProjectId());
        existingExperiment.setCreationTime(AiravataUtils.getTime(experiment.getCreationTime()));
        existingExperiment.setDescription(experiment.getDescription());
        existingExperiment.setExecutionId(experiment.getExecutionId());
        if (experiment.isEnableEmailNotification()) {
            existingExperiment.setEnableEmailNotification(true);
            if (experiment.getEmailAddresses() != null) {
                existingExperiment.setEmailAddresses(StringUtils.join(experiment.getEmailAddresses(), ","));
            }
        } else {
            existingExperiment.setEnableEmailNotification(false);
        }
        existingExperiment.save();
        UserConfigurationDataModel userConfigurationData = experiment.getUserConfigurationData();
        if (userConfigurationData != null) {
            updateUserConfigData(userConfigurationData, expId);
        }
        List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs();
        if (experimentInputs != null && !experimentInputs.isEmpty()) {
            updateExpInputs(experimentInputs, expId);
        }
        List<OutputDataObjectType> experimentOutputs = experiment.getExperimentOutputs();
        if (experimentOutputs != null && !experimentOutputs.isEmpty()) {
            updateExpOutputs(experimentOutputs, expId);
        }
        List<ExperimentStatus> experimentStatuses = experiment.getExperimentStatus();
        if (experimentStatuses != null && experimentStatuses.size() > 0) {
            if (experimentStatuses.get(0) != null) {
                updateExperimentStatus(experimentStatuses.get(0), expId);
            }
        }
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel errror : errors) {
                updateExperimentError(errror, expId);
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating experiment...", e);
        throw new RegistryException(e);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ErrorModel(org.apache.airavata.model.commons.ErrorModel) 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