use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project beam by apache.
the class ElasticsearchIO method getBackendVersion.
static int getBackendVersion(ConnectionConfiguration connectionConfiguration) {
try (RestClient restClient = connectionConfiguration.createClient()) {
Request request = new Request("GET", "");
Response response = restClient.performRequest(request);
JsonNode jsonNode = parseResponse(response.getEntity());
int backendVersion = Integer.parseInt(jsonNode.path("version").path("number").asText().substring(0, 1));
checkArgument(VALID_CLUSTER_VERSIONS.contains(backendVersion), "The Elasticsearch version to connect to is %s.x. " + "This version of the ElasticsearchIO is only compatible with " + "Elasticsearch v7.x, v6.x, v5.x and v2.x", backendVersion);
return backendVersion;
} catch (IOException e) {
throw new IllegalArgumentException("Cannot get Elasticsearch version", e);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project beam by apache.
the class ElasticsearchIOTestUtils method deleteIndex.
static void deleteIndex(RestClient restClient, String index) throws IOException {
try {
closeIndex(restClient, index);
Request request = new Request("DELETE", String.format("/%s", index));
restClient.performRequest(request);
} catch (IOException e) {
// so when the first tests is run, the index does not exist yet
if (!e.getMessage().contains("index_not_found_exception")) {
throw e;
}
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project beam by apache.
the class ElasticsearchIOTestUtils method flushAndRefreshAllIndices.
static void flushAndRefreshAllIndices(RestClient restClient) throws IOException {
Request request = new Request("POST", "/_flush");
restClient.performRequest(request);
request = new Request("POST", "/_refresh");
restClient.performRequest(request);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project beam by apache.
the class ElasticsearchIOTestUtils method closeIndex.
private static void closeIndex(RestClient restClient, String index) throws IOException {
Request request = new Request("POST", String.format("/%s/_close", index));
restClient.performRequest(request);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project beam by apache.
the class ElasticsearchIOTestUtils method createIndex.
public static void createIndex(RestClient restClient, String indexName) throws IOException {
deleteIndex(restClient, indexName);
Request request = new Request("PUT", String.format("/%s", indexName));
restClient.performRequest(request);
}
Aggregations