@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("nodes"); for (NodeStats nodeStats : getNodes()) { builder.startObject(nodeStats.getNode().getId()); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("nodes"); for (NodeStats nodeStats : getNodes()) { builder.startObject(nodeStats.getNode().getId()); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("nodes"); for (NodeStats nodeStats : getNodes()) { builder.startObject(nodeStats.getNode().getId()); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("nodes"); for (NodeStats nodeStats : getNodes()) { builder.startObject(nodeStats.getNode().getId()); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field("cluster_name", getClusterName().value()); builder.startObject("nodes"); for (NodeStats nodeStats : this) { builder.startObject(nodeStats.getNode().id(), XContentBuilder.FieldCaseConversion.NONE); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
private Map<String, String> getNodesStats(NodesStatsResponse nodesStatsResponse) { Map<String, String> nodeStatsMap = new HashMap<>(); for (NodeStats stat : nodesStatsResponse.getNodes()) { try (XContentBuilder nodesStatsBuilder = XContentFactory.jsonBuilder()) { nodesStatsBuilder.humanReadable(true).prettyPrint().startObject(); stat.toXContent(nodesStatsBuilder, ToXContent.EMPTY_PARAMS); nodesStatsBuilder.endObject(); nodeStatsMap.put(stat.getNode().getName(), nodesStatsBuilder.string()); } catch (IOException e) { Exceptions.handle(e); } } return nodeStatsMap; }