Search in sources :

Example 21 with ComputationalResourceSchedulingModel

use of org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel in project airavata by apache.

the class OrchestratorUtils method getLoginUserName.

public static String getLoginUserName(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getLoginUserName())) {
                return userComputeResourcePreference.getLoginUserName();
            } else if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                logger.warn("User computer resource preference doesn't have valid user login name, using computer " + "resource scheduling login name " + processResourceSchedule.getOverrideLoginUserName());
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Either User computer resource preference or computer resource scheduling " + "doesn't have valid user login name, using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideLoginUserName())) {
                return processResourceSchedule.getOverrideLoginUserName();
            } else if (isValid(computeResourcePreference.getLoginUserName())) {
                logger.warn("Process compute resource scheduling doesn't have valid user login name, " + "using  gateway computer resource preference login name " + computeResourcePreference.getLoginUserName());
                return computeResourcePreference.getLoginUserName();
            } else {
                throw new AiravataException("Login name is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch login username", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch login username", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 22 with ComputationalResourceSchedulingModel

use of org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel in project airavata by apache.

the class OrchestratorClientSample method storeExperimentDetail.

/*

    public static void main(String[] args) {
        try {
            AiravataUtils.setExecutionAsClient();
            sysUser = ClientSettings.getSetting(DEFAULT_USER);
            sysUserPwd = ClientSettings.getSetting(DEFAULT_USER_PASSWORD);
            gateway = ClientSettings.getSetting(DEFAULT_GATEWAY);
            orchestratorClient = OrchestratorClientFactory.createOrchestratorClient("localhost", 8940);
            registry = RegistryFactory.getRegistry(gateway, sysUser, sysUserPwd);
            documentCreator = new DocumentCreator(getAiravataAPI());
            documentCreator.createLocalHostDocs();
            documentCreator.createGramDocs();
            documentCreator.createPBSDocsForOGCE();
            storeExperimentDetail();
        } catch (ApplicationSettingsException e) {
            e.printStackTrace();
        } catch (RegistryException e) {
            e.printStackTrace();
        }

    }

    private static AiravataAPI getAiravataAPI() {
        AiravataAPI airavataAPI = null;
            try {
                airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser);
            } catch (AiravataAPIInvocationException e) {
                e.printStackTrace();
            }
        return airavataAPI;
    }
*/
public static void storeExperimentDetail() {
    for (int i = 0; i < NUM_CONCURRENT_REQUESTS; i++) {
        Thread thread = new Thread() {

            public void run() {
                List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
                InputDataObjectType input = new InputDataObjectType();
                input.setName("echo_input");
                input.setType(DataType.STRING);
                input.setValue("echo_output=Hello World");
                exInputs.add(input);
                List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
                OutputDataObjectType output = new OutputDataObjectType();
                output.setName("echo_output");
                output.setType(DataType.STRING);
                output.setValue("");
                exOut.add(output);
                ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, "default", "admin", "echoExperiment", "SimpleEcho2", "SimpleEcho2", exInputs);
                simpleExperiment.setExperimentOutputs(exOut);
                ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.edu", 1, 1, 1, "normal", 0, 0);
                scheduling.setResourceHostId("gsissh-trestles");
                UserConfigurationDataModel userConfigurationDataModel = new UserConfigurationDataModel();
                userConfigurationDataModel.setComputationalResourceScheduling(scheduling);
                simpleExperiment.setUserConfigurationData(userConfigurationDataModel);
                String expId = null;
                try {
                // expId = (String) registry.add(ParentDataType.EXPERIMENT, simpleExperiment);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    orchestratorClient.launchExperiment(expId, "airavataToken");
                } catch (TException e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start();
        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) TException(org.apache.thrift.TException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 23 with ComputationalResourceSchedulingModel

use of org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel in project airavata by apache.

the class DataRetrievalIT method runExperiment.

public String runExperiment(String user, String project) throws ApplicationSettingsException, AiravataClientException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException, ExperimentNotFoundException {
    List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
    InputDataObjectType input = new InputDataObjectType();
    input.setName("echo_input");
    input.setType(DataType.STRING);
    input.setValue("echo_output=Hello World");
    exInputs.add(input);
    List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
    OutputDataObjectType output = new OutputDataObjectType();
    output.setName("echo_output");
    output.setType(DataType.STRING);
    output.setValue("");
    exOut.add(output);
    ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment("default", project, user, "echoExperiment", "SimpleEcho0", "SimpleEcho0", exInputs);
    simpleExperiment.setExperimentOutputs(exOut);
    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("localhost", 1, 1, 1, "normal", 0, 0);
    scheduling.setResourceHostId("localhost");
    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    simpleExperiment.setUserConfigurationData(userConfigurationData);
    Client client = getClient();
    final String expId = client.createExperiment(authzToken, "default", simpleExperiment);
    client.launchExperiment(authzToken, expId, "testToken");
    return expId;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) Client(org.apache.airavata.api.Airavata.Client) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 24 with ComputationalResourceSchedulingModel

use of org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel in project airavata by apache.

the class OrchestratorUtils method getScratchLocation.

public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    try {
        ComputeResourcePreference computeResourcePreference = getComputeResourcePreference(context, gatewayId, processModel.getComputeResourceId());
        ComputationalResourceSchedulingModel processResourceSchedule = processModel.getProcessResourceSchedule();
        if (processModel.isUseUserCRPref()) {
            UsrResourceProfile userResourceProfile = getUserResourceProfile(context);
            UserComputeResourcePreference userComputeResourcePreference = userResourceProfile.getUserComputeResourcePreference(processModel.getUserName(), gatewayId, processModel.getComputeResourceId());
            if (isValid(userComputeResourcePreference.getScratchLocation())) {
                return userComputeResourcePreference.getScratchLocation();
            } else if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                logger.warn("User computer resource preference doesn't have valid scratch location, using computer " + "resource scheduling scratch location " + processResourceSchedule.getOverrideScratchLocation());
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Either User computer resource preference or computer resource scheduling doesn't have " + "valid scratch location, using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        } else {
            if (isValid(processResourceSchedule.getOverrideScratchLocation())) {
                return processResourceSchedule.getOverrideScratchLocation();
            } else if (isValid(computeResourcePreference.getScratchLocation())) {
                logger.warn("Process compute resource scheduling doesn't have valid scratch location, " + "using  gateway computer resource preference scratch location" + computeResourcePreference.getScratchLocation());
                return computeResourcePreference.getScratchLocation();
            } else {
                throw new AiravataException("Scratch location is not found");
            }
        }
    } catch (AppCatalogException e) {
        logger.error("Error occurred while initializing app catalog to fetch scratch location", e);
        throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e);
    }
}
Also used : UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) UserComputeResourcePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 25 with ComputationalResourceSchedulingModel

use of org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel 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

ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)48 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)36 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)35 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)35 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)34 TException (org.apache.thrift.TException)32 AuthzToken (org.apache.airavata.model.security.AuthzToken)28 Project (org.apache.airavata.model.workspace.Project)17 ArrayList (java.util.ArrayList)14 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 ProcessModel (org.apache.airavata.model.process.ProcessModel)4 AiravataException (org.apache.airavata.common.exception.AiravataException)3 DocumentCreatorNew (org.apache.airavata.integration.tools.DocumentCreatorNew)3 BeforeTest (org.testng.annotations.BeforeTest)3 Test (org.testng.annotations.Test)3 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2