Search in sources :

Example 26 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultData method createTaskResultData.

static TaskResultData createTaskResultData(TaskData taskRuntimeData, TaskResultImpl result) {
    TaskResultData resultData = new TaskResultData();
    resultData.setTaskRuntimeData(taskRuntimeData);
    resultData.setLogs(result.getOutput());
    resultData.setPreviewerClassName(result.getPreviewerClassName());
    resultData.setMetadata(result.getMetadata());
    resultData.setPropagatedVariables(result.getPropagatedVariables());
    resultData.setSerializedException(result.getSerializedException());
    resultData.setSerializedValue(result.getSerializedValue());
    resultData.setResultTime(System.currentTimeMillis());
    resultData.setRaw(result.isRaw());
    FlowAction flowAction = result.getAction();
    if (flowAction != null) {
        FlowActionData actionData = new FlowActionData();
        actionData.setDupNumber(flowAction.getDupNumber());
        actionData.setTarget(flowAction.getTarget());
        actionData.setTargetContinuation(flowAction.getTargetContinuation());
        actionData.setTargetElse(flowAction.getTargetElse());
        actionData.setType(flowAction.getType());
        resultData.setFlowAction(actionData);
    }
    return resultData;
}
Also used : FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction)

Example 27 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultCreator method getTaskResult.

public TaskResultImpl getTaskResult(SchedulerDBManager dbManager, InternalJob job, InternalTask task, Throwable exception, TaskLogs output) throws UnknownTaskException {
    if (task == null) {
        throw new UnknownTaskException();
    }
    JobDescriptor jobDescriptor = job.getJobDescriptor();
    EligibleTaskDescriptor eligibleTaskDescriptor = null;
    if (jobDescriptor.getPausedTasks().get(task.getId()) != null) {
        eligibleTaskDescriptor = (EligibleTaskDescriptor) jobDescriptor.getPausedTasks().get(task.getId());
    } else if (jobDescriptor.getRunningTasks().get(task.getId()) != null) {
        eligibleTaskDescriptor = (EligibleTaskDescriptor) jobDescriptor.getRunningTasks().get(task.getId());
    }
    TaskResultImpl taskResult = getEmptyTaskResult(task, exception, output);
    taskResult.setPropagatedVariables(getPropagatedVariables(dbManager, eligibleTaskDescriptor, job, task));
    return taskResult;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)

Example 28 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class InternalJob method finishInErrorTask.

public ChangedTasksInfo finishInErrorTask(TaskId taskId, TaskResultImpl result, SchedulerStateUpdate frontend) {
    FlowAction action = result.getAction();
    ChangedTasksInfo changedTasksInfo = terminateTask(false, taskId, frontend, action, result, true);
    setUnPause();
    return changedTasksInfo;
}
Also used : FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction)

Example 29 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class InternalJob method terminateTask.

/**
 * Terminate a task, change status, managing dependencies
 * <p>
 * Also, apply a Control Flow Action if provided. This may alter the number
 * of tasks in the job, events have to be sent accordingly.
 *
 * @param errorOccurred has an error occurred for this termination
 * @param taskId        the task to terminate.
 * @param frontend      Used to notify all listeners of the replication of tasks,
 *                      triggered by the FlowAction
 * @param action        a Control Flow Action that will potentially create new tasks
 *                      inside the job
 * @return the taskDescriptor that has just been terminated.
 */
public ChangedTasksInfo terminateTask(boolean errorOccurred, TaskId taskId, SchedulerStateUpdate frontend, FlowAction action, TaskResultImpl result, boolean taskIsPaused) {
    final InternalTask descriptor = tasks.get(taskId);
    if (!errorOccurred) {
        decreaseNumberOfFaultyTasks(taskId);
    }
    descriptor.setFinishedTime(System.currentTimeMillis());
    descriptor.setStatus(errorOccurred ? TaskStatus.FAULTY : TaskStatus.FINISHED);
    descriptor.setExecutionDuration(result.getTaskDuration());
    if (taskIsPaused) {
        setNumberOfInErrorTasks(getNumberOfInErrorTasks() - 1);
    } else {
        setNumberOfRunningTasks(getNumberOfRunningTasks() - 1);
    }
    setNumberOfFinishedTasks(getNumberOfFinishedTasks() + 1);
    if ((getStatus() == JobStatus.RUNNING) && (getNumberOfRunningTasks() == 0) && !taskIsPaused) {
        setStatus(JobStatus.STALLED);
    }
    ChangedTasksInfo changesInfo = new ChangedTasksInfo();
    changesInfo.taskUpdated(descriptor);
    boolean didAction = false;
    if (action != null) {
        InternalTask initiator = tasks.get(taskId);
        switch(action.getType()) {
            /*
                 * LOOP action
                 */
            case LOOP:
                {
                    didAction = terminateLoopHandler.terminateLoopTask(action, initiator, changesInfo, frontend);
                    break;
                }
            /*
                 * IF action
                 */
            case IF:
                {
                    didAction = terminateIfTaskHandler.terminateIfTask(action, initiator, changesInfo, frontend, descriptor, taskId);
                    break;
                }
            /*
                 * REPLICATE action
                 */
            case REPLICATE:
                {
                    didAction = terminateReplicateTaskHandler.terminateReplicateTask(action, initiator, changesInfo, frontend, taskId);
                    break;
                }
            /*
                 * CONTINUE action : - continue taskflow as if no action was provided
                 */
            case CONTINUE:
                LOGGER.debug("Task flow Action CONTINUE on task " + initiator.getId().getReadableName());
                break;
            default:
                LOGGER.warn("There are inconsistency between InternalJob and FlowActionType classes.");
                break;
        }
    /**
     * System.out.println("******** task dump ** " +
     * this.getJobInfo().getJobId() + " " + initiator.getName() +
     * " does " + action.getType() + " " + ((action.getTarget() == null)
     * ? "." : action.getTarget()) + " " + ((action.getTargetElse() ==
     * null) ? "." : action.getTargetElse()) + " " +
     * ((action.getTargetJoin() == null) ? "." :
     * action.getTargetJoin())); for (InternalTask it :
     * this.tasks.values()) { System.out.print(it.getName() + " "); if
     * (it.getIDependences() != null) { System.out.print("deps "); for
     * (InternalTask parent : it.getIDependences()) {
     * System.out.print(parent.getName() + " "); } } if
     * (it.getIfBranch() != null) { System.out.print("if " +
     * it.getIfBranch().getName() + " "); } if (it.getJoinedBranches()
     * != null && it.getJoinedBranches().size() == 2) {
     * System.out.print("join " +
     * it.getJoinedBranches().get(0).getName() + " " +
     * it.getJoinedBranches().get(1).getName()); } System.out.println();
     * } System.out.println("******** task dump ** " +
     * this.getJobInfo().getJobId()); System.out.println();
     */
    }
    // terminate this task
    if (!didAction) {
        getJobDescriptor().terminate(taskId, taskIsPaused);
    }
    return changesInfo;
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 30 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TestJobRemove method testRuntimeDataRemoveAfterFinish.

@Test
public void testRuntimeDataRemoveAfterFinish() throws Throwable {
    TaskFlowJob jobDef = createJob(2);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
    job.setStatus(JobStatus.FINISHED);
    dbManager.updateAfterTaskFinished(job, null, null);
    checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
    // check can still load task results
    Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
    Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
    Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobContent(org.ow2.proactive.scheduler.core.db.JobContent) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResultData(org.ow2.proactive.scheduler.core.db.TaskResultData) JobData(org.ow2.proactive.scheduler.core.db.JobData) TaskData(org.ow2.proactive.scheduler.core.db.TaskData) Test(org.junit.Test)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)73 Test (org.junit.Test)70 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)32 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)30 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)26 SimpleScript (org.ow2.proactive.scripting.SimpleScript)26 TaskScript (org.ow2.proactive.scripting.TaskScript)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)25 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)25 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)22 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)16 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)15 HashMap (java.util.HashMap)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10