Search in sources :

Example 16 with TaskInfoImpl

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

the class InternalTask method replicate.

/**
 * {@inheritDoc}
 */
@Override
public TaskState replicate() throws ExecutableCreationException {
    /*
         * this implementation deep copies everything using serialization. however the new
         * InternalTask cannot be strictly identical and we have to handle the following special
         * cases:
         *
         * - ExecutableContainer is transient and not copied during serialization. It needs to be
         * manually copied, and added to the InternalTask replica
         *
         * - Using the TaskInfo of _this_ gives us a FINISHED task, need to explicitely create a new
         * clean one.
         *
         * - InternalTask dependencies need to be nulled as they contain references to other
         * InternalTasks, and will be rewritten later anyway
         *
         * - Most of the objects down the object graph contain Hibernate @Id fields. If all those
         * fields are not set to 0 when inserting the object in DB, insertion will fail.
         *
         * - Collections are mapped to specific Hibernate internal collections at runtime, which
         * contain references to the @Id fields mentionned above. They need to be reset too.
         */
    InternalTask replicatedTask = null;
    // ExecutableContainer replicatedContainer = null;
    try {
        // Deep copy of the InternalTask using proactive serialization
        replicatedTask = (InternalTask) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(this);
    } catch (Throwable t) {
        throw new ExecutableCreationException("Failed to serialize task", t);
    }
    replicatedTask.internalJob = internalJob;
    // internalTasksDependencies contain references to other InternalTasks, it needs to be removed.
    // anyway, dependencies for the new task will not be the same as the original
    replicatedTask.internalTasksDependencies = null;
    // the taskinfo needs to be cleaned so that we don't tag this task as finished
    TaskId repId = replicatedTask.taskInfo.getTaskId();
    replicatedTask.taskInfo = new TaskInfoImpl();
    // we only need this id for the HashSet comparisons...
    replicatedTask.taskInfo.setTaskId(repId);
    replicatedTask.taskInfo.setNumberOfExecutionLeft(getMaxNumberOfExecution());
    replicatedTask.taskInfo.setNumberOfExecutionOnFailureLeft(getMaxNumberOfExecutionOnFailure());
    replicatedTask.setReplicatedFrom(this);
    // The next DB.update(InternalJob) will take care of it
    return replicatedTask;
}
Also used : ExecutableCreationException(org.ow2.proactive.scheduler.common.exception.ExecutableCreationException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 17 with TaskInfoImpl

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

the class SchedulingService method getProgressAndPingTaskNode.

void getProgressAndPingTaskNode(RunningTaskData taskData) {
    if (!jobs.canPingTask(taskData) || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) {
        return;
    }
    InternalTask task = taskData.getTask();
    try {
        // (2)
        int progress = taskData.getLauncher().getProgress();
        // get previous inside td
        if (progress != task.getProgress()) {
            // (1)
            task.setProgress(progress);
            // if progress != previously set progress (0 by default) -> update
            listener.taskStateUpdated(taskData.getUser(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        }
    } catch (Throwable t) {
        tlogger.debug(task.getId(), "TaskLauncher is not accessible, checking if the node can be reached.", t);
        pingTaskNodeAndInitiateRestart(task);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 18 with TaskInfoImpl

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

the class TaskData method toTaskInfo.

public TaskInfo toTaskInfo() {
    JobIdImpl jobId = new JobIdImpl(getJobData().getId(), getJobData().getJobName());
    TaskInfoImpl taskInfo = createTaskInfo(jobId);
    return taskInfo;
}
Also used : TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl)

Example 19 with TaskInfoImpl

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

the class LiveJobs method finishInErrorTask.

TerminationData finishInErrorTask(JobId jobId, String taskName) throws UnknownTaskException, UnknownJobException {
    JobData jobData = lockJob(jobId);
    if (jobData == null) {
        throw new UnknownJobException(jobId);
    }
    InternalJob job = jobData.job;
    try {
        InternalTask task = job.getTask(taskName);
        if (task == null) {
            throw new UnknownTaskException(taskName);
        }
        TaskId taskId = task.getId();
        if (task.getStatus() != TaskStatus.IN_ERROR) {
            tlogger.info(task.getId(), "Task must be in state IN_ERROR: " + task.getStatus());
            return emptyResult(task.getId());
        }
        TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, job, task);
        RunningTaskData data = new RunningTaskData(task, job.getOwner(), job.getCredentials(), task.getExecuterInformation().getLauncher());
        TerminationData terminationData = TerminationData.newTerminationData();
        terminationData.addTaskData(job, data, TerminationData.TerminationStatus.ABORTED, taskResult);
        tlogger.debug(taskId, "result added to job " + job.getId());
        // to be done before terminating the task, once terminated it is not
        // running anymore..
        ChangedTasksInfo changesInfo = job.finishInErrorTask(taskId, taskResult, listener);
        boolean jobFinished = job.isFinished();
        // update job info if it is terminated
        if (jobFinished) {
            // terminating job
            job.terminate();
            jlogger.debug(job.getId(), "terminated");
            jobs.remove(job.getId());
            terminationData.addJobToTerminate(job.getId());
        }
        // Update database
        if (taskResult.getAction() != null) {
            dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, taskResult);
        } else {
            dbManager.updateAfterTaskFinished(job, task, taskResult);
        }
        // send event
        listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_IN_ERROR_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        // if this job is finished (every task have finished)
        jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
        if (jobFinished) {
            // send event to client
            listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
            listener.jobUpdatedFullData(job);
        }
        return terminationData;
    } finally {
        jobData.unlock();
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 20 with TaskInfoImpl

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

the class LiveJobs method terminateTask.

private void terminateTask(JobData jobData, InternalTask task, boolean errorOccurred, TaskResultImpl result, TerminationData terminationData) {
    InternalJob job = jobData.job;
    TaskId taskId = task.getId();
    tlogger.debug(taskId, "result added to job " + job.getId());
    // to be done before terminating the task, once terminated it is not
    // running anymore..
    job.getRunningTaskDescriptor(taskId);
    ChangedTasksInfo changesInfo = job.terminateTask(errorOccurred, taskId, listener, result.getAction(), result);
    boolean jobFinished = job.isFinished();
    // update job info if it is terminated
    if (jobFinished) {
        // terminating job
        job.terminate();
        jlogger.debug(job.getId(), "terminated");
        terminationData.addJobToTerminate(job.getId());
    }
    // Update database
    if (result.getAction() != null) {
        dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    } else {
        dbManager.updateAfterTaskFinished(job, task, result);
    }
    // send event
    listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
    // if this job is finished (every task have finished)
    jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
    if (jobFinished) {
        // send event to client
        listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
        listener.jobUpdatedFullData(job);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Aggregations

TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)21 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)15 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)9 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)9 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)8 ArrayList (java.util.ArrayList)7 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)7 Test (org.junit.Test)6 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)6 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)5 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)5 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)5 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)4 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2 ChangedTasksInfo (org.ow2.proactive.scheduler.job.ChangedTasksInfo)2