use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TestDataspaceConcurrentKilling method createJobWithFileTransfers.
public Job createJobWithFileTransfers() throws UserException, InvalidScriptException {
TaskFlowJob job = new TaskFlowJob();
job.setName(JOB_NAME);
job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
for (int i = 0; i < NB_TASKS; i++) {
ScriptTask st = new ScriptTask();
st.setName(TASK_NAME + i);
st.setScript(new TaskScript(new SimpleScript("new File(localspace, \"" + FILE_NAME + i + "\").createNewFile(); java.lang.Thread.sleep(1000)", "groovy")));
st.addOutputFiles(FILE_NAME + i, OutputAccessMode.TransferToUserSpace);
job.addTask(st);
}
return job;
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class SchedulerDBManager method toInternalTasks.
private Collection<InternalTask> toInternalTasks(boolean loadFullState, InternalJob internalJob, List<TaskData> taskRuntimeDataList) {
Map<DBTaskId, InternalTask> tasks = new HashMap<>(taskRuntimeDataList.size());
try {
for (TaskData taskData : taskRuntimeDataList) {
InternalTask internalTask = taskData.toInternalTask(internalJob, loadFullState);
if (loadFullState) {
internalTask.setParallelEnvironment(taskData.getParallelEnvironment());
internalTask.setGenericInformation(taskData.getGenericInformation());
for (SelectionScriptData scriptData : taskData.getSelectionScripts()) {
internalTask.addSelectionScript(scriptData.createSelectionScript());
}
if (taskData.getCleanScript() != null) {
internalTask.setCleaningScript(taskData.getCleanScript().createSimpleScript());
}
if (taskData.getPreScript() != null) {
internalTask.setPreScript(taskData.getPreScript().createSimpleScript());
}
if (taskData.getPostScript() != null) {
internalTask.setPostScript(taskData.getPostScript().createSimpleScript());
}
if (taskData.getFlowScript() != null) {
internalTask.setFlowScript(taskData.getFlowScript().createFlowScript());
}
for (SelectorData selectorData : taskData.getDataspaceSelectors()) {
if (selectorData.isInput()) {
InputSelector selector = selectorData.createInputSelector();
internalTask.addInputFiles(selector.getInputFiles(), selector.getMode());
} else {
OutputSelector selector = selectorData.createOutputSelector();
internalTask.addOutputFiles(selector.getOutputFiles(), selector.getMode());
}
}
}
tasks.put(taskData.getId(), internalTask);
}
} catch (InvalidScriptException e) {
throw new DatabaseManagerException("Failed to initialize loaded script", e);
}
for (TaskData taskData : taskRuntimeDataList) {
InternalTask internalTask = tasks.get(taskData.getId());
if (!taskData.getDependentTasks().isEmpty()) {
for (DBTaskId dependent : taskData.getDependentTasks()) {
internalTask.addDependence(tasks.get(dependent));
}
}
if (loadFullState) {
if (taskData.getIfBranch() != null) {
internalTask.setIfBranch(tasks.get(taskData.getIfBranch().getId()));
}
if (!taskData.getJoinedBranches().isEmpty()) {
List<InternalTask> branches = new ArrayList<>(taskData.getJoinedBranches().size());
for (DBTaskId joinedBranch : taskData.getJoinedBranches()) {
branches.add(tasks.get(joinedBranch));
}
internalTask.setJoinedBranches(branches);
}
internalTask.setName(internalTask.getName());
}
}
return tasks.values();
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TaskData method createForkEnvironment.
public ForkEnvironment createForkEnvironment() throws InvalidScriptException {
ForkEnvironment forkEnv = new ForkEnvironment();
forkEnv.setJavaHome(javaHome);
forkEnv.setWorkingDir(workingDir);
List<String> additionalClasspath = getAdditionalClasspath();
if (additionalClasspath != null) {
for (String classpath : additionalClasspath) {
forkEnv.addAdditionalClasspath(classpath);
}
}
List<String> jvmArguments = getJvmArguments();
if (jvmArguments != null) {
for (String jvmArg : jvmArguments) {
forkEnv.addJVMArgument(jvmArg);
}
}
List<EnvironmentModifierData> envModifiers = getEnvModifiers();
if (envModifiers != null) {
for (EnvironmentModifierData envModifier : envModifiers) {
forkEnv.addSystemEnvironmentVariable(envModifier.getName(), envModifier.getValue());
}
}
if (envScript != null) {
forkEnv.setEnvScript(envScript.createSimpleScript());
}
return forkEnv;
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs method createJobWithAllKindOfScripts.
private TaskFlowJob createJobWithAllKindOfScripts() throws InvalidScriptException, UserException {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask t = task("T");
ForkEnvironment forkEnvironment = new ForkEnvironment();
SimpleScript aScript = new SimpleScript("", "");
forkEnvironment.setEnvScript(aScript);
t.setPreScript(aScript);
t.setPostScript(aScript);
t.setCleaningScript(aScript);
t.setSelectionScript(new SelectionScript("", ""));
t.setFlowScript(FlowScript.createContinueFlowScript());
t.setForkEnvironment(forkEnvironment);
jobDef.addTask(t);
return jobDef;
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class TagTest method createLoopTask.
private InternalScriptTask createLoopTask(String name, String scriptContent, InternalTask[] dependences, String targetName, boolean block) throws InvalidScriptException {
FlowBlock fb = null;
if (block) {
fb = FlowBlock.END;
}
InternalScriptTask result = createTask(name, dependences, fb, targetName);
FlowScript loop = FlowScript.createLoopFlowScript(scriptContent, targetName);
result.setFlowScript(loop);
return result;
}
Aggregations