use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class ClientES7 method putTemplate.
@Override
public void putTemplate(String templateName, Map<String, Object> source) {
final PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName).source(source);
client.execute((c, requestOptions) -> c.indices().putTemplate(request, requestOptions), "Unable to put template " + templateName);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class ClientES7 method resetIndexBlock.
@Override
public void resetIndexBlock(String index) {
final UpdateSettingsRequest request = new UpdateSettingsRequest(index).settings(Collections.singletonMap("index.blocks.read_only_allow_delete", null));
client.execute((c, requestOptions) -> c.indices().putSettings(request, requestOptions), "Unable to reset index block for " + index);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method searchTypeWithoutStreamsDefaultsToQueriesStreams.
@Test
public void searchTypeWithoutStreamsDefaultsToQueriesStreams() throws IOException {
final Query query = queryFor(Pivot.builder().id("pivot1").series(Collections.singletonList(Average.builder().field("field1").build())).rollup(true).build());
final List<SearchRequest> request = run(query);
assertThat(indicesOf(request).get(0)).isEqualTo("index1,index2");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class ClusterAdapterES7 method clusterStats.
@Override
public ClusterStats clusterStats() {
final Request request = new Request("GET", "/_cluster/stats/nodes/*");
final JsonNode clusterStatsResponseJson = jsonApi.perform(request, "Couldn't read Elasticsearch cluster stats");
final String clusterName = clusterStatsResponseJson.path("cluster_name").asText();
String clusterVersion = null;
if (clusterStatsResponseJson.path("nodes").path("versions").isArray()) {
final ArrayNode versions = (ArrayNode) clusterStatsResponseJson.path("nodes").path("versions");
// We just use the first version in the "versions" array. This is not correct if there are different
// versions running in the cluster, but that is not recommended anyway.
final JsonNode versionNode = versions.path(0);
if (versionNode.getNodeType() != JsonNodeType.MISSING) {
clusterVersion = versionNode.asText();
}
}
final JsonNode countStats = clusterStatsResponseJson.path("nodes").path("count");
final NodesStats nodesStats = NodesStats.create(countStats.path("total").asInt(-1), countStats.path("master_only").asInt(-1), countStats.path("data_only").asInt(-1), countStats.path("master_data").asInt(-1), countStats.path("client").asInt(-1));
final JsonNode clusterIndicesStats = clusterStatsResponseJson.path("indices");
final IndicesStats indicesStats = IndicesStats.create(clusterIndicesStats.path("count").asInt(-1), clusterIndicesStats.path("store").path("size_in_bytes").asLong(-1L), clusterIndicesStats.path("fielddata").path("memory_size_in_bytes").asLong(-1L));
return ClusterStats.create(clusterName, clusterVersion, nodesStats, indicesStats);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method create.
@Override
public void create(String index, IndexSettings indexSettings) {
final Map<String, Object> settings = new HashMap<>();
settings.put("number_of_shards", indexSettings.shards());
settings.put("number_of_replicas", indexSettings.replicas());
final CreateIndexRequest request = new CreateIndexRequest(index).settings(settings);
client.execute((c, requestOptions) -> c.indices().create(request, requestOptions), "Unable to create index " + index);
}
Aggregations