Search in sources :

Example 16 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class GfacServerHandler method submissionErrorHandling.

private void submissionErrorHandling(ProcessStatus status, ProcessSubmitEvent event, TException e) throws RegistryException, AiravataException {
    StringWriter errors = new StringWriter();
    e.printStackTrace(new PrintWriter(errors));
    ErrorModel errorModel = new ErrorModel();
    errorModel.setUserFriendlyMessage("Process execution failed");
    errorModel.setActualErrorMessage(errors.toString());
    errorModel.setCreationTime(AiravataUtils.getCurrentTimestamp().getTime());
    errorModel.setErrorId(AiravataUtils.getId("PROCESS_ERROR"));
    Factory.getDefaultExpCatalog().add(ExpCatChildDataType.PROCESS_ERROR, errorModel, event.getProcessId());
    errorModel.setErrorId(AiravataUtils.getId("EXP_ERROR"));
    Factory.getDefaultExpCatalog().add(ExpCatChildDataType.EXPERIMENT_ERROR, errorModel, event.getExperimentId());
    status.setState(ProcessState.FAILED);
    status.setReason("Process execution failed");
    status.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
    Factory.getDefaultExpCatalog().update(ExperimentCatalogModelType.PROCESS_STATUS, status, event.getProcessId());
    publishProcessStatus(event, status);
}
Also used : StringWriter(java.io.StringWriter) ErrorModel(org.apache.airavata.model.commons.ErrorModel) PrintWriter(java.io.PrintWriter)

Example 17 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class SimpleOrchestratorImpl method validateProcess.

public ValidationResults validateProcess(ExperimentModel experiment, ProcessModel processModel) throws OrchestratorException, LaunchValidationException {
    org.apache.airavata.model.error.ValidationResults validationResults = new org.apache.airavata.model.error.ValidationResults();
    // initially making it to success, if atleast one failed them simply mark it failed.
    validationResults.setValidationState(true);
    String errorMsg = "Validation Errors : ";
    if (this.orchestratorConfiguration.isEnableValidation()) {
        List<String> validatorClzzez = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClasses();
        for (String validator : validatorClzzez) {
            try {
                Class<? extends JobMetadataValidator> vClass = Class.forName(validator.trim()).asSubclass(JobMetadataValidator.class);
                JobMetadataValidator jobMetadataValidator = vClass.newInstance();
                validationResults = jobMetadataValidator.validate(experiment, processModel);
                if (validationResults.isValidationState()) {
                    logger.info("Validation of " + validator + " is SUCCESSFUL");
                } else {
                    List<ValidatorResult> validationResultList = validationResults.getValidationResultList();
                    for (ValidatorResult result : validationResultList) {
                        if (!result.isResult()) {
                            String validationError = result.getErrorDetails();
                            if (validationError != null) {
                                errorMsg += validationError + " ";
                            }
                        }
                    }
                    logger.error("Validation of " + validator + " for experiment Id " + experiment.getExperimentId() + " is FAILED:[error]. " + errorMsg);
                    validationResults.setValidationState(false);
                    try {
                        ErrorModel details = new ErrorModel();
                        details.setActualErrorMessage(errorMsg);
                        details.setCreationTime(Calendar.getInstance().getTimeInMillis());
                        orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.PROCESS_ERROR, details, processModel.getProcessId());
                    } catch (RegistryException e) {
                        logger.error("Error while saving error details to registry", e);
                    }
                    break;
                }
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            }
        }
    }
    if (validationResults.isValidationState()) {
        return validationResults;
    } else {
        // atleast one validation has failed, so we throw an exception
        LaunchValidationException launchValidationException = new LaunchValidationException();
        launchValidationException.setValidationResult(validationResults);
        launchValidationException.setErrorMessage("Validation failed refer the validationResults " + "list for detail error. Validation errors : " + errorMsg);
        throw launchValidationException;
    }
}
Also used : ValidatorResult(org.apache.airavata.model.error.ValidatorResult) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) ValidationResults(org.apache.airavata.model.error.ValidationResults) ValidationResults(org.apache.airavata.model.error.ValidationResults) ErrorModel(org.apache.airavata.model.commons.ErrorModel) JobMetadataValidator(org.apache.airavata.orchestrator.core.validator.JobMetadataValidator)

Example 18 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel in project airavata by apache.

the class ExperimentRegistry method addExperiment.

// CPI Add Methods
public String addExperiment(ExperimentModel experiment) throws RegistryException {
    String experimentId;
    try {
        if (!ExpCatResourceUtils.isUserExist(experiment.getUserName(), experiment.getGatewayId())) {
            ExpCatResourceUtils.addUser(experiment.getUserName(), null, experiment.getGatewayId());
        }
        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...");
        }
        experimentId = AiravataUtils.getId(experiment.getExperimentName());
        experiment.setExperimentId(experimentId);
        ExperimentResource experimentResource = new ExperimentResource();
        experimentResource.setExperimentId(experimentId);
        experimentResource.setProjectId(experiment.getProjectId());
        experimentResource.setGatewayId(experiment.getGatewayId());
        experimentResource.setExperimentType(experiment.getExperimentType().toString());
        experimentResource.setUserName(experiment.getUserName());
        experimentResource.setExperimentName(experiment.getExperimentName());
        experimentResource.setCreationTime(AiravataUtils.getTime(experiment.getCreationTime()));
        experimentResource.setDescription(experiment.getDescription());
        experimentResource.setExecutionId(experiment.getExecutionId());
        experimentResource.setGatewayExecutionId(experiment.getGatewayExecutionId());
        experimentResource.setGatewayInstanceId(experiment.getGatewayInstanceId());
        if (experiment.isEnableEmailNotification()) {
            experimentResource.setEnableEmailNotification(true);
            if (experiment.getEmailAddresses() != null) {
                experimentResource.setEmailAddresses(StringUtils.join(experiment.getEmailAddresses(), ","));
            }
        } else {
            experimentResource.setEnableEmailNotification(false);
        }
        experimentResource.save();
        if (experiment.getUserConfigurationData() != null) {
            addUserConfigData(experiment.getUserConfigurationData(), experimentId);
        }
        if (experiment.getExperimentInputs() != null && experiment.getExperimentInputs().size() > 0) {
            addExpInputs(experiment.getExperimentInputs(), experimentId);
        }
        if (experiment.getExperimentOutputs() != null && experiment.getExperimentOutputs().size() > 0) {
            addExpOutputs(experiment.getExperimentOutputs(), experimentId);
        }
        ExperimentStatus experimentStatus = new ExperimentStatus();
        experimentStatus.setState(ExperimentState.CREATED);
        experimentStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        addExperimentStatus(experimentStatus, experimentId);
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel errror : errors) {
                addExperimentError(errror, experimentId);
            }
        }
    } catch (Exception e) {
        logger.error("Error while saving experiment to registry", e);
        throw new RegistryException(e);
    }
    return experimentId;
}
Also used : ErrorModel(org.apache.airavata.model.commons.ErrorModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 19 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel 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)

Example 20 with ErrorModel

use of org.apache.airavata.model.commons.ErrorModel 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;
}
Also used : ArrayList(java.util.ArrayList) ErrorModel(org.apache.airavata.model.commons.ErrorModel) TaskModel(org.apache.airavata.model.task.TaskModel)

Aggregations

ErrorModel (org.apache.airavata.model.commons.ErrorModel)25 GFacException (org.apache.airavata.gfac.core.GFacException)11 TaskStatus (org.apache.airavata.model.status.TaskStatus)10 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)9 TException (org.apache.thrift.TException)6 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)5 File (java.io.File)4 IOException (java.io.IOException)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)4 JobModel (org.apache.airavata.model.job.JobModel)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 ArrayList (java.util.ArrayList)3 JobSubmissionOutput (org.apache.airavata.gfac.core.cluster.JobSubmissionOutput)3 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)3 JobStatus (org.apache.airavata.model.status.JobStatus)3 ProcessState (org.apache.airavata.model.status.ProcessState)3