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);
}
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);
}
Aggregations