use of org.ow2.proactive_grid_cloud_portal.cli.json.MBeanInfoView 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);
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.MBeanInfoView in project scheduling by ow2-proactive.
the class RmStatsCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
StringBuilder url = new StringBuilder();
url.append("info/ProActiveResourceManager:name=RuntimeData?");
QueryStringBuilder builder = new QueryStringBuilder();
for (String attr : RUNTIME_DATA_ATTR) {
builder.add("attr", attr);
}
url.append(builder.buildString());
HttpGet request = new HttpGet(currentContext.getResourceUrl(url.toString()));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
List<MBeanInfoView> infoList = readValue(response, new TypeReference<List<MBeanInfoView>>() {
}, currentContext);
MBeanInfoView[] stats = infoList.toArray(new MBeanInfoView[infoList.size()]);
resultStack(currentContext).push(stats);
if (!currentContext.isSilent()) {
writeLine(currentContext, "%s", StringUtility.mBeanInfoAsString(stats));
}
} else {
handleError("An error occurred while retrieving stats:", response, currentContext);
}
}
Aggregations