Search in sources :

Example 81 with JobState

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

the class TestLoadSchedulerClientState method testClientStateLoading.

@Test
public void testClientStateLoading() throws Exception {
    TaskFlowJob job1 = new TaskFlowJob();
    job1.setName(this.getClass().getSimpleName());
    job1.setDescription("desc1");
    job1.setProjectName("p1");
    job1.setInputSpace("is1");
    job1.setOutputSpace("os1");
    job1.setMaxNumberOfExecution(22);
    job1.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
    JavaTask task1 = createDefaultTask("task1");
    task1.setDescription("d1");
    task1.setOnTaskError(OnTaskError.CANCEL_JOB);
    task1.setMaxNumberOfExecution(4);
    task1.setPreciousLogs(true);
    task1.setPreciousResult(true);
    task1.setRunAsMe(true);
    task1.setWallTime(440000);
    JavaTask task2 = createDefaultTask("task2");
    task2.setDescription("d2");
    // If it is set to none, the job level behavior will overwrite the task level none behavior.
    task2.setOnTaskError(OnTaskError.NONE);
    task2.setMaxNumberOfExecution(3);
    task2.setPreciousLogs(false);
    task2.setPreciousResult(false);
    task2.setRunAsMe(false);
    task2.setWallTime(240000);
    JavaTask task3 = createDefaultTask("task3");
    task1.addDependence(task2);
    task1.addDependence(task3);
    task2.addDependence(task3);
    job1.addTask(task1);
    job1.addTask(task2);
    job1.addTask(task3);
    job1.setPriority(JobPriority.LOW);
    Map<String, String> genericInfo = new HashMap<>();
    genericInfo.put("p1", "v1");
    genericInfo.put("p2", "v2");
    job1.setGenericInformation(genericInfo);
    InternalJob jobData1 = defaultSubmitJob(job1);
    TaskFlowJob job2 = new TaskFlowJob();
    job2.setName(this.getClass().getSimpleName() + "_2");
    job2.setGenericInformation(new HashMap<String, String>());
    job2.addTask(createDefaultTask("task1"));
    job2.setPriority(JobPriority.HIGH);
    InternalJob jobData2 = defaultSubmitJob(job2);
    System.out.println("Load scheduler client state");
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    SchedulerState state = stateRecoverHelper.recover(-1).getSchedulerState();
    Assert.assertEquals("Unexpected jobs number", 2, state.getPendingJobs().size());
    JobState jobState;
    jobState = checkJobData(state.getPendingJobs(), jobData1.getId(), job1, 3);
    checkTaskData(task1, findTask(jobState, "task1"), "task2", "task3");
    checkTaskData(task2, findTask(jobState, "task2"), "task3");
    checkTaskData(task3, findTask(jobState, "task3"));
    checkJobData(state.getPendingJobs(), jobData2.getId(), job2, 1);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) HashMap(java.util.HashMap) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JobState(org.ow2.proactive.scheduler.common.job.JobState) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 82 with JobState

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

the class TestLoadSchedulerClientState method checkJobData.

private JobState checkJobData(Vector<JobState> jobList, JobId id, TaskFlowJob job, int tasksNumber) {
    for (JobState state : jobList) {
        if (state.getJobInfo().getJobId().equals(id)) {
            Assert.assertEquals(job.getName(), state.getId().getReadableName());
            Assert.assertEquals(job.getName(), state.getName());
            Assert.assertEquals(job.getPriority(), state.getPriority());
            Assert.assertEquals(job.getGenericInformation(), state.getGenericInformation());
            Assert.assertEquals("Unexpected tasks number", tasksNumber, state.getTasks().size());
            Assert.assertEquals(JobType.TASKSFLOW, state.getType());
            Assert.assertEquals(DEFAULT_USER_NAME, state.getOwner());
            Assert.assertEquals(job.getDescription(), state.getDescription());
            Assert.assertEquals(job.getProjectName(), state.getProjectName());
            Assert.assertEquals(job.getInputSpace(), state.getInputSpace());
            Assert.assertEquals(job.getOutputSpace(), state.getOutputSpace());
            Assert.assertEquals(job.getOnTaskErrorProperty().getValue(), state.getOnTaskErrorProperty().getValue());
            Assert.assertEquals(job.getMaxNumberOfExecution(), state.getMaxNumberOfExecution());
            Assert.assertEquals(0, state.getNumberOfFinishedTasks());
            Assert.assertEquals(0, state.getNumberOfRunningTasks());
            Assert.assertEquals(0, state.getNumberOfPendingTasks());
            Assert.assertEquals(tasksNumber, state.getTotalNumberOfTasks());
            return state;
        }
    }
    Assert.fail("Failed to find job " + id);
    return null;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 83 with JobState

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

the class TestTaskIdGeneration method test.

@Test
public void test() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    jobDef.addTask(createDefaultTask("task2"));
    jobDef.addTask(createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, getDefaultCredentials());
    job.setOwner(DEFAULT_USER_NAME);
    dbManager.newJobSubmitted(job);
    for (InternalTask task : job.getITasks()) {
        Assert.assertSame(task, job.getIHMTasks().get(task.getId()));
    }
    for (TaskDescriptor task : job.getJobDescriptor().getEligibleTasks()) {
        Assert.assertNotNull(job.getIHMTasks().get(task.getTaskId()));
    }
    checkIds(job);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState state = recoverHelper.recover(-1);
    Collection<InternalJob> jobs = state.getPendingJobs();
    Assert.assertEquals(1, jobs.size());
    job = jobs.iterator().next();
    checkIds(job);
    JobState jobState = state.getSchedulerState().getPendingJobs().iterator().next();
    checkIds(jobState);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 84 with JobState

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

the class SchedulerRuntimeDataMBeanTest method checkJobData.

private void checkJobData(RuntimeDataMBean bean, JobId jobId) throws Exception {
    JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
    long pendingTime = bean.getJobPendingTime(jobId.value());
    long runningTime = bean.getJobRunningTime(jobId.value());
    assertEquals("Unexpected pending time", jobState.getStartTime() - jobState.getSubmittedTime(), pendingTime);
    assertEquals("Unexpected running time", jobState.getFinishedTime() - jobState.getStartTime(), runningTime);
    assertEquals("Unexpected nodes number", 1, bean.getTotalNumberOfNodesUsed(jobId.value()));
    bean.getMeanTaskPendingTime(jobId.value());
    bean.getMeanTaskRunningTime(jobId.value());
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 85 with JobState

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

the class SchedulerFrontendState method recover.

/**
 * Called to recover the front end state. This method may have to rebuild
 * the different list of userIdentification and job/user association.
 */
private void recover(SchedulerStateImpl sState) {
    Vector<ClientJobState> pendingJobs = sState.getPendingJobs();
    Vector<ClientJobState> runningJobs = sState.getRunningJobs();
    Vector<ClientJobState> finishedJobs = sState.getFinishedJobs();
    // default state = started
    Set<JobState> jobStates = new HashSet<>(pendingJobs.size() + runningJobs.size() + finishedJobs.size());
    if (logger.isInfoEnabled()) {
        logger.info("#Pending jobs: " + pendingJobs.size() + " #Running jobs: " + runningJobs.size() + " #Finished jobs: " + finishedJobs.size());
    }
    for (ClientJobState js : pendingJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : runningJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : finishedJobs) {
        prepare(jobStates, js, true);
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) HashSet(java.util.HashSet)

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