use of org.jboss.resteasy.annotations.GZIP 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);
}
}
use of org.jboss.resteasy.annotations.GZIP 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);
}
}
use of org.jboss.resteasy.annotations.GZIP in project scheduling by ow2-proactive.
the class SchedulerStateRest method serializedValueOfTaskResult.
/**
* Returns the value of the task result of the task <code>taskName</code> of
* the job <code>jobId</code> This method returns the result as a byte array
* whatever the result is.
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return the value of the task result as a byte array.
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/serializedvalue")
@Produces("*/*")
public byte[] serializedValueOfTaskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result/serializedvalue");
TaskResult tr = s.getTaskResult(jobId, taskname);
tr = PAFuture.getFutureValue(tr);
return tr.getSerializedValue();
}
use of org.jboss.resteasy.annotations.GZIP 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);
}
}
use of org.jboss.resteasy.annotations.GZIP in project scheduling by ow2-proactive.
the class SchedulerStateRest method valueOfTaskResultByTag.
/**
* Returns the value of the task result for a set of tasks of the job
* <code>jobId</code> filtered by a given tag. <strong>the result is
* deserialized before sending to the client, if the class is not found the
* content is replaced by the string 'Unknown value type' </strong>. To get
* the serialized form of a given result, one has to call the following
* restful service jobs/{jobid}/tasks/tag/{tasktag}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskTag
* the tag used to filter the tasks.
* @return the value of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/value")
@Produces("application/json")
public Map<String, String> valueOfTaskResultByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tag/" + taskTag + "/result/value");
List<TaskResult> taskResults = s.getTaskResultsByTag(jobId, taskTag);
Map<String, String> result = new HashMap<String, String>(taskResults.size());
for (TaskResult currentTaskResult : taskResults) {
result.put(currentTaskResult.getTaskId().getReadableName(), getTaskResultValueAsStringOrExceptionStackTrace(currentTaskResult));
}
return result;
}
Aggregations