use of io.searchbox.cluster.State in project graylog2-server by Graylog2.
the class V20170607164210_MigrateReopenedIndicesToAliasesClusterStateES6 method getForIndices.
@Override
public JsonNode getForIndices(Collection<String> indices) {
final String indexList = String.join(",", indices);
final State request = new State.Builder().withMetadata().indices(indexList).build();
final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't read cluster state for reopened indices " + indices);
return jestResult.getJsonObject();
}
use of io.searchbox.cluster.State in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method fieldsInIndices.
@Override
public Map<String, Set<String>> fieldsInIndices(String[] writeIndexWildcards) {
final String indices = String.join(",", writeIndexWildcards);
final State request = new State.Builder().indices(indices).withMetadata().build();
final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't read cluster state for indices " + indices);
final JsonNode indicesJson = getClusterStateIndicesMetadata(jestResult.getJsonObject());
final ImmutableMap.Builder<String, Set<String>> fields = ImmutableMap.builder();
final Iterator<Map.Entry<String, JsonNode>> it = indicesJson.fields();
while (it.hasNext()) {
final Map.Entry<String, JsonNode> entry = it.next();
final String indexName = entry.getKey();
final Set<String> fieldNames = ImmutableSet.copyOf(entry.getValue().path("mappings").path(IndexMapping.TYPE_MESSAGE).path("properties").fieldNames());
if (!fieldNames.isEmpty()) {
fields.put(indexName, fieldNames);
}
}
return fields.build();
}
use of io.searchbox.cluster.State in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method getIndexState.
private String getIndexState(String index) {
final State request = new State.Builder().indices(index).withMetadata().build();
final JestResult response = JestUtils.execute(jestClient, request, () -> "Failed to get index metadata");
return response.getJsonObject().path("metadata").path("indices").path(index).path("state").asText();
}
use of io.searchbox.cluster.State in project graylog2-server by Graylog2.
the class ClientES6 method cleanUp.
@Override
public void cleanUp() {
final State request = new State.Builder().withMetadata().build();
final JsonNode result = JestUtils.execute(client, request, () -> "failed to read state").getJsonObject();
deleteTemplates(metadataFieldNamesFor(result, "templates"));
deleteIndices(metadataFieldNamesFor(result, "indices"));
}
Aggregations