Search in sources :

Example 46 with JobCreationException

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

the class ValidationUtil method validateJob.

public JobValidationData validateJob(String jobFilePath, Map<String, String> jobVariables) {
    JobValidationData data = new JobValidationData();
    try {
        JobFactory factory = JobFactory.getFactory();
        Job job = factory.createJob(jobFilePath, jobVariables);
        if (job instanceof TaskFlowJob) {
            validateJob((TaskFlowJob) job, data);
            fillUpdatedVariables((TaskFlowJob) job, data);
        } else {
            data.setValid(true);
        }
    } catch (JobCreationException e) {
        data.setTaskName(e.getTaskName());
        data.setErrorMessage(e.getMessage());
        data.setStackTrace(getStackTrace(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 47 with JobCreationException

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

the class InternalJobFactory method createTask.

private static InternalTask createTask(Job userJob, InternalJob internalJob, ScriptTask task) throws JobCreationException {
    InternalTask scriptTask;
    if (isForkingTask()) {
        scriptTask = new InternalForkedScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
        configureRunAsMe(task);
    } else {
        scriptTask = new InternalScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
    }
    // set task common properties
    try {
        setTaskCommonProperties(userJob, task, scriptTask);
    } catch (Exception e) {
        throw new JobCreationException(e);
    }
    return scriptTask;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) 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)

Example 48 with JobCreationException

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

the class SchedulerClient method submit.

@Override
public JobId submit(Job job) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    JobIdData jobIdData = null;
    try {
        InputStream is = (new Job2XMLTransformer()).jobToxml((TaskFlowJob) job);
        jobIdData = restApiClient().submitXml(sid, is);
    } catch (Exception e) {
        throwNCEOrPEOrSCEOrJCE(e);
    }
    return jobId(jobIdData);
}
Also used : Job2XMLTransformer(org.ow2.proactive.scheduler.common.job.factories.Job2XMLTransformer) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) KeyStoreException(java.security.KeyStoreException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) 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) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException)

Example 49 with JobCreationException

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

the class StaxJobFactory method createSelectionScript.

/**
 * Get the selection script defined at the specified cursor.
 * Leave the method with cursor at the end of the 'ELEMENT_SCRIPT_SELECTION' script.
 *
 * @param cursorScript the streamReader with the cursor on the 'ELEMENT_SCRIPT_SELECTION' tag.
 * @return the script defined at the specified cursor.
 */
private List<SelectionScript> createSelectionScript(XMLStreamReader cursorScript, Map<String, String> variables) throws JobCreationException {
    List<SelectionScript> scripts = new ArrayList<>(0);
    String selectionTag = cursorScript.getLocalName();
    String current = null;
    try {
        SelectionScript newOne;
        int eventType;
        while (cursorScript.hasNext()) {
            eventType = cursorScript.next();
            switch(eventType) {
                case XMLEvent.START_ELEMENT:
                    current = cursorScript.getLocalName();
                    if (XMLTags.SCRIPT_SCRIPT.matches(current)) {
                        newOne = (SelectionScript) createScript(cursorScript, ScriptType.SELECTION, variables);
                        scripts.add(newOne);
                    }
                    break;
                case XMLEvent.END_ELEMENT:
                    current = cursorScript.getLocalName();
                    if (current.equals(selectionTag)) {
                        return scripts.isEmpty() ? null : scripts;
                    }
                    break;
                default:
            }
        }
    } catch (JobCreationException jce) {
        jce.pushTag(current);
        throw jce;
    } catch (Exception e) {
        throw new JobCreationException(current, null, e);
    }
    return scripts;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) ArrayList(java.util.ArrayList) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) XMLStreamException(javax.xml.stream.XMLStreamException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) FileNotFoundException(java.io.FileNotFoundException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) IOException(java.io.IOException)

Example 50 with JobCreationException

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

the class StaxJobFactory method getUnresolvedGenericInformations.

/**
 * Get the defined generic information of the entity.
 * Leave the method at the end of 'ELEMENT_COMMON_GENERIC_INFORMATION' tag.
 *
 * @param cursorInfo the streamReader with the cursor on the 'ELEMENT_COMMON_GENERIC_INFORMATION' tag.
 * @return the list of generic information as a hashMap.
 */
private Map<String, String> getUnresolvedGenericInformations(XMLStreamReader cursorInfo, boolean isTask, GlobalVariablesData globalVariablesData) throws JobCreationException {
    // The following initializaion is to enable overridding of global generic info by workflow gi
    Map<String, String> infos = isTask ? new LinkedHashMap<>() : globalVariablesData.getGenericInformation();
    try {
        int eventType;
        while (cursorInfo.hasNext()) {
            eventType = cursorInfo.next();
            switch(eventType) {
                case XMLEvent.START_ELEMENT:
                    if (XMLTags.COMMON_INFO.matches(cursorInfo.getLocalName())) {
                        Map<String, String> attributesAsMap = getUnresolvedAttributesAsMap(cursorInfo);
                        String name = attributesAsMap.get(XMLAttributes.COMMON_NAME.getXMLName());
                        String value = attributesAsMap.get(XMLAttributes.COMMON_VALUE.getXMLName());
                        infos.put(name, value);
                    }
                    break;
                case XMLEvent.END_ELEMENT:
                    if (XMLTags.COMMON_GENERIC_INFORMATION.matches(cursorInfo.getLocalName())) {
                        return infos;
                    }
                    break;
                default:
            }
        }
        return infos;
    } catch (JobCreationException jce) {
        jce.pushTag(cursorInfo.getLocalName());
        throw jce;
    } catch (Exception e) {
        String attrtmp = null;
        if (cursorInfo.isStartElement() && cursorInfo.getAttributeCount() == 1) {
            attrtmp = cursorInfo.getAttributeLocalName(0);
        }
        throw new JobCreationException(cursorInfo.getLocalName(), attrtmp, e);
    }
}
Also used : JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) XMLStreamException(javax.xml.stream.XMLStreamException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) FileNotFoundException(java.io.FileNotFoundException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) IOException(java.io.IOException)

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