Search in sources :

Example 6 with UnknownTaskRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method taskResult.

/**
 * Returns the task result of the task <code>taskName</code> of the job
 * <code>jobId</code>
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskname
 *            the name of the task
 * @return the task result of the task <code>taskName</code>
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result")
@Produces("application/json")
public TaskResultData taskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws NotConnectedRestException, UnknownJobRestException, UnknownTaskRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result");
        TaskResult taskResult = s.getTaskResult(jobId, taskname);
        if (taskResult == null) {
            TaskIdData taskIdData = new TaskIdData();
            taskIdData.setReadableName(taskname);
            TaskResultData taskResultData = new TaskResultData();
            taskResultData.setId(taskIdData);
            return taskResultData;
        }
        return buildTaskResultData(taskResult);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownTaskException e) {
        throw new UnknownTaskRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) 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) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) 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 7 with UnknownTaskRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method jobTask.

/**
 * Return the task state of the task <code>taskname</code> of the job
 * <code>jobId</code>
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskname
 *            the name of the task
 * @return the task state of the task <code>taskname</code> of the job
 *         <code>jobId</code>
 */
@Override
@GET
@Path("jobs/{jobid}/tasks/{taskname}")
@Produces("application/json")
public TaskStateData jobTask(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, UnknownTaskRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname);
        JobState jobState = s.getJobState(jobId);
        for (TaskState ts : jobState.getTasks()) {
            if (ts.getId().getReadableName().equals(taskname)) {
                return mapper.map(ts, TaskStateData.class);
            }
        }
        throw new UnknownTaskRestException("task " + taskname + "not found");
    } 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) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) JobState(org.ow2.proactive.scheduler.common.job.JobState) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)7 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)7 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)7 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)7 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)7 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)7 GZIP (org.jboss.resteasy.annotations.GZIP)6 UnknownTaskRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException)6 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 JobState (org.ow2.proactive.scheduler.common.job.JobState)3 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1