use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class RecoveredSchedulerStateTest method testConstructor.
@Test
public void testConstructor() throws Exception {
int nbJobs = 2;
Vector<InternalJob> pendingJobs = createJobs(JobStatus.PENDING, nbJobs);
Vector<InternalJob> runningJobs = createJobs(JobStatus.RUNNING, nbJobs);
Vector<InternalJob> finishedJobs = createJobs(JobStatus.FINISHED, nbJobs);
RecoveredSchedulerState recoveredState = new RecoveredSchedulerState(pendingJobs, runningJobs, finishedJobs);
assertThat(recoveredState.getPendingJobs()).containsExactlyElementsIn(pendingJobs);
assertThat(recoveredState.getRunningJobs()).containsExactlyElementsIn(runningJobs);
assertThat(recoveredState.getFinishedJobs()).containsExactlyElementsIn(finishedJobs);
SchedulerStateImpl schedulerState = recoveredState.getSchedulerState();
assertThat(schedulerState).isNotNull();
assertThat(schedulerState.getPendingJobs()).hasSize(nbJobs);
assertThat(schedulerState.getRunningJobs()).hasSize(nbJobs);
assertThat(schedulerState.getFinishedJobs()).hasSize(nbJobs);
assertThat(schedulerState.getPendingJobs().get(0)).isInstanceOf(ClientJobState.class);
assertThat(schedulerState.getRunningJobs().get(0)).isInstanceOf(ClientJobState.class);
assertThat(schedulerState.getFinishedJobs().get(0)).isInstanceOf(ClientJobState.class);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithMixedJobs.
@Test
public void testRecoverWithMixedJobs() throws Exception {
ImmutableList<JobStatus> jobStatuses = ImmutableList.of(JobStatus.CANCELED, JobStatus.FAILED, JobStatus.FINISHED, JobStatus.KILLED, JobStatus.PAUSED, JobStatus.PENDING, JobStatus.RUNNING, JobStatus.STALLED);
ImmutableList<TaskStatus> taskStatuses = ImmutableList.of(TaskStatus.ABORTED, TaskStatus.FAILED, TaskStatus.FINISHED, TaskStatus.ABORTED, TaskStatus.PAUSED, TaskStatus.PENDING, TaskStatus.RUNNING, TaskStatus.SUBMITTED);
List<InternalJob> jobs = new ArrayList<>(jobStatuses.size());
for (int i = 0; i < jobStatuses.size(); i++) {
InternalJob job = createJob(jobStatuses.get(i));
jobs.add(job);
changeTasksState(job, taskStatuses.get(i));
}
RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
assertThat(recoveredState.getFinishedJobs()).hasSize(4);
assertThat(recoveredState.getPendingJobs()).hasSize(2);
assertThat(recoveredState.getRunningJobs()).hasSize(2);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithStalledJobOnly.
@Test
public void testRecoverWithStalledJobOnly() throws Exception {
InternalJob job = createJob(JobStatus.STALLED);
changeTasksState(job, TaskStatus.PENDING);
ImmutableMap<String, TaskStatus> taskStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.SKIPPED, "Tc", TaskStatus.PENDING);
changeTasksState(job, taskStatus);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
job = recoveredState.getRunningJobs().get(0);
assertThat(job.getStatus()).isEqualTo(JobStatus.STALLED);
assertTasksStatus(job, taskStatus);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithRunningJobOnlyAllTasksSameStatus.
@Test
public void testRecoverWithRunningJobOnlyAllTasksSameStatus() throws Exception {
InternalJob job = createJob(JobStatus.RUNNING);
changeTasksState(job, TaskStatus.RUNNING);
RecoveredSchedulerState recoveredState = new Scenario(job).execute();
job = recoveredState.getRunningJobs().get(0);
assertThat(job.getStatus()).isEqualTo(JobStatus.STALLED);
assertTasksStatus(job, TaskStatus.RUNNING);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method changeTasksState.
private void changeTasksState(InternalJob job, Map<String, TaskStatus> newStatuses) {
int nbPending = 0;
int nbRunning = 0;
int nbFinished = 0;
for (InternalTask internalTask : job.getITasks()) {
TaskStatus newStatus = newStatuses.get(internalTask.getName());
if (newStatus != null) {
internalTask.setStatus(newStatus);
}
switch(internalTask.getStatus()) {
case PENDING:
nbPending++;
break;
case RUNNING:
nbRunning++;
break;
case FINISHED:
nbFinished++;
break;
}
}
updateJobCounters(job, nbPending, nbRunning, nbFinished);
}
Aggregations