use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class JobStateImpl method getTasks.
@Override
public List<TaskState> getTasks() {
Map<String, TaskStateData> taskStateMap = jobStateData.getTasks();
List<TaskState> taskStateList = new ArrayList<>(taskStateMap.size());
for (TaskStateData ts : taskStateMap.values()) {
taskStateList.add(DataUtility.taskState(ts));
}
return taskStateList;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class ListTaskStatesCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
List<TaskStateData> tasks = null;
if (this.tag == null) {
if (this.limit == 0) {
tasks = scheduler.getJobTaskStates(currentContext.getSessionId(), jobId).getList();
} else {
tasks = scheduler.getJobTaskStatesPaginated(currentContext.getSessionId(), jobId, offset, limit).getList();
}
} else {
if (this.limit == 0) {
tasks = scheduler.getJobTaskStatesByTag(currentContext.getSessionId(), jobId, tag).getList();
} else {
tasks = scheduler.getJobTaskStatesByTagPaginated(currentContext.getSessionId(), jobId, tag, offset, limit).getList();
}
}
resultStack(currentContext).push(tasks);
if (!currentContext.isSilent()) {
writeLine(currentContext, "%s", StringUtility.taskStatesAsString(tasks, false));
}
} catch (Exception e) {
handleError(String.format("An error occurred while retrieving %s state:", job()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData 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);
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class ListTaskStatesCommandTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
JobIdData jobId = jobIdFaker.fake();
taskStateFaker = new DataFaker<TaskStateData>(TaskStateData.class);
taskStateFaker.setGenerator("taskInfo.jobId", new FixedPropertyGenerator<JobIdData>(jobId));
taskStateFaker.setGenerator("taskInfo.taskId.readableName", new PrefixPropertyGenerator("task", 1));
taskStateFaker.setGenerator("name", new PrefixPropertyGenerator("task", 1));
taskStateFaker.setGenerator("tag", new FixedPropertyGenerator("LOOP-T2-1"));
this.taskData = this.taskStateFaker.fakeList(6);
this.taskDataFiltered = new ArrayList<>();
this.taskDataFiltered.add(this.taskData.get(0));
this.taskDataFiltered.add(this.taskData.get(1));
this.taskDataFiltered.add(this.taskData.get(2));
}
Aggregations