Search in sources :

Example 31 with UnknownJobException

use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.

the class SchedulerClient method isTaskFinished.

@Override
public boolean isTaskFinished(String jobId, String taskName) throws UnknownJobException, NotConnectedException, PermissionException, UnknownTaskException {
    boolean finished = false;
    try {
        TaskStateData taskStateData = restApi().jobTask(sid, jobId, taskName);
        TaskState taskState = taskState(taskStateData);
        finished = !taskState.getStatus().isTaskAlive();
    } catch (Exception e) {
        throwUJEOrNCEOrPEOrUTE(e);
    }
    return finished;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Example 32 with UnknownJobException

use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskResultsByTag.

@Override
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
    List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
    ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
    for (TaskState currentState : taskStates) {
        String taskName = currentState.getTaskInfo().getName();
        try {
            TaskResult currentResult = getTaskResult(jobId, taskName);
            results.add(currentResult);
        } catch (UnknownTaskException ex) {
            // never occurs because tasks are filtered by tag so they cannot
            // be unknown.
            logger.warn("Unknown task.", ex);
        }
    }
    return results;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) ArrayList(java.util.ArrayList) DataUtility.toTaskResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toTaskResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 33 with UnknownJobException

use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.

the class SchedulerClient method getJobState.

@Override
public JobState getJobState(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = null;
    try {
        JobStateData jobStateData = restApi().listJobs(sid, jobId);
        jobState = toJobState(jobStateData);
    } catch (Exception e) {
        throwUJEOrNCEOrPE(e);
    }
    return jobState;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) DataUtility.toJobState(org.ow2.proactive.scheduler.rest.data.DataUtility.toJobState) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Example 34 with UnknownJobException

use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.

the class SchedulerProxyUserInterfaceTest method testChangeStartAt.

@Test
public void testChangeStartAt() throws NotConnectedException, UnknownJobException, PermissionException {
    JobId jobId = JobIdImpl.makeJobId("66");
    String startAt = "2017-07-07T00:00:00+01:00";
    when(uischedulerMock.changeStartAt(jobId, startAt)).thenReturn(true);
    assertThat(schedulerProxyUserInterface.changeStartAt(jobId, startAt), is(true));
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 35 with UnknownJobException

use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.

the class LiveJobs method preemptTask.

TerminationData preemptTask(JobId jobId, String taskName, int restartDelay) throws UnknownJobException, UnknownTaskException {
    JobData jobData = lockJob(jobId);
    if (jobData == null) {
        throw new UnknownJobException(jobId);
    }
    try {
        InternalTask task = jobData.job.getTask(taskName);
        tlogger.info(task.getId(), "preempting task " + task.getId());
        if (!task.getStatus().isTaskAlive()) {
            tlogger.info(task.getId(), "task isn't alive: " + task.getStatus());
            return emptyResult(task.getId());
        }
        RunningTaskData taskData = runningTasksData.remove(TaskIdWrapper.wrap(task.getId()));
        if (taskData == null) {
            throw new IllegalStateException("Task " + task.getId() + " is not running.");
        }
        TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, jobData.job, task, new TaskPreemptedException("Preempted by admin"), new SimpleTaskLogs("", "Preempted by admin"));
        TerminationData terminationData = createAndFillTerminationData(taskResult, taskData, jobData.job, TerminationData.TerminationStatus.ABORTED);
        long waitTime = restartDelay * 1000L;
        restartTaskOnError(jobData, task, TaskStatus.PENDING, taskResult, waitTime, terminationData);
        return terminationData;
    } finally {
        jobData.unlock();
    }
}
Also used : TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Aggregations

UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)46 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)34 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)33 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)29 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)29 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)29 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)28 Path (javax.ws.rs.Path)24 GET (javax.ws.rs.GET)22 Produces (javax.ws.rs.Produces)22 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)21 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)19 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)17 ArrayList (java.util.ArrayList)16 GZIP (org.jboss.resteasy.annotations.GZIP)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)15 Test (org.junit.Test)12 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)12 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)9