Search in sources :

Example 51 with UnknownJobException

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

the class SchedulerStateRest method taskLogByTag.

/**
 * Returns all the logs generated by a set of the tasks (either stdout and
 * stderr) filtered by a tag.
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskTag
 *            the tag used to filter the tasks.
 * @return the list of logs generated by each filtered task (either stdout
 *         and stderr) or an empty string if the result is not yet available
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/log/all")
@Produces("application/json")
public String taskLogByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tag/" + taskTag + "/result/log/err");
        List<TaskResult> trs = s.getTaskResultsByTag(jobId, taskTag);
        StringBuffer buf = new StringBuffer();
        for (TaskResult tr : trs) {
            if (tr.getOutput() != null) {
                buf.append(tr.getOutput().getAllLogs(true));
            }
        }
        return buf.toString();
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 52 with UnknownJobException

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

the class RestSmartProxyTest method waitForJobFinishState.

private JobState waitForJobFinishState(String jobIdAsString) throws InterruptedException, NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = restSmartProxy.getJobState(jobIdAsString);
    Thread.sleep(ONE_SECOND);
    while (jobState.getStatus().isJobAlive()) {
        jobState = restSmartProxy.getJobState(jobIdAsString);
        Thread.sleep(ONE_SECOND);
    }
    return jobState;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 53 with UnknownJobException

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

the class SchedulerClient method getTaskResult.

@Override
public TaskResult getTaskResult(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    TaskResultImpl taskResult = null;
    try {
        TaskResultData taskResultData = restApi().taskResult(sid, jobId, taskName);
        taskResult = (TaskResultImpl) toTaskResult(JobIdImpl.makeJobId(jobId), taskResultData);
        if (taskResult.value() == null) {
            Serializable value = restApi().valueOfTaskResult(sid, jobId, taskName);
            if (value != null) {
                taskResult.setValue(value);
            }
        }
    } catch (Throwable t) {
        throwUJEOrNCEOrPEOrUTE(exception(t));
    }
    return taskResult;
}
Also used : Serializable(java.io.Serializable) TaskResultImpl(org.ow2.proactive.scheduler.rest.data.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)

Example 54 with UnknownJobException

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

the class SchedulerClient method getJobResult.

@Override
public JobResult getJobResult(String jobId) throws NotConnectedException, PermissionException, UnknownJobException {
    JobResult jobResult = null;
    try {
        JobResultData jobResultData = restApi().jobResult(sid, jobId);
        jobResult = toJobResult(jobResultData);
    } catch (Exception e) {
        throwUJEOrNCEOrPE(e);
    }
    return jobResult;
}
Also used : JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) DataUtility.toJobResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toJobResult) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) 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 55 with UnknownJobException

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

the class LiveJobsTest method testRestartTaskOnNodeRunning0ExecutionsLeft.

@Test(timeout = 60000)
public void testRestartTaskOnNodeRunning0ExecutionsLeft() throws UnknownJobException, UnknownTaskException {
    PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("0");
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    JobId id = new JobIdImpl(666L, "test-name");
    job.setId(id);
    List<InternalTask> tasksList = new ArrayList<>();
    InternalScriptTask internalTask = new InternalScriptTask(job);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    internalTask.setMaxNumberOfExecution(5);
    internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.lockJobsToSchedule();
    liveJobs.taskStarted(job, job.getTask("task-name"), null);
    assertThat(internalTask.getMaxNumberOfExecutionOnFailure(), is(0));
    assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(0));
    liveJobs.restartTaskOnNodeFailure(internalTask);
    internalTask.setStatus(TaskStatus.RUNNING);
    Mockito.verify(dbManager, Mockito.times(0)).taskRestarted(job, internalTask, null);
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

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