use of org.ow2.proactive.scheduler.common.task.TaskResult in project scheduling by ow2-proactive.
the class SchedulerStateRest method metadataOfTaskResult.
/**
* Returns the metadata of the task result of task <code>taskName</code> of the
* job <code>jobId</code>.
*
* 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 taskname
* the name of the task
* @return the metadata of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/metadata")
@Produces("*/*")
public Map<String, String> metadataOfTaskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result/value");
TaskResult taskResult = s.getTaskResult(jobId, taskname);
taskResult = PAFuture.getFutureValue(taskResult);
return taskResult.getMetadata();
}
use of org.ow2.proactive.scheduler.common.task.TaskResult in project scheduling by ow2-proactive.
the class SchedulerStateRest method taskLogoutByTag.
/**
* Returns the standard output (stdout) 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 stdout generated by the task or an empty string if the result
* is not yet available
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/log/out")
@Produces("application/json")
public String taskLogoutByTag(@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/out");
List<TaskResult> trs = s.getTaskResultsByTag(jobId, taskTag);
StringBuffer result = new StringBuffer();
for (TaskResult tr : trs) {
if (tr.getOutput() != null) {
result.append(tr.getOutput().getStdoutLogs(true));
}
}
return result.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.scheduler.common.task.TaskResult in project scheduling by ow2-proactive.
the class SchedulerStateRest method taskResult.
/**
* Returns the task result of the task <code>taskName</code> of the job
* <code>jobId</code>
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return the task result of the task <code>taskName</code>
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result")
@Produces("application/json")
public TaskResultData taskResult(@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");
TaskResult taskResult = s.getTaskResult(jobId, taskname);
if (taskResult == null) {
TaskIdData taskIdData = new TaskIdData();
taskIdData.setReadableName(taskname);
TaskResultData taskResultData = new TaskResultData();
taskResultData.setId(taskIdData);
return taskResultData;
}
return buildTaskResultData(taskResult);
} 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 SchedulerStateRest method jobResultValue.
/**
* Returns all the task results of this job as a map whose the key is the
* name of the task and its task result.<br>
* If the result cannot be instantiated, the content is replaced by the
* string 'Unknown value type'. To get the serialized form of a given
* result, one has to call the following restful service
* jobs/{jobid}/tasks/{taskname}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* a job id
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/result/value")
@Produces("application/json")
public Map<String, String> jobResultValue(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId) throws NotConnectedRestException, PermissionRestException, UnknownJobRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/result/value");
JobResult jobResult = PAFuture.getFutureValue(s.getJobResult(jobId));
if (jobResult == null) {
return null;
}
Map<String, TaskResult> allResults = jobResult.getAllResults();
Map<String, String> res = new HashMap<>(allResults.size());
for (final Entry<String, TaskResult> entry : allResults.entrySet()) {
TaskResult taskResult = entry.getValue();
String value = getTaskResultValueAsStringOrExceptionStackTrace(taskResult);
res.put(entry.getKey(), value);
}
return res;
} 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.scheduler.common.task.TaskResult in project scheduling by ow2-proactive.
the class SchedulerStateRest method valueOfTaskResult.
/**
* Returns the value of the task result of task <code>taskName</code> of the
* job <code>jobId</code> <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/{taskname}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return the value of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/value")
@Produces("*/*")
public Serializable valueOfTaskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result/value");
TaskResult taskResult = s.getTaskResult(jobId, taskname);
return getTaskResultValueAsStringOrExceptionStackTrace(taskResult);
}
Aggregations