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