Search in sources :

Example 1 with ValidationResults

use of org.apache.airavata.model.error.ValidationResults in project airavata by apache.

the class ExperimentStatusValidator method validate.

public ValidationResults validate(ExperimentModel experiment, ProcessModel processModel) {
    String error = "During the validation step experiment status should be CREATED, But this experiment status is : ";
    ValidationResults validationResults = new ValidationResults();
    validationResults.setValidationState(true);
    ValidatorResult validatorResult = new ValidatorResult();
    List<ValidatorResult> validatorResultList = new ArrayList<ValidatorResult>();
    if (!experiment.getExperimentStatus().get(0).getState().equals(ExperimentState.CREATED)) {
        error += experiment.getExperimentStatus().get(0).getState().toString();
        log.error(error);
        validatorResult.setErrorDetails(error);
        validatorResult.setResult(false);
        validationResults.setValidationState(false);
    }
    validatorResult.setResult(true);
    validatorResultList.add(validatorResult);
    validationResults.setValidationResultList(validatorResultList);
    return validationResults;
}
Also used : ValidationResults(org.apache.airavata.model.error.ValidationResults) ValidatorResult(org.apache.airavata.model.error.ValidatorResult) ArrayList(java.util.ArrayList)

Example 2 with ValidationResults

use of org.apache.airavata.model.error.ValidationResults in project airavata by apache.

the class SimpleOrchestratorImpl method validateExperiment.

public ValidationResults validateExperiment(ExperimentModel experiment) 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> validatorClasses = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClasses();
        for (String validator : validatorClasses) {
            try {
                Class<? extends JobMetadataValidator> vClass = Class.forName(validator.trim()).asSubclass(JobMetadataValidator.class);
                JobMetadataValidator jobMetadataValidator = vClass.newInstance();
                validationResults = jobMetadataValidator.validate(experiment, null);
                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.EXPERIMENT_ERROR, details, experiment.getExperimentId());
                    } catch (RegistryException e) {
                        logger.error("Error while saving error details to registry", e);
                    }
                    break;
                }
            } catch (ClassNotFoundException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            } catch (InstantiationException e) {
                logger.error("Error loading the validation class: ", validator, e);
                validationResults.setValidationState(false);
            } catch (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 3 with ValidationResults

use of org.apache.airavata.model.error.ValidationResults in project airavata by apache.

the class BatchQueueValidator method validate.

public ValidationResults validate(ExperimentModel experiment, ProcessModel processModel) {
    ValidationResults validationResults = new ValidationResults();
    validationResults.setValidationState(true);
    try {
        List<ValidatorResult> validatorResultList = validateUserConfiguration(experiment, processModel);
        for (ValidatorResult result : validatorResultList) {
            if (!result.isResult()) {
                validationResults.setValidationState(false);
                break;
            }
        }
        validationResults.setValidationResultList(validatorResultList);
    } catch (AppCatalogException e) {
        logger.error("Error while validating user configuration", e);
    }
    return validationResults;
}
Also used : ValidationResults(org.apache.airavata.model.error.ValidationResults) ValidatorResult(org.apache.airavata.model.error.ValidatorResult)

Example 4 with ValidationResults

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

Aggregations

ValidationResults (org.apache.airavata.model.error.ValidationResults)4 ValidatorResult (org.apache.airavata.model.error.ValidatorResult)4 ErrorModel (org.apache.airavata.model.commons.ErrorModel)2 LaunchValidationException (org.apache.airavata.model.error.LaunchValidationException)2 JobMetadataValidator (org.apache.airavata.orchestrator.core.validator.JobMetadataValidator)2 ArrayList (java.util.ArrayList)1