use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class TaskData method taskDataVariableToTaskVariable.
private static TaskVariable taskDataVariableToTaskVariable(TaskDataVariable taskDataVariable) {
if (taskDataVariable == null) {
return null;
}
TaskVariable taskVariable = new TaskVariable();
taskVariable.setJobInherited(taskDataVariable.isJobInherited());
taskVariable.setModel(taskDataVariable.getModel());
taskVariable.setValue(taskDataVariable.getValue());
taskVariable.setName(taskDataVariable.getName());
taskVariable.setDescription(taskDataVariable.getDescription());
taskVariable.setGroup(taskDataVariable.getGroup());
taskVariable.setAdvanced(taskDataVariable.getAdvanced());
return taskVariable;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class TaskData method createTaskData.
static TaskData createTaskData(JobData jobRuntimeData, InternalScriptTask task) {
TaskData taskData = new TaskData();
TaskData.DBTaskId taskId = new DBTaskId();
taskId.setJobId(jobRuntimeData.getId());
taskId.setTaskId(task.getTaskInfo().getTaskId().longValue());
taskData.setId(taskId);
taskData.setOwner(jobRuntimeData.getOwner());
taskData.setDescription(task.getDescription());
taskData.setTag(task.getTag());
taskData.setParallelEnvironment(task.getParallelEnvironment());
taskData.setFlowBlock(task.getFlowBlock());
taskData.setRestartMode(task.getRestartTaskOnError());
taskData.setPreciousLogs(task.isPreciousLogs());
taskData.setPreciousResult(task.isPreciousResult());
taskData.setRunAsMe(task.isRunAsMe());
taskData.setWallTime(task.getWallTime());
taskData.setOnTaskErrorString(task.getOnTaskErrorProperty().getValue());
taskData.setRetryDelay(task.getTaskRetryDelay());
taskData.setMaxNumberOfExecution(task.getMaxNumberOfExecution());
taskData.setJobData(jobRuntimeData);
taskData.setNumberOfExecutionOnFailureLeft(PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.getValueAsInt());
taskData.setNumberOfExecutionLeft(task.getMaxNumberOfExecution());
taskData.setGenericInformation(task.getGenericInformation());
HashMap<String, TaskDataVariable> variables = new LinkedHashMap<>();
for (Map.Entry<String, TaskVariable> entry : task.getVariables().entrySet()) {
variables.put(entry.getKey(), TaskDataVariable.create(entry.getKey(), entry.getValue(), taskData));
}
taskData.setVariables(variables);
// set the scheduledTime if the START_AT property exists
Map<String, String> genericInfos = taskData.getGenericInformation();
if (genericInfos != null && genericInfos.containsKey(CommonAttribute.GENERIC_INFO_START_AT_KEY) && !genericInfos.get(CommonAttribute.GENERIC_INFO_START_AT_KEY).contains(VariableSubstitutor.SUBSITUTE_PREFIX_SIMPLE)) {
// parse the START_AT if it's available and not dynamically defined
long scheduledTime = ISO8601DateUtil.toDate(genericInfos.get(CommonAttribute.GENERIC_INFO_START_AT_KEY)).getTime();
taskData.setScheduledTime(scheduledTime);
task.setScheduledTime(scheduledTime);
}
taskData.updateMutableAttributes(task);
if (task.getSelectionScripts() != null) {
List<SelectionScriptData> scripts = new ArrayList<>(task.getSelectionScripts().size());
long order = 0;
for (SelectionScript selectionScript : task.getSelectionScripts()) {
final SelectionScriptData aSelectionScript = SelectionScriptData.createForSelectionScript(selectionScript, taskData);
aSelectionScript.setOrder(order++);
scripts.add(aSelectionScript);
}
taskData.setSelectionScripts(scripts);
}
if (task.getExecutableContainer() != null) {
taskData.setScript(ScriptData.createForScript(((ScriptExecutableContainer) task.getExecutableContainer()).getScript(), taskData));
}
if (task.getPreScript() != null) {
taskData.setPreScript(ScriptData.createForScript(task.getPreScript(), taskData));
}
if (task.getPostScript() != null) {
taskData.setPostScript(ScriptData.createForScript(task.getPostScript(), taskData));
}
if (task.getCleaningScript() != null) {
taskData.setCleanScript(ScriptData.createForScript(task.getCleaningScript(), taskData));
}
if (task.getFlowScript() != null) {
taskData.setFlowScript(ScriptData.createForFlowScript(task.getFlowScript(), taskData));
}
List<SelectorData> selectorsData = new ArrayList<>();
if (task.getInputFilesList() != null) {
for (InputSelector selector : task.getInputFilesList()) {
selectorsData.add(SelectorData.createForInputSelector(selector, taskData));
}
}
if (task.getOutputFilesList() != null) {
for (OutputSelector selector : task.getOutputFilesList()) {
selectorsData.add(SelectorData.createForOutputSelector(selector, taskData));
}
}
long order = 0;
for (SelectorData selectorData : selectorsData) {
selectorData.setOrder(order++);
}
taskData.setDataspaceSelectors(selectorsData);
ForkEnvironment forkEnvironment = task.getForkEnvironment();
if (forkEnvironment != null) {
taskData.setAdditionalClasspath(forkEnvironment.getAdditionalClasspath());
taskData.setJavaHome(forkEnvironment.getJavaHome());
taskData.setJvmArguments(forkEnvironment.getJVMArguments());
taskData.setWorkingDir(forkEnvironment.getWorkingDir());
if (forkEnvironment.getEnvScript() != null) {
taskData.setEnvScript(ScriptData.createForScript(forkEnvironment.getEnvScript(), taskData));
}
Map<String, String> systemEnvironment = forkEnvironment.getSystemEnvironment();
if (systemEnvironment != null) {
List<EnvironmentModifierData> envModifiers = new ArrayList<>(systemEnvironment.size());
for (Map.Entry<String, String> entry : systemEnvironment.entrySet()) {
envModifiers.add(EnvironmentModifierData.create(new PropertyModifier(entry.getKey(), entry.getValue()), taskData));
}
taskData.setEnvModifiers(new HashSet<>(envModifiers));
}
}
taskData.initTaskType(task);
return taskData;
}
use of org.ow2.proactive.scheduler.common.task.TaskVariable in project scheduling by ow2-proactive.
the class SpelValidatorTest method createTask.
private Task createTask() throws UserException {
Task task = new JavaTask();
task.setVariables(ImmutableMap.of("var1", new TaskVariable("var1", "value1", "model1", "", "group1", false, false, false), "var2", new TaskVariable("var2", "value2", "model2", "", "group1", false, true, false), "var3", new TaskVariable("var3", "", "", "", "group2", false, false, false), "var4", new TaskVariable("var4", null, null, "", "group2", false, false, false)));
task.setName("task1");
return task;
}
Aggregations