Search in sources :

Example 41 with JobState

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

the class TestJobSubmittedParallel method testJobRemoved.

@Test
public void testJobRemoved() throws Throwable {
    final ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
    List<Future<List<JobId>>> futures = new ArrayList<>();
    // submit all jobs
    repeater.accept(THREAD_POOL_SIZE, () -> futures.add(executorService.submit(() -> {
        List<JobId> result = new ArrayList<>();
        repeater.accept(NUMBER_OF_JOBS_PER_THREAD, () -> {
            final JobId jobId = schedulerHelper.submitJob(simpleJob.getPath());
            final JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
            jobState.getId().equals(jobId);
            // call to chech there is no exception thrown
            jobState.getSubmittedTime();
            // call to chech there is no exception thrown
            jobState.isFinished();
            result.add(jobId);
        });
        return result;
    })));
    // wait until all jobs are finished
    List<JobId> allJobId = futures.stream().map(Lambda.silent(Future::get)).flatMap(Collection::stream).collect(Collectors.toList());
    int EXPECTER_NUMBER_OF_JOBS = THREAD_POOL_SIZE * NUMBER_OF_JOBS_PER_THREAD;
    assertEquals(EXPECTER_NUMBER_OF_JOBS, allJobId.size());
    assertEquals(EXPECTER_NUMBER_OF_JOBS, GetTotalJobCount());
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 42 with JobState

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

the class TestPauseJob method test.

@Test
public void test() throws Throwable {
    FileLock fileLock = new FileLock();
    Path fileLockPath = fileLock.lock();
    TaskFlowJob job = createJob(fileLockPath.toString());
    log("Submit job");
    JobId jobId = schedulerHelper.submitJob(job);
    log("Submitted job " + jobId);
    log("Waiting for task1 to start");
    schedulerHelper.waitForEventTaskRunning(jobId, "task1");
    JobState js = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    assertEquals(JobStatus.RUNNING, js.getStatus());
    assertEquals(TaskStatus.RUNNING, getTaskState("task1", js).getStatus());
    assertEquals(TaskStatus.PENDING, getTaskState("task2", js).getStatus());
    log("Pause the job " + jobId);
    schedulerHelper.getSchedulerInterface().pauseJob(jobId);
    js = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    assertEquals(JobStatus.PAUSED, js.getStatus());
    assertEquals(TaskStatus.RUNNING, getTaskState("task1", js).getStatus());
    assertEquals(TaskStatus.PAUSED, getTaskState("task2", js).getStatus());
    // let the task1 finish
    fileLock.unlock();
    log("Checking is the status of task2 remains unchanged");
    Thread.sleep(5000);
    js = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    assertEquals(TaskStatus.PAUSED, getTaskState("task2", js).getStatus());
}
Also used : Path(java.nio.file.Path) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileLock(org.ow2.proactive.scheduler.util.FileLock) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 43 with JobState

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

the class TestPreemptRestartKillTask method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    log(schedulerHelper.getSchedulerInterface().getClass().toString());
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 44 with JobState

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

the class TestPreemptRestartKillTaskSchema33 method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 45 with JobState

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

the class TestTaskNotRestarted method test.

@Test
public void test() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobId jobId = scheduler.submit(createJob());
    JobState jobState;
    schedulerHelper.waitForEventTaskRunning(jobId, "task1");
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.RUNNING, jobState.getTasks().get(0).getStatus());
    scheduler.restartTask(jobId, "task1", Integer.MAX_VALUE);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.WAITING_ON_ERROR, jobState.getTasks().get(0).getStatus());
    scheduler.killJob(jobId);
    jobState = scheduler.getJobState(jobId);
    assertEquals(1, jobState.getTasks().size());
    assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).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)

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