Search in sources :

Example 6 with ComputationalResourceSchedulingModel

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

the class BaseCaseIT method testEchoService.

// @Test(groups = {"setupTests"}, dependsOnMethods = {"testSetup"})
// public void testURLs() throws AiravataAPIInvocationException {
// URI eventingServiceURL = this.airavataAPI.getAiravataManager().getEventingServiceURL();
// Assert.assertNotNull(eventingServiceURL);
// 
// URI messageBoxServiceURL = this.airavataAPI.getAiravataManager().getMessageBoxServiceURL();
// Assert.assertNotNull(messageBoxServiceURL);
// }
@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoService() throws Exception {
    log.info("Running job in trestles...");
    DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
    documentCreator.createPBSDocsForOGCE_Echo();
    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);
    Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
    String projectId = getClient().createProject(authzToken, "default", project);
    ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayName, projectId, "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 userConfigurationData = new UserConfigurationDataModel();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    simpleExperiment.setUserConfigurationData(userConfigurationData);
    final String expId = createExperiment(simpleExperiment);
    System.out.println("Experiment Id returned : " + expId);
    log.info("Experiment Id returned : " + expId);
    launchExperiment(expId);
    System.out.println("Launched successfully");
    Thread monitor = (new Thread() {

        public void run() {
            Map<String, JobStatus> jobStatuses = null;
            while (true) {
                try {
                    jobStatuses = client.getJobStatuses(authzToken, expId);
                    Set<String> strings = jobStatuses.keySet();
                    for (String key : strings) {
                        JobStatus jobStatus = jobStatuses.get(key);
                        if (jobStatus == null) {
                            return;
                        } else {
                            if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
                                log.info("Job completed Job ID: " + key);
                                return;
                            } else {
                                log.info("Job ID:" + key + "  Job Status : " + jobStatuses.get(key).getJobState().toString());
                            }
                        }
                    }
                    Thread.sleep(5000);
                } catch (Exception e) {
                    log.error("Thread interrupted", e.getMessage());
                }
            }
        }
    });
    monitor.start();
    try {
        monitor.join();
    } catch (InterruptedException e) {
        log.error("Thread interrupted..", e.getMessage());
    }
}
Also used : Set(java.util.Set) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) JobStatus(org.apache.airavata.model.status.JobStatus) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) DocumentCreatorNew(org.apache.airavata.integration.tools.DocumentCreatorNew) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) Map(java.util.Map) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with ComputationalResourceSchedulingModel

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

the class BaseCaseIT method testEchoServiceStampede.

@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoServiceStampede() throws Exception {
    log.info("Running job in Stampede...");
    DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
    documentCreator.createSlurmDocs();
    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);
    Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
    String projectId = getClient().createProject(authzToken, "default", project);
    ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayName, projectId, "admin", "echoExperiment", "SimpleEcho3", "SimpleEcho3", exInputs);
    simpleExperiment.setExperimentOutputs(exOut);
    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("stampede.tacc.xsede.org", 1, 1, 1, "normal", 0, 0);
    scheduling.setResourceHostId("stampede-host");
    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    simpleExperiment.setUserConfigurationData(userConfigurationData);
    final String expId = createExperiment(simpleExperiment);
    System.out.println("Experiment Id returned : " + expId);
    log.info("Experiment Id returned : " + expId);
    launchExperiment(expId);
    System.out.println("Launched successfully");
    Thread monitor = (new Thread() {

        public void run() {
            Map<String, JobStatus> jobStatuses = null;
            while (true) {
                try {
                    jobStatuses = client.getJobStatuses(authzToken, expId);
                    Set<String> strings = jobStatuses.keySet();
                    for (String key : strings) {
                        JobStatus jobStatus = jobStatuses.get(key);
                        if (jobStatus == null) {
                            return;
                        } else {
                            if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
                                log.info("Job completed Job ID: " + key);
                                return;
                            } else {
                                log.info("Job ID:" + key + "  Job Status : " + jobStatuses.get(key).getJobState().toString());
                            }
                        }
                    }
                    Thread.sleep(5000);
                } catch (Exception e) {
                    log.error("Thread interrupted", e.getMessage());
                }
            }
        }
    });
    monitor.start();
    try {
        monitor.join();
    } catch (InterruptedException e) {
        log.error("Thread interrupted..", e.getMessage());
    }
}
Also used : Set(java.util.Set) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) JobStatus(org.apache.airavata.model.status.JobStatus) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) DocumentCreatorNew(org.apache.airavata.integration.tools.DocumentCreatorNew) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) Map(java.util.Map) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with ComputationalResourceSchedulingModel

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

the class ExperimentRegistry method updateUserConfigDataField.

public void updateUserConfigDataField(String expID, String fieldName, Object value) throws RegistryException {
    try {
        ExperimentResource experiment = new ExperimentResource();
        experiment.setExperimentId(expID);
        UserConfigurationDataResource exConfigData = (UserConfigurationDataResource) experiment.get(ResourceType.USER_CONFIGURATION_DATA, expID);
        if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.AIRAVATA_AUTO_SCHEDULE)) {
            exConfigData.setAiravataAutoSchedule((Boolean) value);
            exConfigData.save();
        } else if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.OVERRIDE_MANUAL_PARAMS)) {
            exConfigData.setOverrideManualScheduledParams((Boolean) value);
            exConfigData.save();
        } else if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.SHARE_EXP)) {
            exConfigData.setShareExperimentPublically((Boolean) value);
            exConfigData.save();
        } else if (fieldName.equals(Constants.FieldConstants.UserConfigurationDataConstants.COMPUTATIONAL_RESOURCE_SCHEDULING)) {
            updateComputeResourceScheduling((ComputationalResourceSchedulingModel) value, expID);
        } else {
            logger.error("Unsupported field type for Experiment config data");
        }
    } catch (Exception e) {
        logger.error("Error while updating fields in experiment config...", e);
        throw new RegistryException(e);
    }
}
Also used : ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 9 with ComputationalResourceSchedulingModel

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

the class ThriftDataModelConversion method getProcessModel.

public static ProcessModel getProcessModel(ProcessResource processResource) throws RegistryException {
    if (processResource != null) {
        ProcessModel processModel = new ProcessModel();
        processModel.setProcessId(processResource.getProcessId());
        processModel.setExperimentId(processResource.getExperimentId());
        processModel.setCreationTime(processResource.getCreationTime().getTime());
        processModel.setLastUpdateTime(processResource.getLastUpdateTime().getTime());
        processModel.setProcessDetail(processResource.getProcessDetail());
        processModel.setApplicationInterfaceId(processResource.getApplicationInterfaceId());
        processModel.setTaskDag(processResource.getTaskDag());
        processModel.setGatewayExecutionId(processResource.getGatewayExecutionId());
        processModel.setApplicationDeploymentId(processResource.getApplicationDeploymentId());
        processModel.setComputeResourceId(processResource.getComputeResourceId());
        processModel.setEnableEmailNotification(processResource.getEnableEmailNotification());
        processModel.setExperimentDataDir(processResource.getExperimentDataDir());
        processModel.setUseUserCRPref(processResource.isUseUserCRPref());
        if (processModel.isEnableEmailNotification()) {
            String notificationEmails = processResource.getEmailAddresses();
            processModel.setEmailAddresses(getEmailAddresses(notificationEmails.split(",")));
        }
        processModel.setProcessInputs(getProcessInputs(processResource.getProcessInputs()));
        processModel.setProcessOutputs(getProcessOutputs(processResource.getProcessOutputs()));
        ErrorModel errorModel = getErrorModel(processResource.getProcessError());
        if (errorModel != null) {
            List<ErrorModel> errorModels = new ArrayList<>();
            errorModels.add(errorModel);
            processModel.setProcessErrors(errorModels);
        }
        ProcessStatus processStatus = getProcessStatus(processResource.getProcessStatus());
        if (processStatus != null) {
            List<ProcessStatus> statuses = new ArrayList<>();
            statuses.add(processStatus);
            processModel.setProcessStatuses(statuses);
        }
        ComputationalResourceSchedulingModel schedule = getProcessResourceSchedule(processResource.getProcessResourceSchedule());
        if (schedule != null) {
            processModel.setProcessResourceSchedule(schedule);
        }
        processModel.setTasks(getTaskModelList(processResource.getTaskList()));
        processModel.setStorageResourceId(processResource.getStorageResourceId());
        processModel.setUserDn(processResource.getUserDn());
        processModel.setGenerateCert(processResource.isGenerateCert());
        processModel.setUserName(processResource.getUserName());
        return processModel;
    }
    return null;
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) ArrayList(java.util.ArrayList) ErrorModel(org.apache.airavata.model.commons.ErrorModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 10 with ComputationalResourceSchedulingModel

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

the class ThriftDataModelConversion method getProcessResourceSchedule.

public static ComputationalResourceSchedulingModel getProcessResourceSchedule(ProcessResourceScheduleResource resource) {
    if (resource != null) {
        ComputationalResourceSchedulingModel resourceSchedulingModel = new ComputationalResourceSchedulingModel();
        resourceSchedulingModel.setResourceHostId(resource.getResourceHostId());
        resourceSchedulingModel.setTotalCPUCount(resource.getTotalCpuCount());
        resourceSchedulingModel.setNodeCount(resource.getNodeCount());
        resourceSchedulingModel.setNumberOfThreads(resource.getNumberOfThreads());
        resourceSchedulingModel.setQueueName(resource.getQueueName());
        resourceSchedulingModel.setWallTimeLimit(resource.getWallTimeLimit());
        resourceSchedulingModel.setTotalPhysicalMemory(resource.getTotalPhysicalMemory());
        resourceSchedulingModel.setStaticWorkingDir(resource.getStaticWorkingDir());
        resourceSchedulingModel.setOverrideLoginUserName(resource.getOverrideLoginUserName());
        resourceSchedulingModel.setOverrideScratchLocation(resource.getOverrideScratchLocation());
        resourceSchedulingModel.setOverrideAllocationProjectNumber(resource.getOverrideAllocationProjectNumber());
        return resourceSchedulingModel;
    }
    return null;
}
Also used : 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