use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException 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 "";
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException 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);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException 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);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException 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);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method schedulerChangeJobPriorityByValue.
/**
* changes the priority of a job
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param priorityValue
* a string representing the value of the priority
* @throws NumberFormatException
* @throws NotConnectedRestException
* @throws UnknownJobRestException
* @throws PermissionRestException
* @throws JobAlreadyFinishedRestException
*/
@Override
@PUT
@Path("jobs/{jobid}/priority/byvalue/{value}")
public void schedulerChangeJobPriorityByValue(@HeaderParam("sessionid") final String sessionId, @PathParam("jobid") final String jobId, @PathParam("value") String priorityValue) throws NumberFormatException, NotConnectedRestException, UnknownJobRestException, PermissionRestException, JobAlreadyFinishedRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/priority/byvalue" + priorityValue);
s.changeJobPriority(jobId, JobPriority.findPriority(Integer.parseInt(priorityValue)));
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (JobAlreadyFinishedException e) {
throw new JobAlreadyFinishedRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
}
}
Aggregations