Search in sources :

Example 1 with ObjectArrayFormatter

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

the class StringUtility method mBeanInfoAsString.

public static String mBeanInfoAsString(MBeanInfoView[] infoViews) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(80);
    formatter.setSpace(4);
    List<String> titles = new ArrayList<>(2);
    titles.add("Stats:");
    titles.add("");
    formatter.setTitle(titles);
    formatter.addEmptyLine();
    for (MBeanInfoView infoView : infoViews) {
        List<String> line = new ArrayList<>();
        line.add("" + infoView.getName());
        line.add("" + infoView.getValue());
        formatter.addLine(line);
    }
    return Tools.getStringAsArray(formatter);
}
Also used : MBeanInfoView(org.ow2.proactive_grid_cloud_portal.cli.json.MBeanInfoView) ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 2 with ObjectArrayFormatter

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

the class StringUtility method string.

public static String string(NodeEventView[] nodeEvents) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(300);
    formatter.setSpace(4);
    List<String> titles = new ArrayList<>(7);
    titles.add("SOURCE_NAME");
    titles.add("HOST_NAME");
    titles.add("STATE");
    titles.add("SINCE");
    titles.add("LOCKED");
    titles.add("LOCKED_BY");
    titles.add("LOCK_TIME");
    titles.add("URL");
    titles.add("PROVIDER");
    titles.add("USED_BY");
    formatter.setTitle(titles);
    formatter.addEmptyLine();
    if (nodeEvents != null) {
        for (NodeEventView nodeEvent : nodeEvents) {
            List<String> line = new ArrayList<>(10);
            line.add(nodeEvent.getNodeSource());
            line.add(nodeEvent.getHostName());
            line.add(nodeEvent.getNodeState());
            line.add(getStateChangeTime(nodeEvent));
            line.add(nodeEvent.isLocked());
            line.add(toStringNullable(nodeEvent.getNodeLocker()));
            line.add(getLockTime(nodeEvent));
            line.add(nodeEvent.getNodeUrl());
            line.add(toStringNullable(nodeEvent.getNodeProvider()));
            line.add(toStringNullable(nodeEvent.getNodeOwner()));
            formatter.addLine(line);
        }
    }
    return Tools.getStringAsArray(formatter);
}
Also used : ArrayList(java.util.ArrayList) NodeEventView(org.ow2.proactive_grid_cloud_portal.cli.json.NodeEventView) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 3 with ObjectArrayFormatter

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

the class AbstractJsHelpCommand method printHelp.

public void printHelp(ApplicationContext currentContext, CommandSet.Entry[]... entrySet) throws CLIException {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(100);
    formatter.setSpace(2);
    formatter.setTitle(ImmutableList.of("Command", "Description"));
    formatter.addEmptyLine();
    boolean versionEntryAdded = false;
    List<CommandSet.Entry> entries = new ArrayList<>();
    for (CommandSet.Entry[] es : entrySet) {
        for (CommandSet.Entry entry : es) {
            if (entry.jsCommand() != null && entry.jsCommand().equals(CommandSet.VERSION.jsCommand())) {
                if (!versionEntryAdded) {
                    entries.add(entry);
                    versionEntryAdded = true;
                }
            } else {
                entries.add(entry);
            }
        }
    }
    Collections.sort(entries);
    for (CommandSet.Entry entry : entries) {
        if (entry.jsCommand() != null) {
            formatter.addLine(ImmutableList.of(entry.jsCommand(), entry.description()));
        }
    }
    writeLine(currentContext, "%s", StringUtility.objectArrayFormatterAsString(formatter));
}
Also used : ArrayList(java.util.ArrayList) CommandSet(org.ow2.proactive_grid_cloud_portal.cli.CommandSet) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 4 with ObjectArrayFormatter

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

the class StringUtility method string.

public static String string(TopologyView topology) {
    StringBuilder buffer = new StringBuilder();
    Set<String> hostList = topology.getDistances().keySet();
    buffer.append(String.format("%nHost list(%d):", hostList.size()));
    for (String host : hostList) {
        buffer.append(String.format("%s", host));
    }
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(80);
    formatter.setSpace(4);
    List<String> titles = new ArrayList<>(3);
    titles.add("Host");
    titles.add("Distance (µs)");
    titles.add("Host");
    formatter.setTitle(titles);
    formatter.addEmptyLine();
    List<String> line;
    for (String host : hostList) {
        Map<String, String> hostTopology = topology.getDistances().get(host);
        if (hostTopology != null) {
            for (String anotherHost : hostTopology.keySet()) {
                line = new ArrayList<>(3);
                line.add(host);
                line.add(hostTopology.get(anotherHost));
                line.add(anotherHost);
                formatter.addLine(line);
            }
        }
    }
    buffer.append(objectArrayFormatterAsString(formatter));
    return buffer.toString();
}
Also used : ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Example 5 with ObjectArrayFormatter

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

the class StringUtility method statsAsString.

public static String statsAsString(Map<String, String> stats) {
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(80);
    formatter.setSpace(2);
    List<String> columnNames = new ArrayList<>(2);
    columnNames.add("");
    columnNames.add("");
    formatter.setTitle(columnNames);
    for (Entry<String, String> e : stats.entrySet()) {
        List<String> row = new ArrayList<>();
        row.add(e.getKey());
        row.add(e.getValue());
        formatter.addLine(row);
    }
    return Tools.getStringAsArray(formatter);
}
Also used : ArrayList(java.util.ArrayList) 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