Search in sources :

Example 51 with JobVariable

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

the class SchedulerFrontend method validateJobSignal.

@Override
@ImmediateService
public List<JobVariable> validateJobSignal(String jobId, String signalName, Map<String, String> updatedVariables) throws NotConnectedException, UnknownJobException, PermissionException, SignalApiException, JobValidationException {
    if (updatedVariables == null || updatedVariables.isEmpty()) {
        return null;
    }
    String currentUser = frontendState.getCurrentUser();
    logger.debug("Request to validate signal " + signalName + " on job " + jobId + " received from " + currentUser);
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("addJobSignal", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_SEND_SIGNALS_TO_THIS_JOB);
    String readyPrefix = SignalApiImpl.READY_PREFIX;
    if (StringUtils.isBlank(signalName.trim())) {
        throw new SignalApiException("Empty signals are not allowed");
    }
    try {
        TaskId taskId = createFakeTaskId(jobId);
        publicStore.createChannelIfAbsent(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, true);
        Signal signal = (Signal) publicStore.get(SIGNAL_ORIGINATOR, taskId, signalsChannel + jobId, readyPrefix + signalName);
        if (signal != null) {
            DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
            Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>();
            serializableUpdatedVariables.putAll(updatedVariables);
            validatorServiceProvider.validateVariables(signal.getInputVariables(), serializableUpdatedVariables, this, this);
            return signal.getInputVariables();
        } else {
            throw new SignalApiException("Signal not found");
        }
    } catch (InvalidChannelException e) {
        throw new SignalApiException("Could not read signals channel", e);
    } catch (IOException e) {
        throw new SignalApiException("Could not add signalName for the job " + jobId, e);
    }
}
Also used : InvalidChannelException(org.ow2.proactive.scheduler.synchronization.InvalidChannelException) Signal(org.ow2.proactive.scheduler.signal.Signal) DefaultModelJobValidatorServiceProvider(org.ow2.proactive.scheduler.common.job.factories.spi.model.DefaultModelJobValidatorServiceProvider) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) SignalApiException(org.ow2.proactive.scheduler.signal.SignalApiException) JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 52 with JobVariable

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

the class JobData method createDetailedVariables.

private Map<String, JobVariable> createDetailedVariables() {
    Map<String, JobDataVariable> jobDataVariablesMap = getVariables();
    Map<String, JobVariable> jobVariablesMap = new LinkedHashMap<>(jobDataVariablesMap.size());
    for (JobDataVariable variable : getVariables().values()) {
        jobVariablesMap.put(variable.getName(), new JobVariable(variable.getName(), variable.getValue(), variable.getModel(), variable.getDescription(), variable.getGroup(), variable.getAdvanced(), variable.getHidden()));
    }
    return jobVariablesMap;
}
Also used : JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) LinkedHashMap(java.util.LinkedHashMap)

Example 53 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 54 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)

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