use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskIds.
@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
RestPage<TaskStateData> page = null;
try {
page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, null);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
}
List<TaskId> lTaskIds = new ArrayList<TaskId>(page.getList().size());
for (TaskStateData taskStateData : page.getList()) {
TaskInfoData taskInfo = taskStateData.getTaskInfo();
TaskIdData taskIdData = taskInfo.getTaskId();
JobId jobId = new JobIdImpl(taskInfo.getJobId().getId(), taskInfo.getJobId().getReadableName());
TaskId taskId = TaskIdImpl.createTaskId(jobId, taskIdData.getReadableName(), taskIdData.getId());
lTaskIds.add(taskId);
}
return new Page<TaskId>(lTaskIds, page.getSize());
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.
the class JobStateImpl method getHMTasks.
@Override
public Map<TaskId, TaskState> getHMTasks() {
Map<String, TaskStateData> taskStateDataMap = jobStateData.getTasks();
Map<TaskId, TaskState> taskStateMap = new HashMap<>();
for (TaskStateData taskStateData : taskStateDataMap.values()) {
TaskIdData taskIdData = taskStateData.getTaskInfo().getTaskId();
taskStateMap.put(DataUtility.taskId(DataUtility.jobId(jobStateData.getJobInfo().getJobId()), taskIdData), DataUtility.taskState(taskStateData));
}
return taskStateMap;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData 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_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.
the class RestTestUtils method newMockedTaskStateData.
protected static TaskStateData newMockedTaskStateData(String jobIdStr, String tag, long cnt, int nbTasks) {
TaskStateData mockedTaskStateData = mock(TaskStateData.class);
TaskInfoData mockedTaskInfoData = mock(TaskInfoData.class);
TaskIdData mockedTaskIdData = mock(TaskIdData.class);
when(mockedTaskIdData.getReadableName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
when(mockedTaskIdData.getId()).thenReturn(cnt);
when(mockedTaskInfoData.getTaskId()).thenReturn(mockedTaskIdData);
when(mockedTaskStateData.getTaskInfo()).thenReturn(mockedTaskInfoData);
when(mockedTaskStateData.getTag()).thenReturn(tag);
return mockedTaskStateData;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.
the class StringUtility method taskStatesAsString.
public static String taskStatesAsString(Collection<TaskStateData> tasks, boolean displayTags) {
// create formatter
ObjectArrayFormatter formatter = new ObjectArrayFormatter();
formatter.setMaxColumnLength(80);
// space between column
formatter.setSpace(4);
// title line
List<String> list = new ArrayList<>();
list.add("ID");
list.add("NAME");
if (displayTags) {
list.add("TAG");
}
list.add("ITER");
list.add("DUP");
list.add("STATUS");
list.add("HOSTNAME");
list.add("EXEC DURATION");
list.add("TOT DURATION");
list.add("#NODES USED");
list.add("#EXECUTIONS");
list.add("#NODES KILLED");
formatter.setTitle(list);
formatter.addEmptyLine();
for (TaskStateData taskState : tasks) {
list = new ArrayList<>();
TaskInfoData taskInfo = taskState.getTaskInfo();
TaskIdData taskId = taskInfo.getTaskId();
list.add(String.valueOf(taskId.getId()));
list.add(taskId.getReadableName());
if (displayTags) {
list.add(toStringNullable(taskState.getTag()));
}
list.add((taskState.getIterationIndex() > 0) ? "" + taskState.getIterationIndex() : "");
list.add((taskState.getReplicationIndex() > 0) ? "" + taskState.getReplicationIndex() : "");
list.add(taskInfo.getTaskStatus().toString());
list.add(toStringNullable(taskInfo.getExecutionHostName(), "unknown"));
if (taskInfo.getTaskStatus() == TaskStatusData.IN_ERROR) {
list.add(Tools.getFormattedDuration(taskInfo.getInErrorTime(), taskInfo.getStartTime()));
} else {
list.add(Tools.getFormattedDuration(0, taskInfo.getExecutionDuration()));
}
list.add(Tools.getFormattedDuration(taskInfo.getFinishedTime(), taskInfo.getStartTime()));
list.add("" + taskState.getNumberOfNodesNeeded());
list.add((taskState.getMaxNumberOfExecution() - taskInfo.getNumberOfExecutionLeft()) + "/" + taskState.getMaxNumberOfExecution());
list.add((taskState.getMaxNumberOfExecutionOnFailure() - taskInfo.getNumberOfExecutionOnFailureLeft()) + "/" + taskState.getMaxNumberOfExecutionOnFailure());
formatter.addLine(list);
}
return Tools.getStringAsArray(formatter);
}
Aggregations