Search in sources :

Example 1 with InternalForkedScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask 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;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 2 with InternalForkedScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask 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);
    }
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) SimpleScript(org.ow2.proactive.scripting.SimpleScript) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Example 3 with InternalForkedScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask in project scheduling by ow2-proactive.

the class InternalJobFactory method createTask.

/**
 * Create an internal java Task with the given java task (user)
 *
 * @param task the user java task that will be used to create the internal java task.
 * @return the created internal task.
 * @throws JobCreationException an exception if the factory cannot create the given task.
 */
@SuppressWarnings("unchecked")
private static InternalTask createTask(Job userJob, InternalJob internalJob, JavaTask task) throws JobCreationException {
    InternalTask javaTask;
    if (task.getExecutableClassName() != null) {
        HashMap<String, byte[]> args = task.getSerializedArguments();
        try {
            if (isForkingTask()) {
                javaTask = new InternalForkedScriptTask(new ScriptExecutableContainer(new TaskScript(new SimpleScript(task.getExecutableClassName(), JavaClassScriptEngineFactory.JAVA_CLASS_SCRIPT_ENGINE_NAME, new Serializable[] { args }))), internalJob);
                javaTask.setForkEnvironment(task.getForkEnvironment());
                configureRunAsMe(task);
            } else {
                javaTask = new InternalScriptTask(new ScriptExecutableContainer(new TaskScript(new SimpleScript(task.getExecutableClassName(), JavaClassScriptEngineFactory.JAVA_CLASS_SCRIPT_ENGINE_NAME, new Serializable[] { args }))), internalJob);
            }
        } catch (InvalidScriptException e) {
            throw new JobCreationException(e);
        }
    } else {
        String msg = "You must specify your own executable task class to be launched (in every task)!";
        logger.info(msg);
        throw new JobCreationException(msg);
    }
    // set task common properties
    try {
        setTaskCommonProperties(userJob, task, javaTask);
    } catch (Exception e) {
        throw new JobCreationException(e);
    }
    return javaTask;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Example 4 with InternalForkedScriptTask

use of org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask in project scheduling by ow2-proactive.

the class InternalJobFactory method createTask.

private static InternalTask createTask(Job userJob, InternalJob internalJob, ScriptTask task) throws JobCreationException {
    InternalTask scriptTask;
    if (isForkingTask()) {
        scriptTask = new InternalForkedScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
        configureRunAsMe(task);
    } else {
        scriptTask = new InternalScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
    }
    // set task common properties
    try {
        setTaskCommonProperties(userJob, task, scriptTask);
    } catch (Exception e) {
        throw new JobCreationException(e);
    }
    return scriptTask;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Aggregations

InternalForkedScriptTask (org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask)4 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)4 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)4 InternalException (org.ow2.proactive.scheduler.common.exception.InternalException)3 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)3 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)3 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)3 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)2 SimpleScript (org.ow2.proactive.scripting.SimpleScript)2 TaskScript (org.ow2.proactive.scripting.TaskScript)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)1