Search in sources :

Example 86 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method move.

@Override
public void move(String source, String target, Consumer<IndexMoveResult> resultCallback) {
    final ReindexRequest request = new ReindexRequest();
    request.setSourceIndices(source);
    request.setDestIndex(target);
    final BulkByScrollResponse result = client.execute((c, requestOptions) -> c.reindex(request, requestOptions));
    final IndexMoveResult indexMoveResult = IndexMoveResult.create(Math.toIntExact(result.getTotal()), result.getTook().millis(), !result.getBulkFailures().isEmpty());
    resultCallback.accept(indexMoveResult);
}
Also used : ReindexRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.reindex.ReindexRequest) IndexMoveResult(org.graylog2.indexer.indices.IndexMoveResult) BulkByScrollResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.reindex.BulkByScrollResponse)

Example 87 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method flush.

@Override
public void flush(String index) {
    final FlushRequest request = new FlushRequest(index);
    client.execute((c, requestOptions) -> c.indices().flush(request, requestOptions), "Unable to flush index " + index);
}
Also used : FlushRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.flush.FlushRequest)

Example 88 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method setReadOnly.

@Override
public void setReadOnly(String index) {
    // https://www.elastic.co/guide/en/elasticsearch/reference/7.8/indices-update-settings.html
    final Map<String, Object> settings = ImmutableMap.of("index", ImmutableMap.of("blocks", ImmutableMap.of(// Block writing.
    "write", // Block writing.
    true, // Allow reading.
    "read", // Allow reading.
    false, "metadata", // Allow getting metadata.
    false)));
    final UpdateSettingsRequest request = new UpdateSettingsRequest(index).settings(settings);
    client.execute((c, requestOptions) -> c.indices().putSettings(request, requestOptions), "Couldn't set index " + index + " to read-only");
}
Also used : UpdateSettingsRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest)

Example 89 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class CatApi method request.

private Request request(@SuppressWarnings("SameParameterValue") String method, String endpoint) {
    final Request request = new Request(method, "/_cat/" + endpoint);
    request.addParameter("format", "json");
    return request;
}
Also used : Request(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request)

Example 90 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class CatApi method requestIndices.

private JsonNode requestIndices(String indexName, String errorMessage) {
    final Request request = request("GET", "indices/" + indexName);
    request.addParameter("h", "index,status");
    request.addParameter("expand_wildcards", "all");
    request.addParameter("s", "index,status");
    return perform(request, new TypeReference<JsonNode>() {
    }, errorMessage);
}
Also used : Request(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

Request (org.elasticsearch.client.Request)54 Response (org.elasticsearch.client.Response)34 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 IOException (java.io.IOException)12 Request (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request)12 HttpEntity (org.apache.http.HttpEntity)11 NStringEntity (org.apache.http.nio.entity.NStringEntity)11 Map (java.util.Map)10 Collectors (java.util.stream.Collectors)10 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 SearchRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest)7 Response (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Response)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 InputStream (java.io.InputStream)6 StringEntity (org.apache.http.entity.StringEntity)6 RestClient (org.elasticsearch.client.RestClient)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 HashMap (java.util.HashMap)5 Locale (java.util.Locale)5 ContentType (org.apache.http.entity.ContentType)5