Search in sources :

Example 11 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class LiveJobs method unpauseAll.

void unpauseAll() {
    for (JobId jobId : jobs.keySet()) {
        JobData jobData = lockJob(jobId);
        if (jobData != null) {
            try {
                InternalJob job = jobData.job;
                if (job.getStatus() == JobStatus.PAUSED) {
                    job.setUnPause();
                    dbManager.updateJobAndTasksState(job);
                    updateJobInSchedulerState(job, SchedulerEvent.JOB_RESUMED);
                }
            } finally {
                jobData.unlock();
            }
        }
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 12 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class LiveJobs method restartWaitingTask.

void restartWaitingTask(TaskId taskId) {
    JobData jobData = lockJob(taskId.getJobId());
    if (jobData == null) {
        return;
    }
    try {
        InternalTask task = jobData.job.getTask(taskId);
        if (!task.getStatus().isTaskAlive()) {
            tlogger.warn(taskId, "task to be restarted isn't alive " + task.getStatus());
            return;
        }
        jobData.job.reStartTask(task);
    } catch (UnknownTaskException e) {
        logger.error("Unexpected exception", e);
    } finally {
        jobData.unlock();
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 13 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class LiveJobs method resumeJob.

boolean resumeJob(JobId jobId) {
    JobData jobData = lockJob(jobId);
    if (jobData == null) {
        return false;
    }
    try {
        InternalJob job = jobData.job;
        Set<TaskId> updatedTasks = job.setUnPause();
        if (!updatedTasks.isEmpty()) {
            jlogger.info(jobId, "has just been resumed.");
            dbManager.updateJobAndTasksState(job);
            updateTasksInSchedulerState(job, updatedTasks);
        }
        // update tasks events list and send it to front-end
        updateJobInSchedulerState(job, SchedulerEvent.JOB_RESUMED);
        return !updatedTasks.isEmpty();
    } finally {
        jobData.unlock();
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId)

Example 14 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class LiveJobs method suspendTaskOnError.

private void suspendTaskOnError(JobData jobData, InternalTask task, long taskDuration) {
    InternalJob job = jobData.job;
    job.setInErrorTime(System.currentTimeMillis());
    job.setTaskPausedOnError(task);
    setJobStatusToInErrorIfNotPaused(job);
    job.incrementNumberOfInErrorTasksBy(1);
    task.setInErrorTime(task.getStartTime() + taskDuration);
    dbManager.updateJobAndTasksState(job);
    updateTaskPausedOnerrorState(job, task.getId());
    updateJobInSchedulerState(job, SchedulerEvent.JOB_IN_ERROR);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob)

Example 15 with JobData

use of org.ow2.proactive.scheduler.core.db.JobData in project scheduling by ow2-proactive.

the class LiveJobs method restartTaskOnNodeFailure.

private void restartTaskOnNodeFailure(InternalTask task, JobData jobData, TerminationData terminationData) {
    final String errorMsg = "An error has occurred due to a node failure and the maximum amount of retries property has been reached.";
    task.setProgress(0);
    task.decreaseNumberOfExecutionOnFailureLeft();
    tlogger.info(task.getId(), "number of retry on failure left " + task.getNumberOfExecutionOnFailureLeft());
    InternalJob job = jobData.job;
    if (task.getNumberOfExecutionOnFailureLeft() > 0) {
        task.setStatus(TaskStatus.WAITING_ON_FAILURE);
        job.newWaitingTask();
        listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_WAITING_FOR_RESTART, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        job.reStartTask(task);
        dbManager.taskRestarted(job, task, null);
        tlogger.info(task.getId(), " is waiting for restart");
    } else {
        job.incrementNumberOfFailedTasksBy(1);
        endJob(jobData, terminationData, task, null, errorMsg, JobStatus.FAILED);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)20 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)10 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)8 Test (org.junit.Test)7 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)4 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)4 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)2