Search in sources :

Example 11 with SchedulerState

use of org.ow2.proactive.scheduler.common.SchedulerState 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 12 with SchedulerState

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

the class SchedulerRuntimeDataMBeanTest method checkDataConsistent.

private void checkDataConsistent(RuntimeDataMBean bean) throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    int pendingJobs = bean.getPendingJobsCount();
    int runningJobs = bean.getRunningJobsCount();
    int finishedJobs = bean.getFinishedJobsCount();
    int totalJobs = bean.getTotalJobsCount();
    int pendingTasks = bean.getPendingTasksCount();
    int runningTasks = bean.getRunningTasksCount();
    int finishedTasks = bean.getFinishedTasksCount();
    int totalTasks = bean.getTotalTasksCount();
    System.out.println("Jobs: pending: " + pendingJobs + ", running: " + runningJobs + " " + ", finished " + finishedJobs + ", total: " + totalJobs);
    System.out.println("Tasks: pending: " + pendingTasks + ", running: " + runningTasks + ", finished " + finishedTasks + ", total " + totalTasks);
    SchedulerState state = scheduler.getState();
    assertEquals(state.getPendingJobs().size(), bean.getPendingJobsCount());
    assertEquals(state.getRunningJobs().size(), bean.getRunningJobsCount());
    assertEquals(state.getFinishedJobs().size(), bean.getFinishedJobsCount());
    assertEquals(bean.getPendingJobsCount() + bean.getRunningJobsCount() + bean.getFinishedJobsCount(), bean.getTotalJobsCount());
    Assert.assertTrue("Invalid pending tasks: " + pendingTasks, pendingTasks >= 0);
    Assert.assertTrue("Invalid running tasks: " + runningTasks, runningTasks >= 0);
    Assert.assertTrue("Invalid finished tasks: " + finishedTasks, finishedTasks >= 0);
}
Also used : SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) Scheduler(org.ow2.proactive.scheduler.common.Scheduler)

Aggregations

SchedulerState (org.ow2.proactive.scheduler.common.SchedulerState)11 JobId (org.ow2.proactive.scheduler.common.job.JobId)6 JobState (org.ow2.proactive.scheduler.common.job.JobState)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)3 Test (org.junit.Test)3 MonitorEventReceiver (functionaltests.monitor.MonitorEventReceiver)2 SchedulerMonitorsHandler (functionaltests.monitor.SchedulerMonitorsHandler)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 UniqueID (org.objectweb.proactive.core.UniqueID)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)1 SchedulerEventListener (org.ow2.proactive.scheduler.common.SchedulerEventListener)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1