Search in sources :

Example 66 with JobCreationException

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

the class TestStaxJobFactory method testUnresolvedTaskGenericInformation.

@Test
public void testUnresolvedTaskGenericInformation() throws URISyntaxException, JobCreationException {
    TaskFlowJob job = (TaskFlowJob) factory.createJob(jobDescriptorWithUnresolvedGenericInfoAndVariables);
    Map<String, String> unresolvedGenericInformation = job.getTask("task").getUnresolvedGenericInformation();
    Map<String, String> genericInformation = job.getTask("task").getGenericInformation();
    // the gi references a task variable
    assertEquals("gi_${task_variable2}", unresolvedGenericInformation.get("task_generic_info1"));
    assertEquals("gi_task_value1", genericInformation.get("task_generic_info1"));
    // the gi references a task variable which inherits a job variable
    assertEquals("gi_${variable1}", unresolvedGenericInformation.get("task_generic_info2"));
    assertEquals("gi_value1", genericInformation.get("task_generic_info2"));
    // the gi references a task variable which overrides a job variable
    assertEquals("gi_${variable2}", unresolvedGenericInformation.get("task_generic_info3"));
    assertEquals("gi_task_value1", genericInformation.get("task_generic_info3"));
    // the gi overrides a job gi which references a non-inherited task variable (complicated case)
    assertEquals("gi_${variable2}", unresolvedGenericInformation.get("info1"));
    assertEquals("gi_task_value1", genericInformation.get("info1"));
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) GlobalVariablesParserTest(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesParserTest) Test(org.junit.Test)

Example 67 with JobCreationException

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

the class ValidationUtil method validateJob.

public static JobValidationData validateJob(InputStream jobInputStream, Map<String, String> jobVariables, Scheduler scheduler, SchedulerSpaceInterface space, String sessionId) {
    JobValidationData data = new JobValidationData();
    Job job = null;
    try {
        JobFactory factory = JobFactory.getFactory();
        job = factory.createJob(jobInputStream, jobVariables, null, scheduler, space, sessionId);
        if (job instanceof TaskFlowJob) {
            fillUpdatedVariables((TaskFlowJob) job, data);
            validateJob((TaskFlowJob) job, data);
        } else {
            data.setValid(true);
        }
    } catch (JobCreationException e) {
        data.setTaskName(e.getTaskName());
        setJobValidationDataErrorMessage(data, e);
    }
    return data;
}
Also used : JobFactory(org.ow2.proactive.scheduler.common.job.factories.JobFactory) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobValidationData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData) Job(org.ow2.proactive.scheduler.common.job.Job) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Example 68 with JobCreationException

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

the class AbstractSmartProxy method submit.

/**
 * Submits a job to the scheduler and handle data transfer via the SmartProxy
 *
 * @param job                   job to submit
 * @param localInputFolderPath  path to the local directory containing input files
 * @param pushUrl               url of the dataspace server used to push input files to
 * @param localOutputFolderPath path to the local directory which will contain output files
 * @param pullUrl               url of the dataspace server used to pull output files from
 * @param isolateTaskOutputs    if set to true, output files from each tasks will be isolated from each other in the dataspace server (to prevent overlapping)
 * @param automaticTransfer     if set to true, output files will be automatically transferred from the dataspace server to the local machine as soon as the task is finished.
 *                              If set to false, the files will not be automatically transferred and a call to pullData must be done to transfer files
 * @return the new job id
 * @throws Exception
 * @throws SubmissionClosedException
 * @throws JobCreationException
 */
public JobId submit(TaskFlowJob job, String localInputFolderPath, String pushUrl, String localOutputFolderPath, String pullUrl, boolean isolateTaskOutputs, boolean automaticTransfer) throws Exception, SubmissionClosedException, JobCreationException {
    checkInitialized();
    List<String> pushUrls;
    List<String> pullUrls;
    if (isNullOrEmpty(pushUrl)) {
        pushUrls = getUserSpaceURIs();
    } else {
        pushUrls = Arrays.asList(Tools.dataSpaceConfigPropertyToUrls(pushUrl));
    }
    if (isNullOrEmpty(pullUrl)) {
        pullUrls = getUserSpaceURIs();
    } else {
        pullUrls = Arrays.asList(Tools.dataSpaceConfigPropertyToUrls(pullUrl));
    }
    String newFolderName = createNewFolderName();
    String pushUrlUpdate = prepareJobInput(job, localInputFolderPath, pushUrls, newFolderName);
    String pullUrlUpdate = prepareJobOutput(job, localOutputFolderPath, pullUrls, newFolderName, isolateTaskOutputs);
    uploadInputfiles(job, localInputFolderPath);
    JobId id = null;
    if (log.isTraceEnabled()) {
        log.trace("Job Contents before submission:");
        log.trace(job.display());
    }
    try {
        id = submit(job);
    } catch (Exception e) {
        log.error("Error while submitting job", e);
        try {
            removeJobIO(job, pushUrl, pullUrl, newFolderName);
        } catch (Exception e2) {
            log.error("Error while removing job IO", e2);
        }
        propagateIfInstanceOf(e, NotConnectedException.class);
        propagateIfInstanceOf(e, PermissionException.class);
        propagateIfInstanceOf(e, SubmissionClosedException.class);
        propagateIfInstanceOf(e, JobCreationException.class);
        propagateIfInstanceOf(e, RuntimeException.class);
        propagate(e);
    }
    HashMap<String, AwaitedTask> awaitedTaskMap = new HashMap<>();
    for (Task t : job.getTasks()) {
        awaitedTaskMap.put(t.getName(), new AwaitedTask(t.getName(), t.getOutputFilesList()));
    }
    AwaitedJob awaitedJob = new AwaitedJob(id.toString(), localInputFolderPath, job.getInputSpace(), pushUrlUpdate, localOutputFolderPath, job.getOutputSpace(), pullUrlUpdate, isolateTaskOutputs, automaticTransfer, awaitedTaskMap);
    jobTracker.putAwaitedJob(id.toString(), awaitedJob);
    return id;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) Task(org.ow2.proactive.scheduler.common.task.Task) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) LoginException(javax.security.auth.login.LoginException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)51 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)30 FileNotFoundException (java.io.FileNotFoundException)29 XMLStreamException (javax.xml.stream.XMLStreamException)29 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)25 IOException (java.io.IOException)24 LinkedHashMap (java.util.LinkedHashMap)16 Job (org.ow2.proactive.scheduler.common.job.Job)16 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)12 HashMap (java.util.HashMap)11 Test (org.junit.Test)10 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)9 GlobalVariablesParserTest (org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesParserTest)9 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)8 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)8 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)8 ArrayList (java.util.ArrayList)7 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)7 Task (org.ow2.proactive.scheduler.common.task.Task)7