Search in sources :

Example 1 with UnknownJobRestException

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

the class SchedulerStateRest method getJobTaskStatesByTagPaginated.

/**
 * {@inheritDoc}
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/{tasktag}/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesByTagPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag, @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 + "/taskstates/" + taskTag + "/paginated");
        JobState jobState = s.getJobState(jobId);
        TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, offset, limit);
        List<TaskStateData> tasks = map(page.getTaskStates(), TaskStateData.class);
        return new RestPage<TaskStateData>(tasks, 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) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) 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) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) JobState(org.ow2.proactive.scheduler.common.job.JobState) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 2 with UnknownJobRestException

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

the class SchedulerStateRest method getJobTaskTagsPrefix.

/**
 * Returns a list of the tags of the tasks belonging to job
 * <code>jobId</code> and filtered by a prefix pattern
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            jobid one wants to list the tasks' tags
 * @param prefix
 *            the prefix used to filter tags
 * @return a list of tasks' name
 */
@GET
@Path("jobs/{jobid}/tasks/tags/startsWith/{prefix}")
@Produces("application/json")
public List<String> getJobTaskTagsPrefix(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("prefix") String prefix) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tags/startswith/" + prefix);
        JobState jobState = s.getJobState(jobId);
        return jobState.getTags(prefix);
    } 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 3 with UnknownJobRestException

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

the class SchedulerStateRest method taskLogErrByTag.

/**
 * Returns the list of standard error outputs (stderr) generated by a set of
 * tasks filtered by a given 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 stderr generated by the set of tasks filtered by the
 *         given tag or an empty string if the result is not yet available
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/log/err")
@Produces("application/json")
public String taskLogErrByTag(@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().getStderrLogs(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 4 with UnknownJobRestException

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

the class SchedulerStateRest method getLiveLogJob.

/**
 * Stream the output of job identified by the id <code>jobid</code> only
 * stream currently available logs, call this method several times to get
 * the complete output.
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job to retrieve
 * @throws IOException
 * @throws LogForwardingRestException
 */
@GET
@GZIP
@Path("jobs/{jobid}/livelog")
@Produces("application/json")
@Override
public String getLiveLogJob(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, LogForwardingRestException, IOException {
    try {
        Scheduler scheduler = checkAccess(sessionId, "/scheduler/jobs/" + jobId + "/livelog");
        Session session = sessionStore.get(sessionId);
        JobState jobState = scheduler.getJobState(jobId);
        boolean isFinished = jobState != null && jobState.isFinished();
        int availableLinesCount = session.getJobsOutputController().availableLinesCount(jobId);
        if (!isFinished || availableLinesCount > 0) {
            return session.getJobsOutputController().getNewLogs(jobId);
        } else {
            session.getJobsOutputController().removeAppender(jobId);
            return "";
        }
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (LogForwardingException e) {
        throw new LogForwardingRestException(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) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) JobState(org.ow2.proactive.scheduler.common.job.JobState) LogForwardingRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.LogForwardingRestException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 5 with UnknownJobRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException 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)

Aggregations

UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)27 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)26 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)26 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)26 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)26 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)26 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)25 Path (javax.ws.rs.Path)24 GET (javax.ws.rs.GET)22 Produces (javax.ws.rs.Produces)22 GZIP (org.jboss.resteasy.annotations.GZIP)16 JobState (org.ow2.proactive.scheduler.common.job.JobState)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)10 ArrayList (java.util.ArrayList)6 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)6 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)6 UnknownTaskRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException)6 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)5 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)3