use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData 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