From fb0dfbb683df41c087a0bbc781c4ba06dc23667a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 11 May 2020 14:11:59 +0200 Subject: [PATCH] fix mapping / date detection, adapt to API changes --- .../org/xbib/elx/http/test/ClientTest.java | 9 +++++---- .../xbib/elx/http/test/DuplicateIDTest.java | 2 +- .../org/xbib/elx/http/test/SmokeTest.java | 4 ++-- .../org/xbib/elx/node/test/ClientTest.java | 9 +++++---- .../xbib/elx/node/test/DuplicateIDTest.java | 2 +- .../org/xbib/elx/node/test/SmokeTest.java | 4 ++-- .../transport/ExtendedTransportClient.java | 20 ++++++++----------- .../xbib/elx/transport/test/ClientTest.java | 17 +++++++++------- .../elx/transport/test/DuplicateIDTest.java | 2 +- .../xbib/elx/transport/test/SmokeTest.java | 4 ++-- gradle.properties | 2 +- 11 files changed, 38 insertions(+), 37 deletions(-) diff --git a/elx-http/src/test/java/org/xbib/elx/http/test/ClientTest.java b/elx-http/src/test/java/org/xbib/elx/http/test/ClientTest.java index b68486c..cb0b2cf 100644 --- a/elx-http/src/test/java/org/xbib/elx/http/test/ClientTest.java +++ b/elx-http/src/test/java/org/xbib/elx/http/test/ClientTest.java @@ -68,7 +68,7 @@ class ClientTest { } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { - assertEquals(1, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(1, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -116,6 +116,7 @@ class ClientTest { Settings settings = Settings.builder().put("index.number_of_shards", "1").build(); XContentBuilder builder = JsonXContent.contentBuilder() .startObject() + .field("date_detection", false) .startObject("properties") .startObject("pos") .field("type", "geo_point") @@ -157,7 +158,7 @@ class ClientTest { } catch (Exception e) { logger.error(e.getMessage(), e); } finally { - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -214,7 +215,7 @@ class ClientTest { logger.warn("latch timeout"); } client.stopBulk("test", 30L, TimeUnit.SECONDS); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } catch (Exception e) { @@ -224,7 +225,7 @@ class ClientTest { logger.error("error", client.getBulkController().getLastBulkError()); } assertNull(client.getBulkController().getLastBulkError()); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); logger.log(Level.INFO, "refreshing index test"); client.refreshIndex("test"); SearchSourceBuilder builder = new SearchSourceBuilder() diff --git a/elx-http/src/test/java/org/xbib/elx/http/test/DuplicateIDTest.java b/elx-http/src/test/java/org/xbib/elx/http/test/DuplicateIDTest.java index 692cc76..2fd356c 100644 --- a/elx-http/src/test/java/org/xbib/elx/http/test/DuplicateIDTest.java +++ b/elx-http/src/test/java/org/xbib/elx/http/test/DuplicateIDTest.java @@ -69,7 +69,7 @@ class DuplicateIDTest { logger.warn("skipping, no node available"); } finally { client.close(); - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } diff --git a/elx-http/src/test/java/org/xbib/elx/http/test/SmokeTest.java b/elx-http/src/test/java/org/xbib/elx/http/test/SmokeTest.java index b2b86fb..e0d8879 100644 --- a/elx-http/src/test/java/org/xbib/elx/http/test/SmokeTest.java +++ b/elx-http/src/test/java/org/xbib/elx/http/test/SmokeTest.java @@ -60,8 +60,8 @@ class SmokeTest { int replica = client.getReplicaLevel(indexDefinition); assertEquals(2, replica); client.deleteIndex(indexDefinition); - assertEquals(0, client.getBulkMetric().getFailed().getCount()); - assertEquals(6, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(0, client.getBulkController().getBulkMetric().getFailed().getCount()); + assertEquals(6, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/ClientTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/ClientTest.java index ed26bd0..3b301d6 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/ClientTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/ClientTest.java @@ -66,7 +66,7 @@ class ClientTest { } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { - assertEquals(1, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(1, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -111,6 +111,7 @@ class ClientTest { Settings settings = Settings.builder().put("index.number_of_shards", "1").build(); XContentBuilder builder = JsonXContent.contentBuilder() .startObject() + .field("date_detection", false) .startObject("properties") .startObject("location") .field("type", "geo_point") @@ -152,7 +153,7 @@ class ClientTest { } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -209,7 +210,7 @@ class ClientTest { logger.warn("latch timeout"); } client.stopBulk("test", 30L, TimeUnit.SECONDS); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { @@ -217,7 +218,7 @@ class ClientTest { logger.error("error", client.getBulkController().getLastBulkError()); } assertNull(client.getBulkController().getLastBulkError()); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); logger.log(Level.INFO, "refreshing index test"); client.refreshIndex("test"); SearchSourceBuilder builder = new SearchSourceBuilder() diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/DuplicateIDTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/DuplicateIDTest.java index 0eb1547..80c15d0 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/DuplicateIDTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/DuplicateIDTest.java @@ -68,7 +68,7 @@ class DuplicateIDTest { logger.warn("skipping, no node available"); } finally { client.close(); - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/SmokeTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/SmokeTest.java index d6e458d..cc698aa 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/SmokeTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/SmokeTest.java @@ -59,8 +59,8 @@ class SmokeTest { int replica = client.getReplicaLevel(indexDefinition); assertEquals(2, replica); client.deleteIndex(indexDefinition); - //assertEquals(0, client.getBulkMetric().getFailed().getCount()); - //assertEquals(6, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(0, client.getBulkController().getBulkMetric().getFailed().getCount()); + assertEquals(6, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { diff --git a/elx-transport/src/main/java/org/xbib/elx/transport/ExtendedTransportClient.java b/elx-transport/src/main/java/org/xbib/elx/transport/ExtendedTransportClient.java index cefe71f..28d6d0c 100644 --- a/elx-transport/src/main/java/org/xbib/elx/transport/ExtendedTransportClient.java +++ b/elx-transport/src/main/java/org/xbib/elx/transport/ExtendedTransportClient.java @@ -124,13 +124,15 @@ public class ExtendedTransportClient extends AbstractExtendedClient { logger.info("connected to nodes = {}", nodes); if (nodes != null && !nodes.isEmpty()) { if (autodiscover) { - logger.debug("trying to auto-discover all nodes..."); + logger.debug("trying to discover all nodes..."); ClusterStateRequestBuilder clusterStateRequestBuilder = new ClusterStateRequestBuilder(getClient(), ClusterStateAction.INSTANCE); ClusterStateResponse clusterStateResponse = clusterStateRequestBuilder.execute().actionGet(); DiscoveryNodes discoveryNodes = clusterStateResponse.getState().getNodes(); - addDiscoveryNodes(transportClient, discoveryNodes); - logger.info("after auto-discovery: connected to {}", transportClient.connectedNodes()); + for (DiscoveryNode discoveryNode : discoveryNodes) { + transportClient.addTransportAddress(discoveryNode.getAddress()); + } + logger.info("after discovery: connected to {}", transportClient.connectedNodes()); } return true; } @@ -142,9 +144,9 @@ public class ExtendedTransportClient extends AbstractExtendedClient { // "cluster.name" .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey())) - // "processors" - .put(EsExecutors.PROCESSORS_SETTING.getKey(), - settings.get(EsExecutors.PROCESSORS_SETTING.getKey(), + // "node.processors" + .put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), + settings.get(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), String.valueOf(Runtime.getRuntime().availableProcessors()))) // "transport.type" .put(NetworkModule.TRANSPORT_TYPE_KEY, @@ -152,12 +154,6 @@ public class ExtendedTransportClient extends AbstractExtendedClient { .build(); } - private void addDiscoveryNodes(TransportClient transportClient, DiscoveryNodes discoveryNodes) { - for (DiscoveryNode discoveryNode : discoveryNodes) { - transportClient.addTransportAddress(discoveryNode.getAddress()); - } - } - static class MyTransportClient extends TransportClient { MyTransportClient(Settings settings, Collection> plugins) { diff --git a/elx-transport/src/test/java/org/xbib/elx/transport/test/ClientTest.java b/elx-transport/src/test/java/org/xbib/elx/transport/test/ClientTest.java index 5f2ae9a..86efd7b 100644 --- a/elx-transport/src/test/java/org/xbib/elx/transport/test/ClientTest.java +++ b/elx-transport/src/test/java/org/xbib/elx/transport/test/ClientTest.java @@ -66,7 +66,7 @@ class ClientTest { } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { - assertEquals(1, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(1, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -114,6 +114,7 @@ class ClientTest { Settings settings = Settings.builder().put("index.number_of_shards", "1").build(); XContentBuilder builder = JsonXContent.contentBuilder() .startObject() + .field("date_detection", false) .startObject("properties") .startObject("location") .field("type", "geo_point") @@ -121,9 +122,11 @@ class ClientTest { .endObject() .endObject(); client.newIndex("test", settings, builder); - GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices("test"); - GetMappingsResponse getMappingsResponse = - client.getClient().execute(GetMappingsAction.INSTANCE, getMappingsRequest).actionGet(); + GetMappingsRequest getMappingsRequest = new GetMappingsRequest() + .indices("test"); + GetMappingsResponse getMappingsResponse = client.getClient() + .execute(GetMappingsAction.INSTANCE, getMappingsRequest) + .actionGet(); logger.info("mappings={}", getMappingsResponse.getMappings()); assertTrue(getMappingsResponse.getMappings().get("test").containsKey("_doc")); client.close(); @@ -151,7 +154,7 @@ class ClientTest { } catch (Exception e) { logger.error(e.getMessage(), e); } finally { - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } @@ -216,7 +219,7 @@ class ClientTest { logger.warn("latch timeout"); } client.stopBulk("test", 30L, TimeUnit.SECONDS); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } catch (Exception e) { @@ -226,7 +229,7 @@ class ClientTest { logger.error("error", client.getBulkController().getLastBulkError()); } assertNull(client.getBulkController().getLastBulkError()); - assertEquals(maxthreads * actions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(maxthreads * actions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); logger.log(Level.INFO, "refreshing index test"); client.refreshIndex("test"); SearchSourceBuilder builder = new SearchSourceBuilder() diff --git a/elx-transport/src/test/java/org/xbib/elx/transport/test/DuplicateIDTest.java b/elx-transport/src/test/java/org/xbib/elx/transport/test/DuplicateIDTest.java index d2c2773..9bc45a7 100644 --- a/elx-transport/src/test/java/org/xbib/elx/transport/test/DuplicateIDTest.java +++ b/elx-transport/src/test/java/org/xbib/elx/transport/test/DuplicateIDTest.java @@ -69,7 +69,7 @@ class DuplicateIDTest { logger.warn("skipping, no node available"); } finally { client.close(); - assertEquals(numactions, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(numactions, client.getBulkController().getBulkMetric().getSucceeded().getCount()); if (client.getBulkController().getLastBulkError() != null) { logger.error("error", client.getBulkController().getLastBulkError()); } diff --git a/elx-transport/src/test/java/org/xbib/elx/transport/test/SmokeTest.java b/elx-transport/src/test/java/org/xbib/elx/transport/test/SmokeTest.java index ac17b60..49e5b90 100644 --- a/elx-transport/src/test/java/org/xbib/elx/transport/test/SmokeTest.java +++ b/elx-transport/src/test/java/org/xbib/elx/transport/test/SmokeTest.java @@ -57,8 +57,8 @@ class SmokeTest { int replica = client.getReplicaLevel(indexDefinition); assertEquals(2, replica); client.deleteIndex(indexDefinition); - assertEquals(0, client.getBulkMetric().getFailed().getCount()); - assertEquals(4, client.getBulkMetric().getSucceeded().getCount()); + assertEquals(0, client.getBulkController().getBulkMetric().getFailed().getCount()); + assertEquals(4, client.getBulkController().getBulkMetric().getSucceeded().getCount()); } catch (NoNodeAvailableException e) { logger.warn("skipping, no node available"); } finally { diff --git a/gradle.properties b/gradle.properties index 4f0ebb6..89f8883 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = elx -version = 7.6.1.0 +version = 7.6.1.1 elasticsearch.version = 7.6.1 netty.version = 4.1.49.Final