Search in sources :

Example 31 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class SchedulerFrontend method validateUpdatedVariables.

private boolean validateUpdatedVariables(Map<String, String> updatedVariables, List<JobVariable> inputVariables) throws JobValidationException {
    DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
    Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>(updatedVariables);
    validatorServiceProvider.validateVariables(inputVariables, serializableUpdatedVariables, this, this);
    return true;
}
Also used : DefaultModelJobValidatorServiceProvider(org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider)

Example 32 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class ForkedJvmTaskExecutionCommandCreatorTest method getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment.

private TaskLauncherInitializer getTaskLauncherInitializerWithWorkflowVariableAndForkEnvironment() {
    // Create and setup task launcher initializer
    TaskLauncherInitializer taskLauncherInitializer = createTaskLauncherInitializer();
    Map<String, JobVariable> variablesToPut = new HashMap<>();
    variablesToPut.put(testVariable1Key, new JobVariable(testVariable1Key, testVariable1Value));
    taskLauncherInitializer.setJobVariables(variablesToPut);
    return taskLauncherInitializer;
}
Also used : HashMap(java.util.HashMap) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Example 33 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class StaxJobFactory method createJob.

/**
 * Start parsing and creating the job.
 *
 * @throws JobCreationException if an error occurred during job creation process.
 */
private Job createJob(XMLStreamReader cursorRoot, Map<String, String> replacementVariables, Map<String, String> replacementGenericInfos, Map<String, ArrayList<String>> dependencies, String jobContent) throws JobCreationException {
    String current = null;
    GlobalVariablesData globalVariablesData = getConfiguredGlobalVariablesData(jobContent);
    // start parsing
    try {
        int eventType;
        Job job = null;
        while (cursorRoot.hasNext()) {
            eventType = cursorRoot.next();
            if (eventType == XMLEvent.START_ELEMENT) {
                current = cursorRoot.getLocalName();
                if (XMLTags.JOB.matches(current)) {
                    // first tag of the job.
                    job = createAndFillJob(cursorRoot, replacementVariables, replacementGenericInfos, jobContent, globalVariablesData);
                } else if (XMLTags.TASK.matches(current)) {
                    // once here, the job instance has been created
                    fillJobWithTasks(cursorRoot, job, dependencies, globalVariablesData);
                } else if (XMLTags.METADATA_VISUALIZATION.matches(current) && job != null) {
                    // Add workflow visualization's embedded html
                    job.setVisualization(getJobVisualization(cursorRoot));
                    // Metadata is the last element to parse
                    break;
                }
            }
        }
        if (job != null) {
            resolveCleaningScripts((TaskFlowJob) job, job.getVariablesAsReplacementMap());
        }
        Map<String, JobVariable> globalVariables = new LinkedHashMap<>();
        for (String globalVariable : globalVariablesData.getVariables().keySet()) {
            globalVariables.put(globalVariable, job.getVariables().get(globalVariable));
        }
        job.setGlobalVariables(globalVariables);
        Map<String, String> globalGenericInfoMap = new LinkedHashMap<>();
        for (String globalGenericInfo : globalVariablesData.getGenericInformation().keySet()) {
            globalGenericInfoMap.put(globalGenericInfo, job.getGenericInformation().get(globalGenericInfo));
        }
        job.setGlobalGenericInformation(globalGenericInfoMap);
        return job;
    } catch (JobCreationException jce) {
        if (XMLTags.TASK.matches(current)) {
            jce.pushTag(XMLTags.TASK_FLOW.getXMLName());
        }
        throw jce;
    } catch (Exception e) {
        throw new JobCreationException(current, null, e);
    }
}
Also used : GlobalVariablesData(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesData) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Job(org.ow2.proactive.scheduler.common.job.Job) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) 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) LinkedHashMap(java.util.LinkedHashMap)

Example 34 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class StaxJobFactory method fillUpdatedVariables.

private void fillUpdatedVariables(JobValidationException e, TaskFlowJob job) {
    HashMap<String, String> updatedVariables = new HashMap<>();
    HashMap<String, String> updatedModels = new HashMap<>();
    HashMap<String, String> updatedDescriptions = new HashMap<>();
    HashMap<String, String> updatedGroups = new HashMap<>();
    HashMap<String, Boolean> updatedAdvanced = new HashMap<>();
    HashMap<String, Boolean> updatedHidden = new HashMap<>();
    for (JobVariable jobVariable : job.getVariables().values()) {
        updatedVariables.put(jobVariable.getName(), jobVariable.getValue());
        updatedModels.put(jobVariable.getName(), jobVariable.getModel());
        updatedDescriptions.put(jobVariable.getName(), jobVariable.getDescription());
        updatedGroups.put(jobVariable.getName(), jobVariable.getGroup());
        updatedAdvanced.put(jobVariable.getName(), jobVariable.isAdvanced());
        updatedHidden.put(jobVariable.getName(), jobVariable.isHidden());
    }
    for (Task task : job.getTasks()) {
        for (TaskVariable taskVariable : task.getVariables().values()) {
            updatedVariables.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getValue());
            updatedModels.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getModel());
            updatedDescriptions.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getDescription());
            updatedGroups.put(task.getName() + ":" + taskVariable.getName(), taskVariable.getGroup());
            updatedAdvanced.put(task.getName() + ":" + taskVariable.getName(), taskVariable.isAdvanced());
            updatedHidden.put(task.getName() + ":" + taskVariable.getName(), taskVariable.isHidden());
        }
    }
    e.setUpdatedVariables(updatedVariables);
    e.setUpdatedModels(updatedModels);
    e.setUpdatedDescriptions(updatedDescriptions);
    e.setUpdatedGroups(updatedGroups);
    e.setUpdatedAdvanced(updatedAdvanced);
    e.setUpdatedHidden(updatedHidden);
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TaskVariable(org.ow2.proactive.scheduler.common.task.TaskVariable) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 35 with JobVariable

use of org.ow2.proactive.scheduler.common.job.JobVariable in project scheduling by ow2-proactive.

the class ModelValidatorContext method updateJobVariablesWithContext.

/**
 * updates the given job variables with the current context
 */
public void updateJobVariablesWithContext(List<JobVariable> jobVariables) {
    for (JobVariable jobVariable : jobVariables) {
        jobVariable.setValue(spELVariables.getVariables().get(jobVariable.getName()).toString());
        jobVariable.setModel(spELVariables.getModels().get(jobVariable.getName()));
        String groupName = jobVariable.getGroup();
        if (!Strings.isNullOrEmpty(groupName)) {
            Boolean hiddenGroupStatus = spELVariables.getHiddenGroups().get(groupName);
            if (hiddenGroupStatus != null) {
                jobVariable.setHidden(hiddenGroupStatus);
            }
        }
        Boolean hiddenVariableStatus = spELVariables.getHiddenVariables().get(jobVariable.getName());
        if (hiddenVariableStatus != null) {
            jobVariable.setHidden(hiddenVariableStatus);
        }
    }
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Aggregations

JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)51 Test (org.junit.Test)19 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)17 HashMap (java.util.HashMap)15 LinkedHashMap (java.util.LinkedHashMap)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 JobId (org.ow2.proactive.scheduler.common.job.JobId)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)7 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)6 Task (org.ow2.proactive.scheduler.common.task.Task)6 TaskVariable (org.ow2.proactive.scheduler.common.task.TaskVariable)6 IOException (java.io.IOException)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)5 SimpleScript (org.ow2.proactive.scripting.SimpleScript)5 TaskScript (org.ow2.proactive.scripting.TaskScript)5 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)4 SimpleJob (functionaltests.jobs.SimpleJob)4 FileNotFoundException (java.io.FileNotFoundException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4