use of org.ow2.proactive.scheduler.common.SchedulerSpaceInterface in project scheduling by ow2-proactive.
the class StaxJobFactory method validate.
/*
* Validate the given job descriptor
*/
private TaskFlowJob validate(TaskFlowJob job, Scheduler scheduler, SchedulerSpaceInterface space, String sessionId) throws JobCreationException {
Map<String, JobValidatorService> factories;
try {
factories = JobValidatorRegistry.getInstance().getRegisteredFactories();
} catch (Exception e) {
throw new JobCreationException(MSG_UNABLE_TO_INSTANCIATE_JOB_VALIDATION_FACTORIES, e);
}
TaskFlowJob updatedJob = job;
try {
for (JobValidatorService factory : factories.values()) {
updatedJob = factory.validateJob(updatedJob, scheduler, space, sessionId);
}
} catch (JobValidationException e) {
fillUpdatedVariables(e, job);
throw e;
} catch (Exception e) {
JobValidationException validationException = new JobValidationException(e);
fillUpdatedVariables(validationException, job);
throw validationException;
}
return updatedJob;
}
use of org.ow2.proactive.scheduler.common.SchedulerSpaceInterface 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;
}
use of org.ow2.proactive.scheduler.common.SchedulerSpaceInterface in project scheduling by ow2-proactive.
the class OptionalValidatorTest method mockContext.
public ModelValidatorContext mockContext() throws NotConnectedException, PermissionException {
ModelValidatorContext context = mock(ModelValidatorContext.class);
SchedulerSpaceInterface schedulerSpaceInterface = mock(SchedulerSpaceInterface.class);
when(context.getSpace()).thenReturn(schedulerSpaceInterface);
when(schedulerSpaceInterface.checkFileExists(GLOBALSPACE_NAME, existGlobalFilePath)).thenReturn(true);
when(schedulerSpaceInterface.checkFileExists(GLOBALSPACE_NAME, notExistGlobalFilePath)).thenReturn(false);
when(schedulerSpaceInterface.checkFileExists(USERSPACE_NAME, existUserFilePath)).thenReturn(true);
when(schedulerSpaceInterface.checkFileExists(USERSPACE_NAME, notExistUserFilePath)).thenReturn(false);
return context;
}
Aggregations