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;
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations