use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTasksIdsByTag.
/**
* Returns a list of the name of the tasks belonging to job and filtered by
* a given tag. <code>jobId</code>
*
* @param sessionId
* a valid session id
* @param jobId
* jobid one wants to list the tasks' name
* @param taskTag
* the tag used to filter the tasks.
* @return the list of task ids with the total number of them
*/
@Override
@GET
@Path("jobs/{jobid}/tasks/tag/{tasktag}")
@Produces("application/json")
public RestPage<String> getJobTasksIdsByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, 0, TASKS_PAGE_SIZE);
List<TaskState> tasks = page.getTaskStates();
List<String> tasksName = new ArrayList<>(tasks.size());
for (TaskState ts : tasks) {
tasksName.add(ts.getId().getReadableName());
}
return new RestPage<String>(tasksName, 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.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerStateRest method schedulerChangeJobPriorityByName.
/**
* changes the priority of a job
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param priorityName
* a string representing the name of the priority
* @throws NotConnectedRestException
* @throws UnknownJobRestException
* @throws PermissionRestException
* @throws JobAlreadyFinishedRestException
*/
@Override
@PUT
@Path("jobs/{jobid}/priority/byname/{name}")
public void schedulerChangeJobPriorityByName(@HeaderParam("sessionid") final String sessionId, @PathParam("jobid") final String jobId, @PathParam("name") String priorityName) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, JobAlreadyFinishedRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/priority/byname/" + priorityName);
s.changeJobPriority(jobId, JobPriority.findPriority(priorityName));
} 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.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerStateRest method jobs.
/**
* Returns the ids of the current jobs under a list of string.
*
* @param sessionId
* a valid session id
* @param index
* optional, if a sublist has to be returned the index of the
* sublist
* @param limit
* optional, if a sublist has to be returned, the limit of the
* sublist
* @return a list of jobs' ids under the form of a list of string
*/
@Override
@GET
@Path("jobs")
@Produces("application/json")
public RestPage<String> jobs(@HeaderParam("sessionid") String sessionId, @QueryParam("index") @DefaultValue("-1") int index, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "/scheduler/jobs");
Page<JobInfo> page = s.getJobs(index, limit, new JobFilterCriteria(false, true, true, true), DEFAULT_JOB_SORT_PARAMS);
List<String> ids = new ArrayList<String>(page.getList().size());
for (JobInfo jobInfo : page.getList()) {
ids.add(jobInfo.getJobId().value());
}
return new RestPage<String>(ids, page.getSize());
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
}
}
use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesPaginated.
/**
* Returns a list of taskState with pagination
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param offset
* the index of the first TaskState to return
* @param limit
* the index (non inclusive) of the last TaskState to return
* @return a list of task' states of the job <code>jobId</code>
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesPaginated(@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 + "/taskstates/paginated");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTasksPaginated(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.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerStateRest method jobResultValue.
/**
* Returns all the task results of this job as a map whose the key is the
* name of the task and its task result.<br>
* If the result cannot be instantiated, the content is replaced by the
* string 'Unknown value type'. To get the serialized form of a given
* result, one has to call the following restful service
* jobs/{jobid}/tasks/{taskname}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* a job id
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/result/value")
@Produces("application/json")
public Map<String, String> jobResultValue(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, PermissionRestException, UnknownJobRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/result/value");
JobResult jobResult = PAFuture.getFutureValue(s.getJobResult(jobId));
if (jobResult == null) {
return null;
}
Map<String, TaskResult> allResults = jobResult.getAllResults();
Map<String, String> res = new HashMap<>(allResults.size());
for (final Entry<String, TaskResult> entry : allResults.entrySet()) {
TaskResult taskResult = entry.getValue();
String value = getTaskResultValueAsStringOrExceptionStackTrace(taskResult);
res.put(entry.getKey(), value);
}
return res;
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
Aggregations