Search in sources :

Example 6 with ObjectArrayFormatter

use of org.ow2.proactive.utils.ObjectArrayFormatter in project scheduling by ow2-proactive.

the class StringUtility method jobsAsString.

public static String jobsAsString(List<UserJobData> jobs) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(30);
    formatter.setSpace(4);
    List<String> columnNames = new ArrayList<>(7);
    columnNames.add("ID");
    columnNames.add("NAME");
    columnNames.add("OWNER");
    columnNames.add("PRIORITY");
    columnNames.add("STATUS");
    columnNames.add("START AT");
    columnNames.add("DURATION");
    formatter.setTitle(columnNames);
    formatter.addEmptyLine();
    for (UserJobData job : jobs) {
        formatter.addLine(rowList(job));
    }
    return Tools.getStringAsArray(formatter);
}
Also used : UserJobData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.UserJobData) ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 7 with ObjectArrayFormatter

use of org.ow2.proactive.utils.ObjectArrayFormatter 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)

Example 8 with ObjectArrayFormatter

use of org.ow2.proactive.utils.ObjectArrayFormatter in project scheduling by ow2-proactive.

the class StringUtility method string.

public static String string(NodeSourceView[] nodeSources) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(80);
    formatter.setSpace(4);
    List<String> titles = new ArrayList<>(3);
    titles.add("SOURCE_NAME");
    titles.add("DESCRIPTION");
    titles.add("ADMINISTRATOR");
    formatter.setTitle(titles);
    formatter.addEmptyLine();
    for (NodeSourceView ns : nodeSources) {
        List<String> line = new ArrayList<>(3);
        line.add(ns.getSourceName());
        line.add(ns.getSourceDescription());
        line.add(ns.getNodeSourceAdmin());
        formatter.addLine(line);
    }
    return Tools.getStringAsArray(formatter);
}
Also used : NodeSourceView(org.ow2.proactive_grid_cloud_portal.cli.json.NodeSourceView) ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 9 with ObjectArrayFormatter

use of org.ow2.proactive.utils.ObjectArrayFormatter in project scheduling by ow2-proactive.

the class StringUtility method credentialsKeysAsString.

public static String credentialsKeysAsString(Set<String> keys) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(30);
    formatter.setSpace(4);
    formatter.setTitle(Collections.singletonList("KEY"));
    formatter.addEmptyLine();
    for (String key : keys) {
        formatter.addLine(Collections.singletonList(key));
    }
    return Tools.getStringAsArray(formatter);
}
Also used : ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Aggregations

ObjectArrayFormatter (org.ow2.proactive.utils.ObjectArrayFormatter)9 ArrayList (java.util.ArrayList)8 CommandSet (org.ow2.proactive_grid_cloud_portal.cli.CommandSet)1 MBeanInfoView (org.ow2.proactive_grid_cloud_portal.cli.json.MBeanInfoView)1 NodeEventView (org.ow2.proactive_grid_cloud_portal.cli.json.NodeEventView)1 NodeSourceView (org.ow2.proactive_grid_cloud_portal.cli.json.NodeSourceView)1 TaskIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)1 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)1 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)1 UserJobData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.UserJobData)1