Search in sources :

Example 16 with JobCreationException

use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionGenericInformationXmlElement.

/**
 * The next 3 tests are there to check that parsing a workflow XML description involving XML elements
 * with more than 1 attribute (defined in any order) returns an object description with expected values
 * in corresponding data structures.
 */
@Test
public void testJobCreationAttributeOrderDefinitionGenericInformationXmlElement() throws URISyntaxException, JobCreationException {
    TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("job_attr_def_generic_information_xml_element.xml"));
    Map<String, String> genericInformation = job.getTask("task").getGenericInformation();
    assertExpectedKeyValueEntriesMatch(genericInformation);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 17 with JobCreationException

use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testTaskVariables.

@Test
public void testTaskVariables() throws URISyntaxException, JobCreationException {
    TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("task_variables.xml"));
    Map<String, TaskVariable> taskVariables = job.getTask("task").getVariables();
    assertEquals(2, taskVariables.size());
    TaskVariable taskVariable = taskVariables.get("name1");
    assertNotNull(taskVariable);
    assertEquals("name1", taskVariable.getName());
    assertEquals("value1", taskVariable.getValue());
    assertEquals("model1", taskVariable.getModel());
    assertFalse(taskVariable.isJobInherited());
    taskVariable = taskVariables.get("name2");
    assertNotNull(taskVariable);
    assertEquals("name2", taskVariable.getName());
    assertEquals("value2", taskVariable.getValue());
    assertEquals("model2", taskVariable.getModel());
    assertTrue(taskVariable.isJobInherited());
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) Test(org.junit.Test)

Example 18 with JobCreationException

use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testHandleVariablesReplacements.

@Test
public void testHandleVariablesReplacements() throws JobCreationException {
    // null replacement
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), null));
    // replace existing variable, leave the model intact
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v2", "m1")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), ImmutableMap.<String, String>of("a1", "v2")));
    // add new variable
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), ImmutableMap.<String, String>of("a2", "v2")));
    // reuse replacement variable in pattern and add new variable
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v2", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}")), ImmutableMap.<String, String>of("a2", "v2")));
    // existing variable uses another existing variable in a pattern, null replacements
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v2", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a2", new JobVariable("a2", "v2")), null));
    // existing variable uses another existing variable in a pattern, this other existing variable uses itself a replacement variable
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v3", "m1v3"), "a2", new JobVariable("a2", "v3", "m2v3"), "a3", new JobVariable("a3", "v3")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a2", new JobVariable("a2", "${a3}", "m2${a3}")), ImmutableMap.<String, String>of("a3", "v3")));
    // existing variable uses a replacement variable in a pattern, this replacement variable uses itself a job variable from the workflow
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v3", "m1v3"), "a2", new JobVariable("a2", "v3"), "a3", new JobVariable("a3", "v3", "m3v3")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a3", new JobVariable("a3", "v3", "m3${a2}")), ImmutableMap.<String, String>of("a2", "${a3}")));
    // existing variable uses a replacement variable in a pattern, but is overwritten by another replacement variable
    Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}")), ImmutableMap.<String, String>of("a2", "v2", "a1", "v1")));
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) Test(org.junit.Test)

Example 19 with JobCreationException

use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.

the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionParameterXmlElement.

@Test
public void testJobCreationAttributeOrderDefinitionParameterXmlElement() throws URISyntaxException, JobCreationException, IOException, ClassNotFoundException {
    TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("job_attr_def_parameter_xml_element.xml"));
    Map<String, Serializable> arguments = ((JavaTask) job.getTask("task")).getArguments();
    assertExpectedKeyValueEntriesMatch(arguments);
}
Also used : Serializable(java.io.Serializable) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 20 with JobCreationException

use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.

the class InternalJobFactory method createJob.

/**
 * Create a new internal job with the given job (user).
 *
 * @param job the user job that will be used to create the internal job.
 * @return the created internal job.
 * @throws JobCreationException an exception if the factory cannot create the given job.
 */
public static InternalJob createJob(Job job, Credentials cred) throws JobCreationException {
    InternalJob iJob;
    if (logger.isDebugEnabled()) {
        logger.debug("Create job '" + job.getName() + "' - " + job.getClass().getName());
    }
    switch(job.getType()) {
        case PARAMETER_SWEEPING:
            logger.error("The type of the given job is not yet implemented !");
            throw new JobCreationException("The type of the given job is not yet implemented !");
        case TASKSFLOW:
            iJob = createJob((TaskFlowJob) job);
            break;
        default:
            logger.error("The type of the given job is unknown !");
            throw new JobCreationException("The type of the given job is unknown !");
    }
    try {
        // set the job common properties
        iJob.setCredentials(cred);
        setJobCommonProperties(job, iJob);
        return iJob;
    } catch (Exception e) {
        logger.error("", e);
        throw new InternalException("Error while creating the internalJob !", e);
    }
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Aggregations

JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)37 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)21 FileNotFoundException (java.io.FileNotFoundException)20 XMLStreamException (javax.xml.stream.XMLStreamException)20 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)20 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 LinkedHashMap (java.util.LinkedHashMap)10 HashMap (java.util.HashMap)9 Job (org.ow2.proactive.scheduler.common.job.Job)9 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)6 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)6 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)6 File (java.io.File)5 IOException (java.io.IOException)5