Search in sources :

Example 16 with TaskState

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

the class LiveJobs method restartAllInErrorTasks.

public Boolean restartAllInErrorTasks(JobId jobId) {
    JobData jobData = lockJob(jobId);
    if (jobData == null) {
        return false;
    }
    try {
        InternalJob job = jobData.job;
        for (TaskState taskState : job.getTasks()) {
            try {
                restartInErrorTask(jobId, taskState.getName());
            } catch (UnknownTaskException e) {
                logger.error("", e);
                jlogger.error(jobId, "", e);
                tlogger.error(taskState.getId(), "", e);
            }
        }
        setJobStatusToInErrorIfNotPaused(job);
        dbManager.updateJobAndTasksState(job);
        updateJobInSchedulerState(job, SchedulerEvent.JOB_RESTARTED_FROM_ERROR);
        return Boolean.TRUE;
    } finally {
        jobData.unlock();
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 17 with TaskState

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

the class SchedulerFrontendState method getTaskState.

synchronized TaskState getTaskState(JobId jobId, TaskId taskId) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
    if (jobsMap.get(jobId) == null) {
        throw new UnknownJobException(jobId);
    }
    JobState jobState = jobsMap.get(jobId);
    synchronized (jobState) {
        TaskState ts = jobState.getHMTasks().get(taskId);
        if (ts == null) {
            throw new UnknownTaskException(taskId, jobId);
        }
        return ts;
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 18 with TaskState

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

the class TaskData method toTaskState.

public TaskState toTaskState() {
    TaskInfo taskInfo = toTaskInfo();
    TaskStateImpl taskState = new TaskStateImpl();
    taskState.update(taskInfo);
    taskState.setName(getTaskName());
    taskState.setDescription(getDescription());
    taskState.setTag(getTag());
    taskState.setIterationIndex(getIteration());
    taskState.setReplicationIndex(getReplication());
    taskState.setMaxNumberOfExecution(getMaxNumberOfExecution());
    taskState.setParallelEnvironment(getParallelEnvironment());
    taskState.setGenericInformation(getGenericInformation());
    taskState.setVariables(variablesToTaskVariables());
    return taskState;
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskStateImpl(org.ow2.proactive.scheduler.task.TaskStateImpl)

Example 19 with TaskState

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

the class TestLicensePolicy method testLicensePolicy.

/**
 * Tests that two independent tasks do not run at the same time, due to license limitation.
 *
 * @throws Exception
 */
@Test
public void testLicensePolicy() throws Throwable {
    JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    log("Waiting for job finished");
    schedulerHelper.waitForEventJobFinished(jobId);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    TaskState taskState0 = scheduler.getJobState(jobId).getTasks().get(0);
    TaskState taskState1 = scheduler.getJobState(jobId).getTasks().get(1);
    boolean tasksExecutedOneByOne = (taskState0.getFinishedTime() < taskState1.getStartTime()) || (taskState1.getFinishedTime() < taskState0.getStartTime());
    Assert.assertTrue(tasksExecutedOneByOne);
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) 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 20 with TaskState

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

the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method action.

@Test
public void action() throws Throwable {
    nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWhenNodesAreReservedInBatchTest.class.getSimpleName(), NB_NODES);
    for (int i = 0; i < NB_NODES; i++) {
        schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    }
    JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
    schedulerHelper.waitForEventJobRunning(jobid);
    schedulerHelper.waitForEventTaskFinished(jobid, "Groovy_Task");
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobid);
    SchedulerTHelper.log("Total number of tasks: " + jobState.getTotalNumberOfTasks());
    List<TaskState> tasks = jobState.getTasks();
    TaskState fifthTask = tasks.get(5);
    SchedulerTHelper.log("Wait for the fifth task running");
    // we wait for the fifth task to be running so that when we kill the
    // scheduler we have a mix of pending/submitted/running tasks
    schedulerHelper.waitForEventTaskRunning(fifthTask.getJobId(), fifthTask.getName());
    SchedulerTHelper.log("Fifth task is running");
    // restart scheduler
    printRmStateAndReturnNotFreeNodeNumber();
    printJobStateAndReturnNumberOfRunningTasks(jobid);
    TestScheduler.kill();
    schedulerHelper = new SchedulerTHelper(false, new File(SCHEDULER_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
    SchedulerTHelper.log("Wait for job to finish");
    JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(jobid);
    assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(0);
    assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(0);
    // wait for all nodes released
    while (printRmStateAndReturnNotFreeNodeNumber() != 0) {
        schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    }
    // all nodes should be free now
    int notFreeNodeNumber = printRmStateAndReturnNotFreeNodeNumber();
    assertThat(notFreeNodeNumber).isEqualTo(0);
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) 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)

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