Search in sources :

Example 11 with PermissionException

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

the class SchedulerStateRest method listJobs.

/**
 * Returns a JobState of the job identified by the id <code>jobid</code>
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job to retrieve
 */
@Override
@GET
@Path("jobs/{jobid}")
@Produces({ "application/json", "application/xml" })
public JobStateData listJobs(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "/scheduler/jobs/" + jobId);
        JobState js = s.getJobState(jobId);
        js = PAFuture.getFutureValue(js);
        return mapper.map(js, JobStateData.class);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) 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) JobState(org.ow2.proactive.scheduler.common.job.JobState) 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)

Example 12 with PermissionException

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

the class SchedulerStateRest method retrieveTaskLogsUsingDatabase.

private String retrieveTaskLogsUsingDatabase(String sessionId, String jobId, String taskName) throws NotConnectedRestException, UnknownJobException, UnknownTaskException, NotConnectedException, PermissionException, PermissionRestException {
    Scheduler scheduler = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskName + "/result/log/all");
    TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
    if (taskResult != null && taskResult.getOutput() != null) {
        return taskResult.getOutput().getAllLogs(true);
    }
    return "";
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 13 with PermissionException

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

the class SchedulerStateRest method taskLogout.

/**
 * Returns the standard output (stderr) generated by the task
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskname
 *            the name of the task
 * @return the stdout generated by the task or an empty string if the result
 *         is not yet available
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/log/out")
@Produces("application/json")
public String taskLogout(@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/log/out");
        TaskResult tr = s.getTaskResult(jobId, taskname);
        if ((tr != null) && (tr.getOutput() != null)) {
            return tr.getOutput().getStdoutLogs(true);
        } else {
            return "";
        }
    } 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) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) 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 14 with PermissionException

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

the class SchedulerStateRest method getJobTaskTags.

/**
 * Returns a list of the tags of the tasks belonging to job
 * <code>jobId</code>
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            jobid one wants to list the tasks' tags
 * @return a list of tasks' name
 */
@GET
@Path("jobs/{jobid}/tasks/tags")
@Produces("application/json")
public List<String> getJobTaskTags(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tags");
        JobState jobState = s.getJobState(jobId);
        return jobState.getTags();
    } 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) JobState(org.ow2.proactive.scheduler.common.job.JobState) 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)

Example 15 with PermissionException

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

the class SchedulerStateRest method getTasksNamesPaginated.

/**
 * Returns a list of the name of the tasks belonging to job
 * <code>jobId</code> with pagination
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            jobid one wants to list the tasks' name
 * @param offset
 *            the number of the first task to fetch
 * @param limit
 *            the number of the last task to fetch (non inclusive)
 * @return the list of task ids with the total number of them
 */
@Override
@GET
@Path("jobs/{jobid}/tasks/paginated")
@Produces("application/json")
public RestPage<String> getTasksNamesPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    if (limit == -1)
        limit = TASKS_PAGE_SIZE;
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks");
        JobState jobState = s.getJobState(jobId);
        TaskStatesPage page = jobState.getTasksPaginated(offset, limit);
        List<String> tasksNames = new ArrayList<>(page.getTaskStates().size());
        for (TaskState ts : page.getTaskStates()) {
            tasksNames.add(ts.getId().getReadableName());
        }
        return new RestPage<String>(tasksNames, page.getSize());
    } 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) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)64 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)62 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)46 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)46 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)44 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)39 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)34 Path (javax.ws.rs.Path)32 Produces (javax.ws.rs.Produces)30 GET (javax.ws.rs.GET)26 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)25 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 GZIP (org.jboss.resteasy.annotations.GZIP)17 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)16 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)16 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)15