use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class SchedulerStateRest method valueOfTaskResultByTag.
/**
* Returns the value of the task result for a set of tasks of the job
* <code>jobId</code> filtered by a given tag. <strong>the result is
* deserialized before sending to the client, if the class is not found the
* content is replaced by the string 'Unknown value type' </strong>. To get
* the serialized form of a given result, one has to call the following
* restful service jobs/{jobid}/tasks/tag/{tasktag}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskTag
* the tag used to filter the tasks.
* @return the value of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/value")
@Produces("application/json")
public Map<String, String> valueOfTaskResultByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tag/" + taskTag + "/result/value");
List<TaskResult> taskResults = s.getTaskResultsByTag(jobId, taskTag);
Map<String, String> result = new HashMap<String, String>(taskResults.size());
for (TaskResult currentTaskResult : taskResults) {
result.put(currentTaskResult.getTaskId().getReadableName(), getTaskResultValueAsStringOrExceptionStackTrace(currentTaskResult));
}
return result;
}
use of org.ow2.proactive.scheduler.common.Scheduler 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.Scheduler in project scheduling by ow2-proactive.
the class SchedulerStateRest method metadataOfTaskResultByTag.
/**
* Returns the metadata of the task result of task <code>taskName</code> of the
* job <code>jobId</code>filtered by a given tag.
* <p>
* Metadata is a map containing additional information associated with a result. For example a file name if the result represents a file.
*
* @param sessionId a valid session id
* @param jobId the id of the job
* @param taskTag the tag used to filter the tasks.
* @return a map containing for each task entry, the metadata of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/metadata")
@Produces("application/json")
public Map<String, Map<String, String>> metadataOfTaskResultByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tag" + taskTag + "/result/serializedvalue");
List<TaskResult> trs = s.getTaskResultsByTag(jobId, taskTag);
Map<String, Map<String, String>> result = new HashMap<>(trs.size());
for (TaskResult currentResult : trs) {
TaskResult r = PAFuture.getFutureValue(currentResult);
result.put(r.getTaskId().getReadableName(), r.getMetadata());
}
return result;
}
use of org.ow2.proactive.scheduler.common.Scheduler 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.Scheduler in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskTags.
/**
* Returns a list of the tags of the tasks belonging to job
* <code>jobId</code>
*
* @param sessionId
* a valid session id
* @param jobId
* jobid one wants to list the tasks' tags
* @return a list of tasks' name
*/
@GET
@Path("jobs/{jobid}/tasks/tags")
@Produces("application/json")
public List<String> getJobTaskTags(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tags");
JobState jobState = s.getJobState(jobId);
return jobState.getTags();
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
Aggregations