Search in sources :

Example 61 with UnknownJobException

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

the class RunningTaskRecoveryWithDownNodeTest method checkJobResult.

private void checkJobResult(JobId jobid, Scheduler scheduler) throws NotConnectedException, PermissionException, UnknownJobException {
    JobResult jobResult = scheduler.getJobResult(jobid);
    Assert.assertFalse(jobResult.hadException());
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult)

Example 62 with UnknownJobException

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

the class SchedulingServiceTest4 method testTaskRestart1.

@Test
public void testTaskRestart1() throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    JobDescriptor jobDesc = startTask();
    try {
        service.restartTask(jobDesc.getJobId(), "invalid task name", 100);
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.restartTask(JobIdImpl.makeJobId("1234567"), "javaTask", 100);
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    service.restartTask(jobDesc.getJobId(), "javaTask", 100);
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
    infrastructure.assertRequests(1);
    startTask();
    TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask").getId();
    service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "OK", null, 0));
    listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) Test(org.junit.Test)

Example 63 with UnknownJobException

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

the class SchedulerFrontend method getJobServerLogs.

@Override
@ImmediateService
public String getJobServerLogs(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getJobServerLogs", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSIONS_TO_GET_THE_LOGS_OF_THIS_JOB);
    return ServerJobAndTaskLogs.getJobLog(JobIdImpl.makeJobId(jobId), frontendState.getJobTasks(id));
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 64 with UnknownJobException

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

the class SchedulerFrontend method getTaskResultsByTag.

@Override
@ImmediateService
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
    frontendState.checkPermission("getTaskResultByTag", YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    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) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 65 with UnknownJobException

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

the class SchedulerFrontend method getJobResult.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public JobResult getJobResult(final JobId jobId) throws NotConnectedException, PermissionException, UnknownJobException {
    // checking permissions
    IdentifiedJob ij = frontendState.getIdentifiedJob(jobId);
    frontendState.checkPermissions("getJobResult", ij, YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_RESULT_OF_THIS_JOB);
    if (!ij.isFinished()) {
        jlogger.info(jobId, "is not finished");
        jlogger.info(jobId, "Job state: " + frontendState.getJobState(jobId).getStatus());
        return null;
    }
    jlogger.info(jobId, "trying to get the job result");
    JobResult result = dbManager.loadJobResult(jobId);
    if (result == null) {
        throw new UnknownJobException(jobId);
    }
    if (!result.getJobInfo().isToBeRemoved() && SCHEDULER_REMOVED_JOB_DELAY > 0) {
        // remember that this job is to be removed
        dbManager.jobSetToBeRemoved(jobId);
        schedulingService.scheduleJobRemove(jobId, System.currentTimeMillis() + SCHEDULER_REMOVED_JOB_DELAY);
        jlogger.info(jobId, "will be removed in " + (SCHEDULER_REMOVED_JOB_DELAY / 1000) + "sec");
    }
    return result;
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

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