use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException 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.scheduler.common.exception.UnknownTaskException 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.scheduler.common.exception.UnknownTaskException 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;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class SchedulerClient method isTaskFinished.
@Override
public boolean isTaskFinished(String jobId, String taskName) throws UnknownJobException, NotConnectedException, PermissionException, UnknownTaskException {
boolean finished = false;
try {
TaskStateData taskStateData = restApi().jobTask(sid, jobId, taskName);
TaskState taskState = taskState(taskStateData);
finished = !taskState.getStatus().isTaskAlive();
} catch (Exception e) {
throwUJEOrNCEOrPEOrUTE(e);
}
return finished;
}
use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskResultsByTag.
@Override
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
for (TaskState currentState : taskStates) {
String taskName = currentState.getTaskInfo().getName();
try {
TaskResult currentResult = getTaskResult(jobId, taskName);
results.add(currentResult);
} catch (UnknownTaskException ex) {
// never occurs because tasks are filtered by tag so they cannot
// be unknown.
logger.warn("Unknown task.", ex);
}
}
return results;
}
Aggregations