Search in sources :

Example 51 with TaskState

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

the class SchedulerDBManager method updateTaskData.

private int updateTaskData(final TaskState task, Session session) {
    Query taskUpdateQuery = session.getNamedQuery("updateTaskData");
    TaskInfo taskInfo = task.getTaskInfo();
    return taskUpdateQuery.setParameter("taskStatus", taskInfo.getStatus()).setParameter("numberOfExecutionLeft", taskInfo.getNumberOfExecutionLeft()).setParameter("numberOfExecutionOnFailureLeft", taskInfo.getNumberOfExecutionOnFailureLeft()).setParameter("inErrorTime", taskInfo.getInErrorTime()).setParameter("taskId", taskId(task.getId())).executeUpdate();
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) Query(org.hibernate.Query)

Example 52 with TaskState

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

the class JobDescriptorImpl method isEntryPoint.

/**
 * Tags all startable tasks as entry point
 * a startable task : has no dependency, and is not target of an if control flow action
 *
 * @param t a Task
 * @param otherTasks the other tasks contained in the job containing task t
 * @return true if t is an entry point among all tasks in otherTasks, or false
 */
private boolean isEntryPoint(InternalTask t, List<InternalTask> otherTasks) {
    List<TaskState> deps = t.getDependences();
    boolean entryPoint = false;
    // an entry point has no dependency
    if (deps == null || deps.size() == 0) {
        entryPoint = true;
    } else {
        return false;
    }
    // a entry point is not target of an if
    for (Task t2 : otherTasks) {
        if (t.equals(t2)) {
            continue;
        }
        FlowScript sc = t2.getFlowScript();
        if (sc != null) {
            String actionType = sc.getActionType();
            if (FlowActionType.parse(actionType).equals(FlowActionType.IF)) {
                String tIf = sc.getActionTarget();
                String tElse = sc.getActionTargetElse();
                String tJoin = sc.getActionContinuation();
                if (tIf != null && tIf.equals(t.getName())) {
                    return false;
                }
                if (tElse != null && tElse.equals(t.getName())) {
                    return false;
                }
                if (tJoin != null && tJoin.equals(t.getName())) {
                    return false;
                }
            }
        }
    }
    return entryPoint;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 53 with TaskState

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

the class TestKilledJobResult method test.

@Test
public void test() throws Throwable {
    TaskFlowJob job = new TaskFlowJob();
    JavaTask task1 = new JavaTask();
    task1.setName("task1");
    task1.setExecutableClassName(TestJavaTask1.class.getName());
    job.addTask(task1);
    JavaTask task2 = new JavaTask();
    task2.setName("task2");
    task2.setExecutableClassName(TestJavaTask2.class.getName());
    job.addTask(task2);
    task2.addDependence(task1);
    log("Submit job");
    JobId jobId = schedulerHelper.submitJob(job);
    log("Submitted job " + jobId);
    log("Waiting for task1 to finish");
    schedulerHelper.waitForEventTaskFinished(jobId, "task1");
    schedulerHelper.waitForEventTaskRunning(jobId, "task2");
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    log("Killing job");
    scheduler.killJob(jobId);
    log("Wait when job finishes");
    schedulerHelper.waitForEventJobFinished(jobId);
    JobResult jobResult = scheduler.getJobResult(jobId);
    printResult(jobResult);
    assertEquals(1, jobResult.getAllResults().size());
    assertEquals("OK", jobResult.getAllResults().get("task1").value().toString());
    JobInfo jobInfo = jobResult.getJobInfo();
    assertEquals(JobStatus.KILLED, jobInfo.getStatus());
    assertEquals(1, jobInfo.getNumberOfFinishedTasks());
    assertEquals(2, jobInfo.getTotalNumberOfTasks());
    assertEquals(0, jobInfo.getNumberOfPendingTasks());
    assertEquals(0, jobInfo.getNumberOfRunningTasks());
    JobState state = scheduler.getJobState(jobId);
    assertEquals(JobStatus.KILLED, state.getStatus());
    assertEquals(1, state.getNumberOfFinishedTasks());
    assertEquals(2, state.getTotalNumberOfTasks());
    assertEquals(0, state.getNumberOfPendingTasks());
    assertEquals(0, state.getNumberOfRunningTasks());
    assertEquals(2, state.getTasks().size());
    assertEquals(TaskStatus.FINISHED, findTask(state, "task1").getStatus());
    assertEquals(TaskStatus.ABORTED, findTask(state, "task2").getStatus());
    TaskState taskState0 = state.getTasks().get(0);
    TaskState taskState1 = state.getTasks().get(1);
    assertTrue(taskState0.getStartTime() > 0);
    assertTrue(taskState0.getFinishedTime() > 0);
    assertTrue(taskState0.getExecutionDuration() >= 0);
    assertTrue(taskState0.getExecutionDuration() <= taskState0.getFinishedTime() - taskState0.getStartTime());
    assertTrue(taskState1.getStartTime() > 0);
    assertTrue(taskState1.getFinishedTime() > 0);
    assertTrue(taskState1.getExecutionDuration() >= 0);
    assertTrue(taskState1.getExecutionDuration() <= taskState1.getFinishedTime() - taskState1.getStartTime());
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 54 with TaskState

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

the class RunningTaskRecoveryWithDownNodeTest method checkTasks.

private void checkTasks(JobState jobState) {
    int maximumNumberOfPendingTasks = jobState.getNumberOfPendingTasks();
    for (int i = 0; i < maximumNumberOfPendingTasks; i++) {
        TaskState taskState = jobState.getTasks().get(i);
        TaskStatus taskStatus = taskState.getTaskInfo().getStatus();
        assertThat(taskStatus.equals(TaskStatus.PENDING) || taskStatus.equals(TaskStatus.RUNNING)).isTrue();
    }
}
Also used : TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 55 with TaskState

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

the class SchedulerDBManagerTest method testDatesTaskCentric.

@Test
public void testDatesTaskCentric() throws Throwable {
    int nbJobs = 5;
    int nbTasksPerJob = 10;
    int totalNbTasks = nbJobs * nbTasksPerJob;
    // These only should come up
    actualInternalJobs = createTestJobs("Job-hier", "TAG-HIER", nbJobs, nbTasksPerJob);
    for (InternalJob j : actualInternalJobs) {
        service.submitJob(j);
    }
    // These should NOT come up
    List<InternalJob> todayJobs = createTestJobs("Job-today", "TAG-TODAY", nbJobs, nbTasksPerJob);
    for (InternalJob j : todayJobs) {
        service.submitJob(j);
    }
    for (InternalJob j : actualInternalJobs) {
        j.start();
        j.setStartTime(100L);
        for (InternalTask t : j.getITasks()) {
            t.setStartTime(100L);
            dbManager.jobTaskStarted(j, t, true);
        }
    }
    for (int i = 0; i < todayJobs.size(); i++) {
        terminateJob(i, 500L);
    }
    crit = TaskFilterCriteria.TFCBuilder.newInstance().from(100L).criterias();
    actualPageState = getTaskStates(crit);
    for (TaskState ts : actualPageState.getList()) {
        String taskStr = "Results from criteria:" + ts.getName() + "," + ts.getTag() + "," + String.valueOf(ts.getStartTime()) + "," + String.valueOf(ts.getFinishedTime()) + "," + ts.getStatus();
        System.out.println(taskStr);
    }
    assertEquals("Incorrect tasks list size due to coupled dates from/to", totalNbTasks, actualPageState.getList().size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

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