use of org.ow2.proactive.scheduler.common.job.factories.JobFactory in project scheduling by ow2-proactive.
the class ValidationUtil method validateJob.
public static JobValidationData validateJob(String jobFilePath, 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(jobFilePath, 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;
}
use of org.ow2.proactive.scheduler.common.job.factories.JobFactory 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.job.factories.JobFactory in project scheduling by ow2-proactive.
the class JobFactory method getFactory.
/**
* Try to instantiate the known factories.
* Return the created instance of the jobFactory.
* As it may instantiate built'in factories, this method rarely fails but a RuntimeException is raised if
* no factory can be found.
* @param handleGlobalVariables if global variables should be handled by the job factory
*
* @return the instance of the jobFactory.
*/
public static JobFactory getFactory(boolean handleGlobalVariables) {
JobFactory factory = null;
for (String factoryInstance : CURRENT_IMPL) {
try {
ClassLoader cl = JobFactory.class.getClassLoader();
Class c = cl.loadClass(factoryInstance);
Constructor constructor = c.getConstructor(Boolean.TYPE);
factory = (JobFactory) constructor.newInstance(handleGlobalVariables);
break;
} catch (ClassNotFoundException e) {
logger.warn("Cannot instanciate this factory : " + factoryInstance, e);
} catch (Exception e) {
logger.warn("Error while instanciating this factory : " + factoryInstance, e);
}
}
if (factory == null) {
throw new RuntimeException("Cannot instanciate any factory ! (see WARN logs to know why)");
}
return factory;
}
use of org.ow2.proactive.scheduler.common.job.factories.JobFactory in project scheduling by ow2-proactive.
the class JobFactory method getFactory.
/**
* Try to instantiate the given factory.
* Return the created instance of the jobFactory.
* If the factory is not found or not created, a runtime exception is raised.
* @param handleGlobalVariables if global variables should be handled by the job factory
*
* @return the instance of the required factory.
*/
public static JobFactory getFactory(String impl, boolean handleGlobalVariables) {
if (impl == null) {
return getFactory(handleGlobalVariables);
}
JobFactory factory;
try {
Class c = Class.forName(impl);
Constructor constructor = c.getConstructor(Boolean.TYPE);
factory = (JobFactory) constructor.newInstance(handleGlobalVariables);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Cannot instanciate this factory : " + impl, e);
} catch (Exception e) {
throw new RuntimeException("Error while instanciating this factory : " + impl, e);
}
return factory;
}
use of org.ow2.proactive.scheduler.common.job.factories.JobFactory 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;
}
Aggregations