use of org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse in project fess by codelibs.
the class SystemMonitorTarget method appendFesenStats.
private void appendFesenStats(final StringBuilder buf) {
String stats = null;
try {
final SearchEngineClient esClient = ComponentUtil.getSearchEngineClient();
final NodesStatsResponse response = esClient.admin().cluster().prepareNodesStats().all().execute().actionGet(10000L);
final XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
builder.flush();
try (OutputStream out = builder.getOutputStream()) {
stats = ((ByteArrayOutputStream) out).toString(Constants.UTF_8);
}
} catch (final Exception e) {
logger.debug("Failed to access Fesen stats.", e);
}
buf.append("\"elasticsearch\":").append(stats).append(',');
}
Aggregations