use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestLoadJobs method createJob.
private TaskFlowJob createJob(String communicationObjectUrl) throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
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.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TaskUsingCredentialsTest method jobs_using_third_party_credentials.
private void jobs_using_third_party_credentials() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
scheduler.putThirdPartyCredential("MY_APP_PASSWORD", "superpassword");
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
if (OperatingSystem.getOperatingSystem() == org.objectweb.proactive.utils.OperatingSystem.unix) {
NativeTask nativeTask = new NativeTask();
nativeTask.setCommandLine("echo", "$credentials_MY_APP_PASSWORD");
job.addTask(nativeTask);
}
JobId jobId = scheduler.submit(job);
schedulerHelper.waitForEventJobFinished(jobId);
JobResult jobResult = schedulerHelper.getJobResult(jobId);
for (TaskResult taskResult : jobResult.getAllResults().values()) {
assertTrue("task " + taskResult.getTaskId().getReadableName() + " did not print the credential", taskResult.getOutput().getAllLogs(false).contains("superpassword"));
}
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestThirdPartyCredentialsDefined method createAndSubmitTaskPrintingCredentials.
public String createAndSubmitTaskPrintingCredentials() throws Exception {
ScriptTask scriptTask = new ScriptTask();
scriptTask.setName("task");
scriptTask.setScript(new TaskScript(new SimpleScript("print credentials", "python")));
TaskFlowJob job = new TaskFlowJob();
job.addTask(scriptTask);
JobId id = schedulerHelper.submitJob(job);
schedulerHelper.waitForEventJobFinished(id);
JobResult jobResult = schedulerHelper.getJobResult(id);
TaskResult result = jobResult.getResult(scriptTask.getName());
return result.getOutput().getStdoutLogs(false).replaceAll("\n|\r", "");
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestDataspaceConcurrentTransfer method createJobWithFileTransfers.
public Job createJobWithFileTransfers() throws UserException, InvalidScriptException {
TaskFlowJob job = new TaskFlowJob();
job.setName(JOB_NAME);
job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
for (int i = 0; i < NB_TASKS; i++) {
ScriptTask st1 = new ScriptTask();
st1.setName(TASK_NAME_CREATE + i);
st1.setScript(new TaskScript(new SimpleScript("org.apache.commons.io.FileUtils.touch(new File(localspace, \"" + FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN + "\"));", "groovy")));
st1.addOutputFiles("**/*" + FILE_EXT_IN, OutputAccessMode.TransferToGlobalSpace);
job.addTask(st1);
ScriptTask st2 = new ScriptTask();
st2.setName(TASK_NAME_PROCESS + i);
st2.setScript(new TaskScript(new SimpleScript("org.apache.commons.io.FileUtils.copyFile(new File(localspace, \"" + FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN + "\"), new File(localspace, \"" + FOLDER_OUT_NAME + i + "/" + FILE_NAME + i + FILE_EXT_OUT + "\"));", "groovy")));
st2.addInputFiles(FOLDER_IN_NAME + i + "/" + FILE_NAME + i + FILE_EXT_IN, InputAccessMode.TransferFromGlobalSpace);
st2.addOutputFiles("**/*" + FILE_EXT_OUT, OutputAccessMode.TransferToGlobalSpace);
st2.addDependence(st1);
job.addTask(st2);
}
return job;
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestGlobalSpace method testGlobalSpace.
@Test
public void testGlobalSpace() throws Throwable {
File in = tmpFolder.newFolder("input_space");
String inPath = in.getAbsolutePath();
File out = tmpFolder.newFolder("output_space");
String outPath = out.getAbsolutePath();
writeFiles(inFiles, inPath);
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.setInputSpace(in.toURI().toURL().toString());
job.setOutputSpace(out.toURI().toURL().toString());
JavaTask A = new JavaTask();
A.setExecutableClassName("org.ow2.proactive.scheduler.examples.EmptyTask");
A.setName("A");
for (String[] file : inFiles) {
A.addInputFiles(file[0], InputAccessMode.TransferFromInputSpace);
A.addOutputFiles(file[0] + ".glob.A", OutputAccessMode.TransferToGlobalSpace);
}
A.setPreScript(new SimpleScript(scriptA, "groovy"));
A.setForkEnvironment(new ForkEnvironment());
job.addTask(A);
JavaTask B = new JavaTask();
B.setExecutableClassName("org.ow2.proactive.scheduler.examples.EmptyTask");
B.setName("B");
B.addDependence(A);
for (String[] file : inFiles) {
B.addInputFiles(file[0] + ".glob.A", InputAccessMode.TransferFromGlobalSpace);
B.addOutputFiles(file[0] + ".out", OutputAccessMode.TransferToOutputSpace);
}
B.setPreScript(new SimpleScript(scriptB, "groovy"));
B.setForkEnvironment(new ForkEnvironment());
job.addTask(B);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobId id = scheduler.submit(job);
schedulerHelper.waitForEventJobFinished(id);
assertFalse(schedulerHelper.getJobResult(id).hadException());
/**
* check: inFiles > IN > LOCAL A > GLOBAL > LOCAL B > OUT
*/
for (String[] inFile : inFiles) {
File f = new File(outPath + File.separator + inFile[0] + ".out");
assertTrue("File does not exist: " + f.getAbsolutePath(), f.exists());
Assert.assertEquals("Original and copied files differ", inFile[1], FileUtils.readFileToString(f));
f.delete();
File inf = new File(inPath + File.separator + inFile[0]);
inf.delete();
}
/**
* check that the file produced is accessible in the global user space via the scheduler API
*/
String globalURI = scheduler.getGlobalSpaceURIs().get(0);
assertTrue(globalURI.startsWith("file:"));
String globalPath = new File(new URI(globalURI)).getAbsolutePath();
FileSystemManager fsManager = VFSFactory.createDefaultFileSystemManager();
for (String[] file : inFiles) {
FileObject outFile = fsManager.resolveFile(globalURI + "/" + file[0] + ".glob.A");
log("Checking existence of " + outFile.getURL());
assertTrue(outFile.getURL() + " exists", outFile.exists());
File outFile2 = new File(globalPath, file[0] + ".glob.A");
log("Checking existence of " + outFile2);
assertTrue(outFile2 + " exists", outFile2.exists());
}
}
Aggregations