Search in sources :

Example 56 with TaskState

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

the class SchedulerDBManagerTest method testUpdateJobAndTasksState.

@Test
public void testUpdateJobAndTasksState() throws Exception {
    InternalJob job = createTestJob("test", "tag", 1);
    service.submitJob(job);
    job.setStatus(JobStatus.KILLED);
    job.setNumberOfFailedTasks(2);
    job.setNumberOfFaultyTasks(3);
    job.setNumberOfInErrorTasks(5);
    job.setInErrorTime(7);
    InternalTask internalTask = job.getITasks().get(0);
    internalTask.setStatus(TaskStatus.IN_ERROR);
    internalTask.setInErrorTime(11);
    dbManager.updateJobAndTasksState(job);
    Page<JobInfo> jobs = dbManager.getJobs(0, 10, null, true, true, true, null);
    assertThat(jobs.getSize()).isEqualTo(1);
    JobInfo jobInfo = jobs.getList().get(0);
    assertThat(jobInfo.getStatus()).isEqualTo(JobStatus.KILLED);
    assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(2);
    assertThat(jobInfo.getNumberOfFaultyTasks()).isEqualTo(3);
    assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(5);
    assertThat(jobInfo.getInErrorTime()).isEqualTo(7);
    Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
    assertThat(tasks.getSize()).isEqualTo(1);
    TaskState taskState = tasks.getList().get(0);
    assertThat(taskState.getStatus()).isEqualTo(TaskStatus.IN_ERROR);
    assertThat(taskState.getTaskInfo().getInErrorTime()).isEqualTo(11);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 57 with TaskState

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

the class SchedulerDBManagerTest method assertTaskStatePage.

private void assertTaskStatePage(Page<TaskState> page, TaskFilterCriteria criterias) {
    int nbTaskStates = page.getList().size();
    for (TaskState taskState : page.getList()) {
        String tag = criterias.getTag();
        if (tag != null)
            assertEquals("Tag is incorrect", tag, taskState.getTag());
        // from
        long from = criterias.getFrom();
        if (from != 0)
            assertEquals("startTime is incorrect", from, taskState.getStartTime());
        // to
        long to = criterias.getTo();
        if (to != 0)
            assertEquals("finishedTime is incorrect", to, taskState.getFinishedTime());
        // pagination
        int pageSize = criterias.getLimit() - criterias.getOffset();
        if (pageSize > 0) {
            assertTrue("Page size is incorrect", pageSize >= nbTaskStates);
        }
        // user
        String expectedUser = criterias.getUser();
        String actualUser = taskState.getTaskInfo().getJobInfo().getJobOwner();
        if (expectedUser != null && "".compareTo(expectedUser) != 0) {
            assertEquals("user is incorrect", expectedUser, actualUser);
        }
        // the corresponding criteria should be true
        switch(taskState.getStatus()) {
            case SUBMITTED:
            case PENDING:
            case NOT_STARTED:
                assertTrue("Task status is incorrect", criterias.isPending());
                break;
            case PAUSED:
            case RUNNING:
            case WAITING_ON_ERROR:
            case WAITING_ON_FAILURE:
                assertTrue("Task status is incorrect", criterias.isRunning());
                break;
            case FAILED:
            case NOT_RESTARTED:
            case ABORTED:
            case FAULTY:
            case FINISHED:
            case SKIPPED:
                assertTrue("Task status is incorrect", criterias.isFinished());
                break;
            default:
                fail("Incoherent task status");
        }
    }
}
Also used : TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 58 with TaskState

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

the class TestLoadSchedulerClientState method checkTaskData.

private void checkTaskData(JavaTask expected, TaskState taskState, String... dependences) {
    Assert.assertEquals(expected.getName(), taskState.getName());
    Assert.assertEquals(expected.getDescription(), taskState.getDescription());
    Assert.assertEquals(expected.getName(), taskState.getTaskInfo().getTaskId().getReadableName());
    Assert.assertEquals(expected.getOnTaskErrorProperty().getValue(), taskState.getOnTaskErrorProperty().getValue());
    Assert.assertEquals(expected.getMaxNumberOfExecution(), taskState.getMaxNumberOfExecution());
    Assert.assertEquals(expected.isPreciousLogs(), taskState.isPreciousLogs());
    Assert.assertEquals(expected.isPreciousResult(), taskState.isPreciousResult());
    Assert.assertEquals(expected.isRunAsMe(), taskState.isRunAsMe());
    Assert.assertEquals(expected.getWallTime(), taskState.getWallTime());
    Assert.assertEquals("Unexpected number of dependencies", dependences.length, taskState.getDependences().size());
    Set<String> dependenciesSet = new HashSet<>();
    for (String dependecy : dependences) {
        dependenciesSet.add(dependecy);
    }
    Set<String> actualDependenciesSet = new HashSet<>();
    for (TaskState task : taskState.getDependences()) {
        actualDependenciesSet.add(task.getName());
    }
    Assert.assertEquals("Unexpected dependencies", dependenciesSet, actualDependenciesSet);
}
Also used : TaskState(org.ow2.proactive.scheduler.common.task.TaskState) HashSet(java.util.HashSet)

Example 59 with TaskState

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

the class SchedulerFrontend method getTaskResultsByTag.

@Override
@ImmediateService
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
    frontendState.checkPermission("getTaskResultByTag", YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
    ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
    for (TaskState currentState : taskStates) {
        String taskName = currentState.getTaskInfo().getName();
        try {
            TaskResult currentResult = getTaskResult(jobId, taskName);
            results.add(currentResult);
        } catch (UnknownTaskException ex) {
            // never occurs because tasks are filtered by tag so they cannot
            // be unknown.
            logger.warn("Unknown task.", ex);
        }
    }
    return results;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) ArrayList(java.util.ArrayList) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 60 with TaskState

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

the class SchedulerFrontend method getTaskServerLogsByTag.

@Override
@ImmediateService
public String getTaskServerLogsByTag(String jobId, String taskTag) throws UnknownJobException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getTaskServerLogsByTag", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
    List<TaskState> lTaskState = frontendState.getJobState(id).getTasksByTag(taskTag);
    Set<TaskId> tasksIds = new HashSet<>(lTaskState.size());
    for (TaskState taskState : lTaskState) {
        tasksIds.add(taskState.getId());
    }
    return ServerJobAndTaskLogs.getJobLog(id, tasksIds);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) HashSet(java.util.HashSet) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

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