Search in sources :

Example 6 with SchedulerSpaceInterface

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;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobValidatorService(org.ow2.proactive.scheduler.common.job.factories.spi.JobValidatorService) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) 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 7 with SchedulerSpaceInterface

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;
}
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 8 with SchedulerSpaceInterface

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;
}
Also used : SchedulerSpaceInterface(org.ow2.proactive.scheduler.common.SchedulerSpaceInterface) ModelValidatorContext(org.ow2.proactive.scheduler.common.job.factories.spi.model.ModelValidatorContext)

Aggregations

JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)4 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 Job (org.ow2.proactive.scheduler.common.job.Job)3 LinkedHashMap (java.util.LinkedHashMap)2 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)2 JobFactory (org.ow2.proactive.scheduler.common.job.factories.JobFactory)2 JobValidationData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobValidationData)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 Before (org.junit.Before)1 SchedulerSpaceInterface (org.ow2.proactive.scheduler.common.SchedulerSpaceInterface)1 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)1 JobValidatorService (org.ow2.proactive.scheduler.common.job.factories.spi.JobValidatorService)1 ModelValidatorContext (org.ow2.proactive.scheduler.common.job.factories.spi.model.ModelValidatorContext)1