use of org.ow2.proactive.scheduler.common.exception.UnknownJobException 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.scheduler.common.exception.UnknownJobException 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.scheduler.common.exception.UnknownJobException 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);
}
}
use of org.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesByTag.
/**
* Returns a list of taskState of the tasks filtered by a given tag.
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param taskTag
* the tag used to filter the tasks
* @return a list of task' states of the job <code>jobId</code> filtered by
* a given tag.
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/{tasktag}")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/taskstates/" + taskTag);
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, 0, TASKS_PAGE_SIZE);
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.ow2.proactive.scheduler.common.exception.UnknownJobException in project scheduling by ow2-proactive.
the class NoVncSecuredTargetResolver method doResolve.
// package-protected for testing
InetSocketAddress doResolve(String sessionId, String jobId, String taskName) {
if (sessionId == null || jobId == null || taskName == null) {
LOGGER.warn("One of the web socket path parameter is missing (sessionId, jobId, taskName).");
return null;
}
Session session = SharedSessionStore.getInstance().get(sessionId);
if (session == null) {
LOGGER.warn("Unknown sessionId.");
return null;
}
SchedulerProxyUserInterface scheduler = session.getScheduler();
try {
TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
List<String> paRemoteConnectionLines = retrievePaRemoteConnectionLines(session, jobId, taskResult);
String taskId = retrieveTaskId(taskName, scheduler.getJobState(jobId));
return resolveVncTargetFromLogs(paRemoteConnectionLines, jobId, taskId);
} catch (NotConnectedException e) {
LOGGER.warn("Failed to connect to scheduler", e);
} catch (UnknownJobException e) {
LOGGER.warn("Job does not exist", e);
} catch (UnknownTaskException e) {
LOGGER.warn("Task does not exist", e);
} catch (PermissionException e) {
LOGGER.warn("Not allowed to access task", e);
}
return null;
}
Aggregations