use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestLoadJobs method createJob.
private TaskFlowJob createJob(String communicationObjectUrl, String parentJobId) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.setProjectName(this.getClass().getSimpleName());
if (parentJobId != null) {
job.addGenericInformation(PARENT_JOB_ID, parentJobId);
}
JavaTask javaTask = new JavaTask();
javaTask.setExecutableClassName(TestJavaTask.class.getName());
javaTask.addArgument("fileLockPath", communicationObjectUrl);
javaTask.setName("Test");
job.addTask(javaTask);
return job;
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestUsageData method createJob.
private TaskFlowJob createJob(String name, String... taskNames) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(name);
job.setPriority(JobPriority.IDLE);
for (String taskName : taskNames) {
JavaTask task = new JavaTask();
task.setName(taskName);
task.setExecutableClassName("className");
job.addTask(task);
}
return job;
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestJobRemove method testFullDataRemove1.
@Test
public void testFullDataRemove1() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask task1 = new JavaTask();
task1.setName("task1");
task1.setExecutableClassName(TestDummyExecutable.class.getName());
jobDef.addTask(task1);
InternalJob job = defaultSubmitJob(jobDef);
System.out.println("Remove job");
long start = System.currentTimeMillis();
dbManager.removeJob(job.getId(), 0, true);
System.out.println("Remove time (single task)" + (System.currentTimeMillis() - start));
checkAllEntitiesDeleted();
}
use of org.ow2.proactive.scheduler.common.task.JavaTask 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.task.JavaTask 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());
}
Aggregations