use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class SchedulerClientTest method nodeClientJob.
protected Job nodeClientJob(String groovyScript, String forkScript) throws Exception {
URL scriptURL = SchedulerClientTest.class.getResource(groovyScript);
URL forkScriptURL = SchedulerClientTest.class.getResource(forkScript);
TaskFlowJob job = new TaskFlowJob();
job.setName("NodeClientJob");
ScriptTask task = new ScriptTask();
task.setName("NodeClientTask");
ForkEnvironment forkEnvironment = new ForkEnvironment();
forkEnvironment.setEnvScript(new SimpleScript(IOUtils.toString(forkScriptURL.toURI()), "groovy"));
task.setForkEnvironment(forkEnvironment);
task.setScript(new TaskScript(new SimpleScript(IOUtils.toString(scriptURL.toURI()), "groovy")));
// add CleanScript to test external APIs
task.setCleaningScript(new SimpleScript("" + "schedulerapi.connect();\n" + "print(\"SCHEDULERAPI_URI_LIST_NOT_NULL=\"+(schedulerapi.getGlobalSpaceURIs()!=null));\n" + "\n" + "userspaceapi.connect();\n" + "print(\"USERSPACE_FILE_LIST_NOT_NULL=\"+(userspaceapi.listFiles(\".\", \"*\")!=null));\n" + "\n" + "globalspaceapi.connect();\n" + "print(\"GLOBALSPACE_FILE_LIST_NOT_NULL=\"+(globalspaceapi.listFiles(\".\", \"*\")!=null));\n" + "print(\"TEST_CREDS=\"+(credentials.get(\"TEST_CREDS\")));\n", "js"));
job.addTask(task);
return job;
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class SchedulerClientTest method testDataSpaceNodeClientPushPull.
@Test(timeout = MAX_WAIT_TIME)
public void testDataSpaceNodeClientPushPull() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = nodeClientJob("/functionaltests/descriptors/dataspace_client_node_push_pull.groovy", "/functionaltests/descriptors/dataspace_client_node_fork.groovy");
JobId jobId = submitJob(job, client);
TaskResult tres = client.waitForTask(jobId.toString(), "NodeClientTask", TimeUnit.MINUTES.toMillis(5));
System.out.println(tres.getOutput().getAllLogs(false));
Assert.assertNotNull(tres);
Assert.assertEquals("HelloWorld", tres.value());
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class SchedulerClientTest method testWaitForNonTerminatingJob.
@Test(timeout = MAX_WAIT_TIME, expected = TimeoutException.class)
public void testWaitForNonTerminatingJob() throws Exception {
ISchedulerClient client = clientInstance();
Job job = pendingJob();
JobId jobId = submitJob(job, client);
try {
client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(10));
} finally {
// Once the TimeoutException has been thrown
// kill the job to free the node
client.killJob(jobId);
}
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class ValidationUtil method validate.
/**
* Validates the job descriptor file against the specified schema.
*
* @param jobFile
* the job descriptor file
* @param schemaIs
* the job schema
*
* @throws JobCreationException
* if the job descriptor is invalid
*/
public static void validate(File jobFile, InputStream schemaIs) throws SAXException, IOException, JobCreationException {
try {
XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
VerifierFactory vfactory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
Schema schema = vfactory.compileSchema(schemaIs);
Verifier verifier = schema.newVerifier();
VerifierHandler handler = verifier.getVerifierHandler();
ContentHandlerDecorator contentHandlerDecorator = new ContentHandlerDecorator(handler);
reader.setContentHandler(contentHandlerDecorator);
ValidationErrorHandler errHandler = new ValidationErrorHandler(contentHandlerDecorator);
verifier.setErrorHandler(errHandler);
reader.parse(jobFile.getAbsolutePath());
} catch (SAXException se) {
Throwable cause = se.getCause();
if (cause != null && cause instanceof JobCreationException) {
// unwrap
throw (JobCreationException) cause;
} else {
throw se;
}
} catch (VerifierConfigurationException e) {
throw new IllegalStateException(e);
}
}
use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.
the class DefaultModelJobValidatorServiceProvider method validateJob.
@Override
public TaskFlowJob validateJob(TaskFlowJob job) throws JobValidationException {
ModelValidatorContext context = new ModelValidatorContext(job);
for (JobVariable jobVariable : job.getVariables().values()) {
checkVariableFormat(null, jobVariable, context);
context.updateJobWithContext(job);
}
for (Task task : job.getTasks()) {
context = new ModelValidatorContext(task);
for (TaskVariable taskVariable : task.getVariables().values()) {
checkVariableFormat(task, taskVariable, context);
context.updateTaskWithContext(task);
}
}
return job;
}
Aggregations