use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestJobRemove method testRuntimeDataRemoveAfterFinish.
@Test
public void testRuntimeDataRemoveAfterFinish() throws Throwable {
TaskFlowJob jobDef = createJob(2);
InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
job.setStatus(JobStatus.FINISHED);
dbManager.updateAfterTaskFinished(job, null, null);
checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
// check can still load task results
Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestJobRemove method removeScenario.
private void removeScenario(int tasksNumber) throws Exception {
TaskFlowJob jobDef = createJob(tasksNumber);
InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
for (int i = 0; i < tasksNumber; i++) {
dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
}
System.out.println("Remove job");
long start = System.currentTimeMillis();
dbManager.removeJob(job.getId(), 0, true);
System.out.println("Remove time (tasks: " + tasksNumber + ")" + (System.currentTimeMillis() - start));
checkAllEntitiesDeleted();
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestJobRemove method testRuntimeDataRemoveAfterFinishParallel.
@Test
public void testRuntimeDataRemoveAfterFinishParallel() throws Throwable {
int THREAD_COUNT = 4;
ExecutorService executorService = Executors.newCachedThreadPool();
List<InternalJob> jobs = new ArrayList<>(THREAD_COUNT);
TaskFlowJob jobDef;
for (int i = 0; i < THREAD_COUNT; i++) {
jobDef = createJob(2);
jobs.add(defaultSubmitJobAndLoadInternal(false, jobDef));
}
for (int i = 0; i < THREAD_COUNT; i++) {
final InternalJob job = jobs.get(i);
executorService.submit(new Runnable() {
@Override
public void run() {
try {
dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
job.setStatus(JobStatus.FINISHED);
dbManager.updateAfterTaskFinished(job, null, null);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
});
}
executorService.shutdown();
executorService.awaitTermination(30, TimeUnit.SECONDS);
for (int i = 0; i < THREAD_COUNT; i++) {
final InternalJob job = jobs.get(i);
List<InternalJob> jobsNotFinished = dbManager.loadNotFinishedJobs(true);
Assert.assertEquals("All jobs should be finished", 0, jobsNotFinished.size());
checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
// check can still load task results
Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
}
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestJobRuntimeData method testJobRuntimeData.
@Test
public void testJobRuntimeData() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.addTask(createDefaultTask("task1"));
job.setPriority(JobPriority.LOW);
System.out.println("Submit and load job");
InternalJob runtimeData = defaultSubmitJobAndLoadInternal(true, job);
Assert.assertEquals(JobStatus.PENDING, runtimeData.getStatus());
Assert.assertEquals(DEFAULT_USER_NAME, runtimeData.getOwner());
Assert.assertEquals(JobPriority.LOW, runtimeData.getPriority());
Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
Assert.assertEquals(1, runtimeData.getTotalNumberOfTasks());
Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
Assert.assertEquals(0, runtimeData.getNumberOfRunningTasks());
Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getName());
Assert.assertNotNull(runtimeData.getCredentials());
Assert.assertEquals(1, runtimeData.getITasks().size());
runtimeData.start();
InternalTask internalTask = startTask(runtimeData, runtimeData.getITasks().get(0));
System.out.println("Update started task data");
dbManager.jobTaskStarted(runtimeData, internalTask, false);
System.out.println("Load internal job");
runtimeData = loadInternalJob(true, runtimeData.getId());
Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getJobInfo().getJobId().getReadableName());
Assert.assertEquals(JobStatus.RUNNING, runtimeData.getStatus());
Assert.assertEquals(1, runtimeData.getNumberOfRunningTasks());
Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
Assert.assertTrue(runtimeData.getStartTime() > 0);
internalTask = runtimeData.getITasks().get(0);
Assert.assertEquals(TaskStatus.RUNNING, internalTask.getStatus());
Assert.assertTrue(internalTask.getStartTime() > 0);
Assert.assertNotNull(internalTask.getExecutionHostName());
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestLoadJobResult method testEmptyResult.
@Test
public void testEmptyResult() throws Throwable {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
JobResult result;
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(0, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
dbManager.updateAfterTaskFinished(job, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(1, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
}
Aggregations