Search in sources :

Example 6 with TaskInfoData

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);
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Aggregations

TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)4 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)3 TaskIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)3 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)3 ArrayList (java.util.ArrayList)2 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 Page (org.ow2.proactive.scheduler.common.Page)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)1 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)1 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)1 TaskIdImpl.createTaskId (org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId)1 ObjectArrayFormatter (org.ow2.proactive.utils.ObjectArrayFormatter)1 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)1 EventNotification (org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)1 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)1 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)1