use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestTaskRuntimeData method testStartJobExecution.
@Test
public void testStartJobExecution() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.addTask(createDefaultTask("task1"));
job.addTask(createDefaultTask("task2"));
job.addTask(createDefaultTask("task3"));
InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task1").getStatus());
Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task2").getStatus());
Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task3").getStatus());
internalJob.start();
InternalTask task = startTask(internalJob, internalJob.getTask("task1"));
System.out.println("Job started");
dbManager.jobTaskStarted(internalJob, task, true);
internalJob = loadInternalJob(true, internalJob.getId());
Assert.assertEquals(TaskStatus.RUNNING, internalJob.getTask("task1").getStatus());
Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task2").getStatus());
Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task3").getStatus());
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestUsageData method finishTask.
private void finishTask(InternalJob job, InternalTask task) throws Exception {
Thread.sleep(10);
TaskResultImpl res = new TaskResultImpl(null, "ok", null, 42);
job.terminateTask(false, task.getId(), null, null, res);
if (job.isFinished()) {
job.terminate();
}
dbManager.updateAfterTaskFinished(job, task, res);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method startJob.
private void startJob(int jobIndex) throws Throwable {
InternalJob startedJob = actualInternalJobs.get(jobIndex);
startedJob.start();
for (InternalTask task : startedJob.getITasks()) {
task.setStatus(TaskStatus.RUNNING);
}
dbManager.updateJobAndTasksState(startedJob);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method createTestJob.
private InternalJob createTestJob(String jobName, String taskTag, int nbTasks) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(jobName);
for (int i = 1; i <= nbTasks; i++) {
JavaTask task = new JavaTask();
task.setName(jobName + "-TASK-" + i + "/" + nbTasks);
task.setExecutableClassName("class");
task.setTag(taskTag);
job.addTask(task);
}
return createJob(job);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method testUpdateTaskState.
@Test
public void testUpdateTaskState() throws Exception {
InternalJob job = createTestJob("test", "tag", 1);
service.submitJob(job);
InternalTask internalTask = job.getITasks().get(0);
internalTask.setStatus(TaskStatus.ABORTED);
dbManager.updateTaskState(internalTask);
Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
assertThat(tasks.getSize()).isEqualTo(1);
TaskState taskState = tasks.getList().get(0);
assertThat(taskState.getStatus()).isEqualTo(TaskStatus.ABORTED);
}
Aggregations