use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerStateRest method jobsInfo.
/**
* Returns a subset of the scheduler state, including pending, running,
* finished jobs (in this particular order). each jobs is described using -
* its id - its owner - the JobInfo class
*
* @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
* @param sessionId
* a valid session id
* @return a list of UserJobData
*/
@Override
@GET
@Path("jobsinfo")
@Produces({ "application/json", "application/xml" })
public RestPage<UserJobData> jobsInfo(@HeaderParam("sessionid") String sessionId, @QueryParam("index") @DefaultValue("-1") int index, @QueryParam("limit") @DefaultValue("-1") int limit) throws PermissionRestException, NotConnectedRestException {
try {
Scheduler s = checkAccess(sessionId, "/scheduler/jobsinfo");
Page<JobInfo> page = s.getJobs(index, limit, new JobFilterCriteria(false, true, true, true), DEFAULT_JOB_SORT_PARAMS);
List<UserJobData> userJobInfoList = new ArrayList<UserJobData>(page.getList().size());
for (JobInfo jobInfo : page.getList()) {
userJobInfoList.add(new UserJobData(mapper.map(jobInfo, JobInfoData.class)));
}
return new RestPage<UserJobData>(userJobInfoList, page.getSize());
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.Session 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);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerStateRest method getLiveLogJobAvailable.
/**
* number of available bytes in the stream or -1 if the stream does not
* exist.
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job to retrieve
*/
@Override
@GET
@Path("jobs/{jobid}/livelog/available")
@Produces("application/json")
public int getLiveLogJobAvailable(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException {
checkAccess(sessionId, "/scheduler/jobs/" + jobId + "/livelog/available");
Session ss = sessionStore.get(sessionId);
return ss.getJobsOutputController().availableLinesCount(jobId);
}
use of org.ow2.proactive_grid_cloud_portal.common.Session 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.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerStateRest method login.
/**
* Login to the scheduler using a form containing 2 fields (username and
* password).
*
* @param username
* username
* @param password
* password
* @return the session id associated to the login.
* @throws LoginException
*/
@Override
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("login")
@Produces("application/json")
public String login(@FormParam("username") String username, @FormParam("password") String password) throws LoginException, SchedulerRestException {
try {
if ((username == null) || (password == null)) {
throw new LoginException("Empty login/password");
}
Session session = sessionStore.create(username);
session.connectToScheduler(new CredData(username, password));
logger.info("Binding user " + username + " to session " + session.getSessionId());
return session.getSessionId();
} catch (ActiveObjectCreationException e) {
throw new SchedulerRestException(e);
} catch (SchedulerException e) {
throw new SchedulerRestException(e);
} catch (NodeException e) {
throw new SchedulerRestException(e);
}
}
Aggregations