Search in sources :

Example 1 with BatchQueue

use of org.apache.airavata.model.appcatalog.computeresource.BatchQueue 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)

Aggregations

ArrayList (java.util.ArrayList)1 BatchQueue (org.apache.airavata.model.appcatalog.computeresource.BatchQueue)1 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)1 ValidatorResult (org.apache.airavata.model.error.ValidatorResult)1 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)1