From 465da6a66826d4be4506691f8d61a5b6ac681c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=BA=90?= Date: Tue, 4 Feb 2025 14:53:09 +0800 Subject: [PATCH] es 8.16.0 support --- .travis.yml | 2 +- pom.xml | 4 ++-- src/main/java/org/nlpcn/es4sql/Test.java | 3 ++- src/test/java/org/nlpcn/es4sql/MainTestSuite.java | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81184b34..8eb8beeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ jdk: before_install: - sudo rm -rf /var/lib/elasticsearch - - curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.5-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb + - curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb - sudo cp ./src/test/resources/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml - sudo cat /etc/elasticsearch/elasticsearch.yml - sudo java -version diff --git a/pom.xml b/pom.xml index 0d735633..3617be41 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.nlpcn elasticsearch-sql - 8.15.5.0 + 8.16.0.0 jar Query elasticsearch using SQL elasticsearch-sql @@ -44,7 +44,7 @@ UTF-8 **/MainTestSuite.class sql - 8.15.5 + 8.16.0 org.elasticsearch.plugin.nlpcn.SqlPlug 1.2.15 32.0.0-jre diff --git a/src/main/java/org/nlpcn/es4sql/Test.java b/src/main/java/org/nlpcn/es4sql/Test.java index 94907360..e52851ca 100644 --- a/src/main/java/org/nlpcn/es4sql/Test.java +++ b/src/main/java/org/nlpcn/es4sql/Test.java @@ -4,6 +4,7 @@ import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.telemetry.metric.MeterRegistry; +import org.elasticsearch.threadpool.DefaultBuiltInExecutorBuilders; import org.elasticsearch.threadpool.ThreadPool; import java.util.HashMap; @@ -22,7 +23,7 @@ public static String sqlToEsQuery(String sql) throws Exception { // .put(ThreadContext.PREFIX + ".key2", "val 2") // .build(); - ThreadPool threadPool = new ThreadPool(settings, MeterRegistry.NOOP); + ThreadPool threadPool = new ThreadPool(settings, MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders()); Client client = new NodeClient(settings, threadPool); SearchDao searchDao = new org.nlpcn.es4sql.SearchDao(client); try { diff --git a/src/test/java/org/nlpcn/es4sql/MainTestSuite.java b/src/test/java/org/nlpcn/es4sql/MainTestSuite.java index 34ea358e..bc8b3959 100644 --- a/src/test/java/org/nlpcn/es4sql/MainTestSuite.java +++ b/src/test/java/org/nlpcn/es4sql/MainTestSuite.java @@ -21,6 +21,7 @@ import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder; import org.elasticsearch.plugin.nlpcn.client.ElasticsearchRestClient; @@ -82,7 +83,7 @@ public static void setUp() throws Exception { String clusterName = nodeInfos.getClusterName().value(); System.out.println(String.format("Found cluster... cluster name: %s", clusterName)); - client.admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableMap.of(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)).get(); + client.admin().cluster().prepareUpdateSettings(TimeValue.ONE_MINUTE, TimeValue.ONE_MINUTE).setTransientSettings(ImmutableMap.of(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)).get(); // Load test data. loadBulk("src/test/resources/online.json", TEST_INDEX_ONLINE); @@ -147,7 +148,7 @@ private static void createTestIndex(String index) { } private static void deleteTestIndex(String index) { - if(client.admin().cluster().prepareState().execute().actionGet().getState().getMetadata().hasIndex(index)){ + if(client.admin().cluster().prepareState(TimeValue.ONE_MINUTE).execute().actionGet().getState().getMetadata().hasIndex(index)){ client.admin().indices().prepareDelete(index).get(); } } @@ -446,7 +447,7 @@ private static TransportAddress getTransportAddress() throws UnknownHostExceptio } private static ElasticsearchTransport getElasticsearchTransport(RestClient restClient) { - RestClientOptions.Builder transportOptionsBuilder = new RestClientOptions(RequestOptions.DEFAULT).toBuilder(); + RestClientOptions.Builder transportOptionsBuilder = new RestClientOptions(RequestOptions.DEFAULT, true).toBuilder(); ContentType jsonContentType = Version.VERSION == null ? ContentType.APPLICATION_JSON : ContentType.create("application/vnd.elasticsearch+json",