Search in sources :

Example 1 with JobStatus

use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.

the class AbstractFunctCmdTest method submitJob.

protected JobId submitJob(String filename, JobStatus waitForStatus) throws Exception {
    File jobFile = new File(this.getClass().getResource("config/" + filename).toURI());
    WorkflowSubmitter submitter = new WorkflowSubmitter(scheduler);
    JobId id = submitter.submit(jobFile, new HashMap<String, String>());
    waitJobState(id, waitForStatus, 500000);
    return id;
}
Also used : WorkflowSubmitter(org.ow2.proactive_grid_cloud_portal.scheduler.WorkflowSubmitter) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 2 with JobStatus

use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.

the class LiveJobs method endJob.

private void endJob(JobData jobData, TerminationData terminationData, InternalTask task, TaskResultImpl taskResult, String errorMsg, JobStatus jobStatus) {
    JobId jobId = jobData.job.getId();
    jobs.remove(jobId);
    terminationData.addJobToTerminate(jobId);
    InternalJob job = jobData.job;
    SchedulerEvent event;
    if (job.getStatus() == JobStatus.PENDING) {
        event = SchedulerEvent.JOB_PENDING_TO_FINISHED;
    } else {
        event = SchedulerEvent.JOB_RUNNING_TO_FINISHED;
    }
    if (task != null) {
        jlogger.info(job.getId(), "ending request caused by task " + task.getId());
    } else {
        jlogger.info(job.getId(), "ending request");
    }
    for (Iterator<RunningTaskData> i = runningTasksData.values().iterator(); i.hasNext(); ) {
        RunningTaskData taskData = i.next();
        if (taskData.getTask().getJobId().equals(jobId)) {
            i.remove();
            // remove previous read progress
            taskData.getTask().setProgress(0);
            terminationData.addTaskData(job, taskData, TerminationData.TerminationStatus.ABORTED, taskResult);
        }
    }
    // if job has been killed
    if (jobStatus == JobStatus.KILLED) {
        Set<TaskId> tasksToUpdate = job.failed(null, jobStatus);
        dbManager.updateAfterJobKilled(job, tasksToUpdate);
        updateTasksInSchedulerState(job, tasksToUpdate);
    } else {
        // finished state (failed/canceled)
        if (jobStatus != JobStatus.FINISHED) {
            Set<TaskId> tasksToUpdate = job.failed(task.getId(), jobStatus);
            // store the exception into jobResult / To prevent from empty
            // task result (when job canceled), create one
            boolean noResult = (jobStatus == JobStatus.CANCELED && taskResult == null);
            if (jobStatus == JobStatus.FAILED || noResult) {
                taskResult = new TaskResultImpl(task.getId(), new Exception(errorMsg), new SimpleTaskLogs("", errorMsg), -1);
            }
            dbManager.updateAfterJobFailed(job, task, taskResult, tasksToUpdate);
            updateTasksInSchedulerState(job, tasksToUpdate);
        }
    }
    // update job and tasks events list and send it to front-end
    updateJobInSchedulerState(job, event);
    jlogger.info(job.getId(), "finished (" + jobStatus + ")");
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent)

Example 3 with JobStatus

use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.

the class InternalJob method failed.

/**
 * Failed this job due to the given task failure or job has been killed
 *
 * @param taskId    the task that has been the cause to failure. Can be null if
 *                  the job has been killed
 * @param jobStatus type of the failure on this job. (failed/canceled/killed)
 */
public Set<TaskId> failed(TaskId taskId, JobStatus jobStatus) {
    if (jobStatus != JobStatus.KILLED) {
        InternalTask descriptor = tasks.get(taskId);
        if (descriptor.getStartTime() > 0) {
            descriptor.setFinishedTime(System.currentTimeMillis());
            setNumberOfFinishedTasks(getNumberOfFinishedTasks() + 1);
            if (descriptor.getExecutionDuration() < 0) {
                descriptor.setExecutionDuration(descriptor.getFinishedTime() - descriptor.getStartTime());
            }
        }
        descriptor.setStatus((jobStatus == JobStatus.FAILED) ? TaskStatus.FAILED : TaskStatus.FAULTY);
        // terminate this job descriptor
        getJobDescriptor().failed();
    }
    // set the new status of the job
    setFinishedTime(System.currentTimeMillis());
    setNumberOfPendingTasks(0);
    setNumberOfRunningTasks(0);
    setStatus(jobStatus);
    // creating list of status
    Set<TaskId> updatedTasks = new HashSet<>();
    for (InternalTask td : tasks.values()) {
        if (!td.getId().equals(taskId)) {
            if (td.getStatus() == TaskStatus.RUNNING) {
                td.setStatus(TaskStatus.ABORTED);
                td.setFinishedTime(System.currentTimeMillis());
                if (td.getStartTime() > 0 && td.getExecutionDuration() < 0) {
                    td.setExecutionDuration(td.getFinishedTime() - td.getStartTime());
                }
                updatedTasks.add(td.getId());
            } else if (td.getStatus() == TaskStatus.WAITING_ON_ERROR || td.getStatus() == TaskStatus.WAITING_ON_FAILURE) {
                td.setStatus(TaskStatus.NOT_RESTARTED);
                updatedTasks.add(td.getId());
            } else if (td.getStatus() != TaskStatus.FINISHED && td.getStatus() != TaskStatus.FAILED && td.getStatus() != TaskStatus.FAULTY && td.getStatus() != TaskStatus.SKIPPED) {
                td.setStatus(TaskStatus.NOT_STARTED);
                updatedTasks.add(td.getId());
            }
        }
    }
    terminateTaskDataSpaceApplications();
    return updatedTasks;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashSet(java.util.HashSet)

Example 4 with JobStatus

use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.

the class RecoveredSchedulerStateTest method createJob.

public InternalJob createJob(JobStatus jobStatus, int id) {
    InternalTaskFlowJob job = new InternalTaskFlowJob("MyJob", JobPriority.HIGH, OnTaskError.CANCEL_JOB, "Description");
    InternalScriptTask internalScriptTask = new InternalScriptTask(job);
    job.addTasks(ImmutableList.<InternalTask>of(internalScriptTask));
    job.setId(JobIdImpl.makeJobId("" + id));
    JobInfoImpl jobInfo = (JobInfoImpl) job.getJobInfo();
    jobInfo.setStatus(jobStatus);
    return job;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 5 with JobStatus

use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithMixedJobs.

@Test
public void testRecoverWithMixedJobs() throws Exception {
    ImmutableList<JobStatus> jobStatuses = ImmutableList.of(JobStatus.CANCELED, JobStatus.FAILED, JobStatus.FINISHED, JobStatus.KILLED, JobStatus.PAUSED, JobStatus.PENDING, JobStatus.RUNNING, JobStatus.STALLED);
    ImmutableList<TaskStatus> taskStatuses = ImmutableList.of(TaskStatus.ABORTED, TaskStatus.FAILED, TaskStatus.FINISHED, TaskStatus.ABORTED, TaskStatus.PAUSED, TaskStatus.PENDING, TaskStatus.RUNNING, TaskStatus.SUBMITTED);
    List<InternalJob> jobs = new ArrayList<>(jobStatuses.size());
    for (int i = 0; i < jobStatuses.size(); i++) {
        InternalJob job = createJob(jobStatuses.get(i));
        jobs.add(job);
        changeTasksState(job, taskStatuses.get(i));
    }
    RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
    assertThat(recoveredState.getFinishedJobs()).hasSize(4);
    assertThat(recoveredState.getPendingJobs()).hasSize(2);
    assertThat(recoveredState.getRunningJobs()).hasSize(2);
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) Test(org.junit.Test)

Aggregations

JobStatus (org.ow2.proactive.scheduler.common.job.JobStatus)6 JobId (org.ow2.proactive.scheduler.common.job.JobId)5 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)4 Test (org.junit.Test)3 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)3 SchedulerEvent (org.ow2.proactive.scheduler.common.SchedulerEvent)2 Job (org.ow2.proactive.scheduler.common.job.Job)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)2 ErrorTask (functionaltests.jobs.ErrorTask)1 LogTask (functionaltests.jobs.LogTask)1 MetadataTask (functionaltests.jobs.MetadataTask)1 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)1 RawTask (functionaltests.jobs.RawTask)1 SimpleJob (functionaltests.jobs.SimpleJob)1 VariableTask (functionaltests.jobs.VariableTask)1