use of org.ow2.proactive.scheduler.common.task.TaskResult 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.task.TaskResult 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.task.TaskResult in project scheduling by ow2-proactive.
the class GetTaskResultCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
TaskResultData taskResult = scheduler.taskResult(currentContext.getSessionId(), jobId, taskId);
resultStack(currentContext).push(taskResult);
if (!currentContext.isSilent()) {
writeLine(currentContext, "%s", StringUtility.taskResultAsString(task(), taskResult));
}
} catch (Exception e) {
handleError(String.format("An error occurred while retrieving %s result:", task()), e, currentContext);
}
}
use of org.ow2.proactive.scheduler.common.task.TaskResult 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;
}
use of org.ow2.proactive.scheduler.common.task.TaskResult in project scheduling by ow2-proactive.
the class JobResultImpl method createTaskResultMap.
private Map<String, TaskResult> createTaskResultMap(Map<String, TaskResultData> inputDataMap) {
Map<String, TaskResult> map = new HashMap<>();
for (String taskName : inputDataMap.keySet()) {
TaskResultData taskResultData = inputDataMap.get(taskName);
map.put(taskName, toTaskResult(jobId, taskResultData));
}
return map;
}
Aggregations