use of io.searchbox.core.CatResult in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method catIndices.
/**
* Retrieve the response for the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html">cat indices</a> request from Elasticsearch.
*
* @param fields The fields to show, see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html">cat indices API</a>.
* @return A {@link JsonNode} with the result of the cat indices request.
*/
private JsonNode catIndices(Collection<String> indices, String... fields) {
final String fieldNames = String.join(",", fields);
final Cat request = new Cat.IndicesBuilder().addIndex(indices).setParameter("h", fieldNames).build();
final CatResult response = JestUtils.execute(jestClient, request, () -> "Unable to read information for indices " + indices);
return response.getJsonObject().path("result");
}
use of io.searchbox.core.CatResult in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method indices.
@Override
public Set<String> indices(String indexWildcard, List<String> status, String indexSetId) {
final Cat catRequest = new Cat.IndicesBuilder().addIndex(indexWildcard).setParameter("h", "index,status").build();
final CatResult result = JestUtils.execute(jestClient, catRequest, () -> "Couldn't get index list for index set <" + indexSetId + ">");
return StreamSupport.stream(result.getJsonObject().path("result").spliterator(), false).filter(cat -> status.isEmpty() || status.contains(cat.path("status").asText())).map(cat -> cat.path("index").asText()).collect(Collectors.toSet());
}
use of io.searchbox.core.CatResult in project graylog2-server by Graylog2.
the class ClusterAdapterES6 method catNodes.
/**
* Retrieve the response for the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html">cat nodes</a> request from Elasticsearch.
*
* @param fields The fields to show, see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html">cat nodes API</a>.
* @return A {@link JsonNode} with the result of the cat nodes request.
*/
private JsonNode catNodes(String... fields) {
final String fieldNames = String.join(",", fields);
final Cat request = new Cat.NodesBuilder().setParameter("h", fieldNames).setParameter("full_id", true).setParameter("format", "json").build();
final CatResult response = JestUtils.execute(jestClient, request, () -> "Unable to read Elasticsearch node information");
return response.getJsonObject().path("result");
}
use of io.searchbox.core.CatResult in project graylog2-server by Graylog2.
the class ClusterES6IT method currentNodeInfo.
private JsonNode currentNodeInfo() {
final Cat nodesInfo = new Cat.NodesBuilder().setParameter("h", "id,name,host,ip").setParameter("format", "json").setParameter("full_id", "true").build();
final CatResult catResult = JestUtils.execute(jestClient(elasticsearch), nodesInfo, () -> "Unable to retrieve current node info");
final JsonNode result = catResult.getJsonObject().path("result");
assertThat(result).isNotEmpty();
return result.path(0);
}
Aggregations