Search in sources :

Example 46 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class TestTaskNotStarted method test.

@Test
public void test() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobId jobId;
    JobState jobState;
    jobId = scheduler.submit(createJob1());
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.SUBMITTED, jobState.getTasks().get(0).getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_STARTED, jobState.getTasks().get(0).getStatus());
    jobId = scheduler.submit(createJob2());
    schedulerHelper.waitForEventJobRunning(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(2, jobState.getTasks().size());
    assertEquals(TaskStatus.PENDING, getTask(jobState, "task2").getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(2, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_STARTED, getTask(jobState, "task2").getStatus());
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 47 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class TestTaskNotExecuted method testTaskNotExecuted.

private void testTaskNotExecuted(String jobDescriptorPath1, String jobDescriptorPath2, String jobDescriptorPath3) throws Exception {
    log("Submitting job 1");
    JobId id1 = schedulerHelper.submitJob(jobDescriptorPath1);
    log("Wait for event job 1 submitted");
    schedulerHelper.waitForEventJobSubmitted(id1);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id1, "t0");
    schedulerHelper.waitForEventTaskFinished(id1, "t0");
    schedulerHelper.waitForEventJobFinished(id1);
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id1, "t1");
    assertTrue(tr1.getException() instanceof TaskCouldNotStartException);
    log("Submitting job 2");
    JobId id2 = schedulerHelper.submitJob(jobDescriptorPath2);
    log("Wait for event job 2 submitted");
    schedulerHelper.waitForEventJobSubmitted(id2);
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id2, "t2");
    log("Restarting task");
    schedulerHelper.getSchedulerInterface().restartTask(id2, "t2", Integer.MAX_VALUE);
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id2, "t2");
    schedulerHelper.getSchedulerInterface().killJob(id2);
    schedulerHelper.waitForEventJobFinished(id2);
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id2);
    Assert.assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id2, "t2");
    assertTrue(tr2.getException() instanceof TaskCouldNotRestartException);
    log("Submitting job 3");
    JobId id3 = schedulerHelper.submitJob(jobDescriptorPath3);
    log("Wait for event job 3 submitted");
    schedulerHelper.waitForEventJobSubmitted(id3);
    log("Wait for event T T1 T2 finished");
    schedulerHelper.waitForEventTaskFinished(id3, "T");
    schedulerHelper.waitForEventTaskFinished(id3, "T1");
    TaskResult tr3_1 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T1");
    TaskResult tr3_2 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T2");
    assertNull(tr3_1.getException());
    assertTrue(tr3_2.getException() instanceof TaskSkippedException);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 48 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class TestJobServerLogs method checkRemoval.

public void checkRemoval(JobId jobId) throws Exception {
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    List<TaskState> tasks = jobState.getTasks();
    checkJobAndTaskLogFiles(jobId, tasks, true);
    // Before it was only job removal but it was bug prone (for pendingJob only)
    // because the following sequence of the events could happen:
    // 1. SchedulerMethodImpl main loop retrieves info about this forever pending job
    // 2. we call removeJob
    // 3. SchedulerMethodImpl main loop asks for RM::getRMNodes.
    // 
    // Third action would print "[SelectionManager.doSelectNodes] "scheduler"..." to the task log
    // which would actually re-created removed log file which would cause an error
    // in the last line of this method
    // that is why kill the job and after wait 5s to make sure that
    // iteration of SchedulerMethodImpl main loop is finished,
    // and finally, we remove job with its log files.
    schedulerHelper.killJob(jobId.value());
    Thread.sleep(5000);
    schedulerHelper.removeJob(jobId);
    schedulerHelper.waitForEventJobRemoved(jobId);
    System.out.println("Suppose to remove all logs at " + simpleDateFormat.format(new Date()));
    checkNoLogsFromAPI(jobId, tasks);
    checkJobAndTaskLogFiles(jobId, tasks, false);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Date(java.util.Date)

Example 49 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class TestMultipleHostsRequest method testMultipleHostsRequest.

@Test
public void testMultipleHostsRequest() throws Throwable {
    String task1Name = "task1";
    switch(OperatingSystem.getOperatingSystem()) {
        case windows:
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePathWindows.toURI()).getAbsolutePath());
            break;
        case unix:
            SchedulerTHelper.setExecutable(new File(executablePath.toURI()).getAbsolutePath());
            // set system Property for executable path
            System.setProperty(executablePathPropertyName, new File(executablePath.toURI()).getAbsolutePath());
            break;
        default:
            throw new IllegalStateException("Unsupported operating system");
    }
    // test submission and event reception
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.addExtraNodes(3);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedState.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    assertEquals(jInfo.getJobId(), id);
    assertEquals(JobStatus.RUNNING, jInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, task1Name);
    TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, task1Name);
    log(schedulerHelper.getSchedulerInterface().getTaskResult(id, "task1").getOutput().getAllLogs(false));
    assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
    schedulerHelper.waitForEventJobFinished(id);
    JobResult res = schedulerHelper.getJobResult(id);
    // check that there is one exception in results
    assertTrue(res.getExceptionResults().isEmpty());
    // remove job
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) File(java.io.File) Test(org.junit.Test)

Example 50 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class SchedulerFrontendState method getJobState.

synchronized JobState getJobState(JobId jobId) throws NotConnectedException, UnknownJobException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
    ClientJobState jobState = jobsMap.get(jobId);
    ClientJobState jobStateCopy;
    synchronized (jobState) {
        try {
            jobStateCopy = (ClientJobState) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(jobState);
        } catch (Exception e) {
            logger.error("Error when copying job state", e);
            throw new IllegalStateException(e);
        }
    }
    return jobStateCopy;
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8