Search in sources :

Example 26 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class TestGenericInformation method testWithReplication.

public void testWithReplication() throws Throwable {
    JobId jobId = schedulerHelper.submitJob(createJobWithReplication());
    SchedulerTHelper.log("Job submitted, id " + jobId.toString());
    schedulerHelper.waitForEventJobFinished(jobId);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    JobState js = scheduler.getJobState(jobId);
    for (TaskState taskState : js.getTasks()) {
        checkTaskState(taskState);
    }
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 27 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class TestTaskIdOrderSameAsDeclarationOrder method task_ids_should_be_ordered_as_task_declaration_order.

@Test
public void task_ids_should_be_ordered_as_task_declaration_order() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    JobState jobState = schedulerHelper.waitForEventJobSubmitted(id);
    List<TaskState> sortedTasksById = sortTasksById(jobState);
    assertEquals("premiere", sortedTasksById.get(0).getName());
    assertEquals("deuxieme", sortedTasksById.get(1).getName());
    assertEquals("troisieme", sortedTasksById.get(2).getName());
    // remove job
    schedulerHelper.waitForEventJobFinished(id);
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) File(java.io.File) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 28 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class TestJobServerLogs method checkNoLogsFromAPI.

private void checkNoLogsFromAPI(JobId jobId, List<TaskState> tasks) throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    try {
        scheduler.getJobServerLogs(jobId.toString());
        fail("getJobServerLogs should throw an exception for a removed job");
    } catch (UnknownJobException expected) {
    }
    for (TaskState taskState : tasks) {
        try {
            scheduler.getTaskServerLogs(jobId.toString(), taskState.getName());
            fail("getTaskServerLogs should throw an exception for a removed job");
        } catch (UnknownJobException expected) {
        }
    }
}
Also used : UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 29 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState 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 30 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class TestJobSchedulingStarvationAndPriority method computeMinMaxStartingTime.

/**
 * Computes min start time and max start time for all tasks which match a given pattern
 * If a task in the set did not start, then the set max will be Long.MAX_VALUE
 */
Pair<Long, Long> computeMinMaxStartingTime(Scheduler scheduler, JobId jobId, String taskNameFilter) throws Exception {
    long min = Long.MAX_VALUE;
    long max = -1;
    for (TaskState state : scheduler.getJobState(jobId).getTasks()) {
        if (state.getName().matches(taskNameFilter)) {
            long startTime = state.getStartTime() > -1 ? state.getStartTime() : Long.MAX_VALUE;
            min = Math.min(min, startTime);
            max = Math.max(max, startTime);
        }
    }
    return new ImmutablePair<>(min, max);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

TaskState (org.ow2.proactive.scheduler.common.task.TaskState)54 JobState (org.ow2.proactive.scheduler.common.job.JobState)23 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)14 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)13 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)12 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)11 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)11 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)10 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)10 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)9 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)9 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)8 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)8 GET (javax.ws.rs.GET)7 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7