use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestDataspaceSelectorsData method testSelectors.
@Test
public void testSelectors() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask task = createDefaultTask("task1");
Set<String> inInclude1 = Sets.newHashSet("inInclude1_1", "inInclude1_2");
Set<String> inExclude1 = Sets.newHashSet("inExclude1_1", "inExclude1_2");
Set<String> outInclude1 = Sets.newHashSet("outInclude1_1", "outInclude1_2");
Set<String> outExclude1 = Sets.newHashSet("outExclude1_1", "outExclude1_2");
Set<String> inInclude2 = Sets.newHashSet("inInclude" + createString(500));
Set<String> inExclude2 = Sets.newHashSet("inExclude" + createString(500));
Set<String> outInclude2 = Sets.newHashSet("outInclude" + createString(500));
Set<String> outExclude2 = Sets.newHashSet("outExclude" + createString(500));
FileSelector fileSelector;
task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromGlobalSpace);
task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromUserSpace);
fileSelector = new FileSelector(inInclude2, inExclude2);
task.addInputFiles(fileSelector, InputAccessMode.TransferFromInputSpace);
task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToGlobalSpace);
task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToUserSpace);
fileSelector = new FileSelector(outInclude2, outExclude2);
task.addOutputFiles(fileSelector, OutputAccessMode.TransferToOutputSpace);
jobDef.addTask(task);
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
Assert.assertEquals(3, task1.getInputFilesList().size());
Assert.assertEquals(InputAccessMode.TransferFromGlobalSpace, task1.getInputFilesList().get(0).getMode());
Assert.assertEquals(InputAccessMode.TransferFromUserSpace, task1.getInputFilesList().get(1).getMode());
Assert.assertEquals(3, task1.getOutputFilesList().size());
checkSelector(task1.getInputFilesList().get(0).getInputFiles(), inInclude1, inExclude1, true);
checkSelector(task1.getInputFilesList().get(1).getInputFiles(), inInclude1, inExclude1, true);
checkSelector(task1.getInputFilesList().get(2).getInputFiles(), inInclude2, inExclude2, false);
checkSelector(task1.getOutputFilesList().get(0).getOutputFiles(), outInclude1, outExclude1, true);
checkSelector(task1.getOutputFilesList().get(1).getOutputFiles(), outInclude1, outExclude1, true);
checkSelector(task1.getOutputFilesList().get(2).getOutputFiles(), outInclude2, outExclude2, false);
}
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 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.task.JavaTask 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.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());
}
}
Aggregations