use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsGlobalURI.
@Test
public void testAddBindingsToScriptHandlerContainsGlobalURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, testSetString), null, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_GLOBAL_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsUserURI.
@Test
public void testAddBindingsToScriptHandlerContainsUserURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, testSetString, null), null, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_USER_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class TaskData method toInternalTask.
InternalTask toInternalTask(InternalJob internalJob, boolean loadFullState) throws InvalidScriptException {
TaskId taskId = createTaskId(internalJob);
InternalTask internalTask;
if (taskType.equals(SCRIPT_TASK)) {
internalTask = new InternalScriptTask(internalJob);
} else if (taskType.equals(FORKED_SCRIPT_TASK)) {
internalTask = new InternalForkedScriptTask(internalJob);
} else {
throw new IllegalStateException("Unexpected stored task type: " + taskType);
}
internalTask.setId(taskId);
internalTask.setDescription(getDescription());
internalTask.setTag(this.getTag());
internalTask.setStatus(getTaskStatus());
internalTask.setJobInfo(internalJob.getJobInfo());
internalTask.setName(getTaskName());
internalTask.setExecutionDuration(getExecutionDuration());
internalTask.setFinishedTime(getFinishedTime());
internalTask.setInErrorTime(getInErrorTime());
internalTask.setStartTime(getStartTime());
internalTask.setScheduledTime(getScheduledTime());
internalTask.setExecutionHostName(getExecutionHostName());
internalTask.setOnTaskError(OnTaskError.getInstance(this.onTaskErrorString));
internalTask.setPreciousLogs(isPreciousLogs());
internalTask.setPreciousResult(isPreciousResult());
internalTask.setRunAsMe(isRunAsMe());
internalTask.setWallTime(getWallTime());
internalTask.setMaxNumberOfExecution(getMaxNumberOfExecution());
internalTask.setNumberOfExecutionLeft(getNumberOfExecutionLeft());
internalTask.setNumberOfExecutionOnFailureLeft(getNumberOfExecutionOnFailureLeft());
internalTask.setRestartTaskOnError(getRestartMode());
internalTask.setFlowBlock(getFlowBlock());
internalTask.setIterationIndex(getIteration());
internalTask.setReplicationIndex(getReplication());
internalTask.setMatchingBlock(getMatchingBlock());
internalTask.setVariables(variablesToTaskVariables());
if (hasAliveTaskLauncher() && getExecuterInformationData() != null) {
internalTask.setExecuterInformation(getExecuterInformationData().toExecuterInformation(loadFullState));
}
ForkEnvironment forkEnv = createForkEnvironment();
internalTask.setForkEnvironment(forkEnv);
return internalTask;
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class InternalJobFactory method createTask.
/**
* Create an internal native Task with the given native task (user)
*
* @param task the user native task that will be used to create the internal native task.
* @return the created internal task.
* @throws JobCreationException an exception if the factory cannot create the given task.
*/
private static InternalTask createTask(Job userJob, InternalJob internalJob, NativeTask task) throws JobCreationException {
if (((task.getCommandLine() == null) || (task.getCommandLine().length == 0))) {
String msg = "The command line is null or empty and not generated !";
logger.info(msg);
throw new JobCreationException(msg);
}
try {
String commandAndArguments = "\"" + Joiner.on("\" \"").join(task.getCommandLine()) + "\"";
InternalTask scriptTask;
if (isForkingTask()) {
scriptTask = new InternalForkedScriptTask(new ScriptExecutableContainer(new TaskScript(new SimpleScript(commandAndArguments, "native"))), internalJob);
configureRunAsMe(task);
} else {
scriptTask = new InternalScriptTask(new ScriptExecutableContainer(new TaskScript(new SimpleScript(commandAndArguments, "native"))), internalJob);
}
ForkEnvironment forkEnvironment = new ForkEnvironment();
scriptTask.setForkEnvironment(forkEnvironment);
// set task common properties
setTaskCommonProperties(userJob, task, scriptTask);
return scriptTask;
} catch (Exception e) {
throw new JobCreationException(e);
}
}
use of org.ow2.proactive.scheduler.common.task.ForkEnvironment in project scheduling by ow2-proactive.
the class InternalTask method getDefaultTaskLauncherInitializer.
/**
* Prepare and return the default task launcher initializer (ie the one that works for every launcher)<br>
* Concrete launcher may have to add values to the created initializer to bring more information to the launcher.
*
* @return the default created task launcher initializer
*/
protected TaskLauncherInitializer getDefaultTaskLauncherInitializer() {
TaskLauncherInitializer tli = new TaskLauncherInitializer();
tli.setTaskId(getId());
tli.setJobOwner(internalJob.getJobInfo().getJobOwner());
tli.setSchedulerRestUrl(PASchedulerProperties.SCHEDULER_REST_URL.getValueAsStringOrNull());
tli.setCatalogRestUrl(PASchedulerProperties.CATALOG_REST_URL.getValueAsStringOrNull());
tli.setPreScript(getPreScript());
tli.setPostScript(getPostScript());
tli.setControlFlowScript(getFlowScript());
tli.setTaskInputFiles(getInputFilesList());
tli.setTaskOutputFiles(getOutputFilesList());
tli.setNamingService(internalJob.getTaskDataSpaceApplications().get(getId().longValue()).getNamingServiceStub());
tli.setIterationIndex(getIterationIndex());
tli.setReplicationIndex(getReplicationIndex());
Map<String, String> gInfo = getRuntimeGenericInformation();
tli.setGenericInformation(gInfo);
ForkEnvironment environment = getForkEnvironment();
if (environment != null) {
Script environmentScript = environment.getEnvScript();
if ((environmentScript != null) && !isScriptAuthorized(getId(), environmentScript)) {
tli.setAuthorizedForkEnvironmentScript(false);
}
}
tli.setForkEnvironment(getForkEnvironment());
if (isWallTimeSet()) {
tli.setWalltime(wallTime);
}
tli.setPreciousLogs(isPreciousLogs());
tli.setJobVariables(internalJob.getVariables());
tli.setTaskVariables(getVariables());
tli.setPingPeriod(PASchedulerProperties.SCHEDULER_NODE_PING_FREQUENCY.getValueAsInt());
tli.setPingAttempts(PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt());
return tli;
}
Aggregations