Search in sources :

Example 11 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class RegistryServerHandler method getJobStatuses.

/**
 * Get Job Statuses for an Experiment
 * This method to be used when need to get the job status of an Experiment. An experiment may have one or many jobs; there for one or many job statuses may turnup
 *
 * @param airavataExperimentId@return JobStatus
 *                                    Job status (string) for all all the existing jobs for the experiment will be returned in the form of a map
 */
@Override
public Map<String, JobStatus> getJobStatuses(String airavataExperimentId) throws RegistryServiceException, TException {
    try {
        experimentCatalog = RegistryFactory.getDefaultExpCatalog();
        if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
            logger.error(airavataExperimentId, "Error while retrieving job details, experiment {} doesn't exist.", airavataExperimentId);
            throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
        }
        List<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
        Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
        if (processModels != null && !processModels.isEmpty()) {
            for (Object process : processModels) {
                ProcessModel processModel = (ProcessModel) process;
                List<TaskModel> tasks = processModel.getTasks();
                if (tasks != null && !tasks.isEmpty()) {
                    for (TaskModel task : tasks) {
                        String taskId = task.getTaskId();
                        List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
                        if (jobs != null && !jobs.isEmpty()) {
                            for (Object jobObject : jobs) {
                                JobModel jobModel = (JobModel) jobObject;
                                String jobID = jobModel.getJobId();
                                List<JobStatus> status = jobModel.getJobStatuses();
                                if (status != null && status.size() > 0) {
                                    jobStatus.put(jobID, status.get(0));
                                }
                            }
                        }
                    }
                }
            }
        }
        logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
        return jobStatus;
    } catch (Exception e) {
        logger.error(airavataExperimentId, "Error while retrieving the job statuses", e);
        AiravataSystemException exception = new AiravataSystemException();
        exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
        exception.setMessage("Error while retrieving the job statuses. More info : " + e.getMessage());
        throw exception;
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) JobStatus(org.apache.airavata.model.status.JobStatus) JobModel(org.apache.airavata.model.job.JobModel) TaskModel(org.apache.airavata.model.task.TaskModel)

Example 12 with JobStatus

use of org.apache.airavata.model.status.JobStatus 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 13 with JobStatus

use of org.apache.airavata.model.status.JobStatus 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 14 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class CreateLaunchExperiment method main.

public static void main(String[] args) throws Exception {
    airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
    AuthzToken token = new AuthzToken("empty_token");
    System.out.println("API version is " + airavataClient.getAPIVersion(token));
    // registerApplications(); // run this only the first time
    // Map<String, String> master = airavataClient.getAllUserSSHPubKeys(token, "master");
    // System.out.println(master.size());
    Map<String, JobStatus> jobStatuses = airavataClient.getJobStatuses(token, "SLM3-QEspresso-Stampede_dc2af008-a832-4fba-ab0a-4b61fa79f5b9");
    for (String jobId : jobStatuses.keySet()) {
        JobStatus jobStatus = jobStatuses.get(jobId);
        System.out.println(jobId);
        System.out.println(jobStatus.getJobState().toString());
    }
// createAndLaunchExp();
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 15 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class LocalRemoteCluster method cancelJob.

@Override
public JobStatus cancelJob(String jobID) throws GFacException {
    JobStatus oldStatus = getJobStatus(jobID);
    RawCommandInfo cancelCommand = jobManagerConfiguration.getCancelCommand(jobID);
    execute(cancelCommand);
    return oldStatus;
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus)

Aggregations

JobStatus (org.apache.airavata.model.status.JobStatus)20 ArrayList (java.util.ArrayList)6 GFacException (org.apache.airavata.gfac.core.GFacException)5 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)5 JobModel (org.apache.airavata.model.job.JobModel)5 TaskStatus (org.apache.airavata.model.status.TaskStatus)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)4 IOException (java.io.IOException)3 ErrorModel (org.apache.airavata.model.commons.ErrorModel)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2 Set (java.util.Set)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 AiravataException (org.apache.airavata.common.exception.AiravataException)2 JobSubmissionOutput (org.apache.airavata.gfac.core.cluster.JobSubmissionOutput)2 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)2