use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException 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.UnknownTaskRestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method enableRemoteVisualization.
@Override
public void enableRemoteVisualization(String sessionId, String jobId, String taskName, String connectionString) throws RestException {
Scheduler s = checkAccess(sessionId, "PUT jobs/" + jobId + PATH_TASKS + taskName + "/visualization");
Session ss = sessionStore.get(sessionId);
try {
ss.getScheduler().enableRemoteVisualization(jobId, taskName, connectionString);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (UnknownTaskException e) {
throw new UnknownTaskRestException(e);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method taskFullLogs.
/**
* Returns full logs generated by the task from user data spaces if task was
* run using the precious logs option. Otherwise, logs are retrieved from
* the database. In this last case they may be truncated.
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return all the logs generated by the task (either stdout and stderr) or
* an empty string if the result is not yet available
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/log/full")
@Produces("application/json")
public InputStream taskFullLogs(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname, @QueryParam("sessionid") String session) throws NotConnectedRestException, UnknownJobRestException, UnknownTaskRestException, PermissionRestException, IOException {
try {
if (sessionId == null) {
sessionId = session;
}
Scheduler scheduler = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result/log/all");
TaskResult taskResult = scheduler.getTaskResult(jobId, taskname);
if (taskResult != null) {
JobState jobState = scheduler.getJobState(taskResult.getTaskId().getJobId());
boolean hasPreciousLogs = false;
for (Task task : jobState.getTasks()) {
if (task.getName().equals(taskname)) {
hasPreciousLogs = task.isPreciousLogs();
break;
}
}
if (hasPreciousLogs) {
return retrieveTaskLogsUsingDataspaces(sessionId, jobId, taskResult.getTaskId());
} else {
logger.warn("Retrieving truncated logs for task '" + taskname + "'");
return IOUtils.toInputStream(retrieveTaskLogsUsingDatabase(sessionId, jobId, taskname));
}
} else {
return null;
}
} 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.UnknownTaskRestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method jobLogs.
/**
* Returns all the logs generated by the job (either stdout and stderr)
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @return all the logs generated by the job (either stdout and stderr) or
* an empty string if the result is not yet available
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/result/log/all")
@Produces("application/json")
public String jobLogs(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, UnknownJobRestException, UnknownTaskRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/result/log/all");
JobResult jobResult = s.getJobResult(jobId);
if (jobResult == null) {
return "";
}
StringBuilder jobOutput = new StringBuilder();
for (TaskResult tr : jobResult.getAllResults().values()) {
if ((tr != null) && (tr.getOutput() != null)) {
jobOutput.append(tr.getOutput().getAllLogs(true));
}
}
return jobOutput.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.scheduler.exception.UnknownTaskRestException in project scheduling by ow2-proactive.
the class SchedulerStateRest method taskLogErr.
/**
* Returns the standard error 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 stderr 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/err")
@Produces("application/json")
public String taskLogErr(@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/err");
TaskResult tr = s.getTaskResult(jobId, taskname);
if ((tr != null) && (tr.getOutput() != null)) {
return tr.getOutput().getStderrLogs(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);
}
}
Aggregations