Search in sources :

Example 61 with Job

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;
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) URL(java.net.URL)

Example 62 with 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());
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 63 with Job

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);
    }
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 64 with Job

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);
    }
}
Also used : VerifierFactory(org.iso_relax.verifier.VerifierFactory) VerifierHandler(org.iso_relax.verifier.VerifierHandler) Schema(org.iso_relax.verifier.Schema) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) Verifier(org.iso_relax.verifier.Verifier) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException) SAXException(org.xml.sax.SAXException) XMLReader(org.xml.sax.XMLReader)

Example 65 with Job

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;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Aggregations

Test (org.junit.Test)260 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)198 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)145 JobId (org.ow2.proactive.scheduler.common.job.JobId)122 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)91 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)87 File (java.io.File)76 SimpleScript (org.ow2.proactive.scripting.SimpleScript)70 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)68 TaskScript (org.ow2.proactive.scripting.TaskScript)65 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)64 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)58 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)48 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 ArrayList (java.util.ArrayList)46 JobState (org.ow2.proactive.scheduler.common.job.JobState)45 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)41 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39