Search in sources :

Example 1 with ValidatorResult

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

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

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

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

the class BatchQueueValidator method validateUserConfiguration.

private List<ValidatorResult> validateUserConfiguration(ExperimentModel experiment, ProcessModel processModel) throws AppCatalogException {
    List<ValidatorResult> validatorResultList = new ArrayList<ValidatorResult>();
    try {
        UserConfigurationDataModel userConfigurationData = experiment.getUserConfigurationData();
        ComputationalResourceSchedulingModel computationalResourceScheduling = userConfigurationData.getComputationalResourceScheduling();
        if (userConfigurationData.isAiravataAutoSchedule()) {
            logger.info("User enabled Auto-Schedule. Hence we don't do validation..");
            ValidatorResult validatorResult = new ValidatorResult();
            validatorResult.setResult(true);
            validatorResultList.add(validatorResult);
        } else {
            ComputeResourceDescription computeResource;
            if (processModel == null) {
                computeResource = appCatalog.getComputeResource().getComputeResource(experiment.getUserConfigurationData().getComputationalResourceScheduling().getResourceHostId());
            } else {
                computeResource = appCatalog.getComputeResource().getComputeResource(processModel.getProcessResourceSchedule().getResourceHostId());
            }
            List<BatchQueue> batchQueues = computeResource.getBatchQueues();
            if (batchQueues != null && !batchQueues.isEmpty()) {
                if (computationalResourceScheduling != null) {
                    String experimentQueueName = computationalResourceScheduling.getQueueName().trim();
                    int experimentWallTimeLimit = computationalResourceScheduling.getWallTimeLimit();
                    int experimentNodeCount = computationalResourceScheduling.getNodeCount();
                    int experimentCPUCount = computationalResourceScheduling.getTotalCPUCount();
                    ValidatorResult queueNameResult = new ValidatorResult();
                    // Set the validation to false. Once all the queue's are looped, if nothing matches, then this gets passed.
                    queueNameResult.setResult(false);
                    queueNameResult.setErrorDetails("The specified queue " + experimentQueueName + " does not exist. If you believe this is an error, contact the administrator to verify App-Catalog Configurations");
                    for (BatchQueue queue : batchQueues) {
                        String resourceQueueName = queue.getQueueName();
                        int maxQueueRunTime = queue.getMaxRunTime();
                        int maxNodeCount = queue.getMaxNodes();
                        int maxcpuCount = queue.getMaxProcessors();
                        if (resourceQueueName != null && resourceQueueName.equals(experimentQueueName)) {
                            queueNameResult.setResult(true);
                            queueNameResult.setErrorDetails("");
                            // Validate if the specified wall time is within allowable limit
                            ValidatorResult wallTimeResult = new ValidatorResult();
                            if (experimentWallTimeLimit == 0) {
                                wallTimeResult.setResult(false);
                                wallTimeResult.setErrorDetails("Walltime cannot be zero for queue " + resourceQueueName);
                            } else {
                                if (maxQueueRunTime == 0) {
                                    wallTimeResult.setResult(true);
                                    wallTimeResult.setErrorDetails("Maximum wall time is not configured for the queue," + "Validation is being skipped");
                                    logger.info("Maximum wall time is not configured for the queue" + "Validation is being skipped");
                                } else {
                                    if (maxQueueRunTime < experimentWallTimeLimit) {
                                        wallTimeResult.setResult(false);
                                        wallTimeResult.setErrorDetails("Job Execution walltime " + experimentWallTimeLimit + "exceeds the allowable walltime" + maxQueueRunTime + "for queue " + resourceQueueName);
                                    } else {
                                        wallTimeResult.setResult(true);
                                        wallTimeResult.setErrorDetails("");
                                    }
                                }
                            }
                            // validate max node count
                            ValidatorResult nodeCountResult = new ValidatorResult();
                            if (maxNodeCount == 0) {
                                nodeCountResult.setResult(true);
                                nodeCountResult.setErrorDetails("Max node count is not configured for the queue," + "Validation is being skipped");
                                logger.info("Max node count is not configured for the queue" + "Validation is being skipped");
                            } else {
                                if (experimentNodeCount == 0) {
                                    nodeCountResult.setResult(false);
                                    nodeCountResult.setErrorDetails("Job Execution node count cannot be zero for queue " + resourceQueueName);
                                } else {
                                    if (maxNodeCount < experimentNodeCount) {
                                        nodeCountResult.setResult(false);
                                        nodeCountResult.setErrorDetails("Job Execution node count " + experimentNodeCount + "exceeds the allowable node count" + maxNodeCount + "for queue " + resourceQueueName);
                                    } else {
                                        nodeCountResult.setResult(true);
                                        nodeCountResult.setErrorDetails("");
                                    }
                                }
                            }
                            // validate cpu count
                            ValidatorResult cpuCountResult = new ValidatorResult();
                            if (maxcpuCount == 0) {
                                cpuCountResult.setResult(true);
                                cpuCountResult.setErrorDetails("Max cpu count is not configured for the queue," + "Validation is being skipped");
                                logger.info("Max cpu count is not configured for the queue" + "Validation is being skipped");
                            } else {
                                if (experimentCPUCount == 0) {
                                    cpuCountResult.setResult(false);
                                    cpuCountResult.setErrorDetails("Job Execution cpu count cannot be zero for queue " + resourceQueueName);
                                } else {
                                    if (maxcpuCount < experimentCPUCount) {
                                        cpuCountResult.setResult(false);
                                        cpuCountResult.setErrorDetails("Job Execution cpu count " + experimentCPUCount + "exceeds the allowable cpu count" + maxcpuCount + "for queue " + resourceQueueName);
                                    } else {
                                        cpuCountResult.setResult(true);
                                        cpuCountResult.setErrorDetails("");
                                    }
                                }
                            }
                            validatorResultList.add(wallTimeResult);
                            validatorResultList.add(nodeCountResult);
                            validatorResultList.add(cpuCountResult);
                        }
                    }
                    validatorResultList.add(queueNameResult);
                }
            } else {
                // for some compute resources, you dnt need to specify queue names
                ValidatorResult result = new ValidatorResult();
                logger.info("There are not queues defined under the compute resource. Airavata assumes this experiment " + "does not need a queue name...");
                result.setResult(true);
                validatorResultList.add(result);
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error while getting information from App catalog", e);
        throw new AppCatalogException("Error while getting information from App catalog", e);
    }
    return validatorResultList;
}
Also used : ValidatorResult(org.apache.airavata.model.error.ValidatorResult) BatchQueue(org.apache.airavata.model.appcatalog.computeresource.BatchQueue) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ArrayList(java.util.ArrayList) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 5 with ValidatorResult

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

ValidatorResult (org.apache.airavata.model.error.ValidatorResult)5 ValidationResults (org.apache.airavata.model.error.ValidationResults)4 ArrayList (java.util.ArrayList)2 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 BatchQueue (org.apache.airavata.model.appcatalog.computeresource.BatchQueue)1 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)1 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)1