From 7b71bf94815040f5a67a929c11ffb3d860566d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 6 Apr 2020 11:16:33 +0200 Subject: [PATCH] update for new 6.3.2.4 version --- .gitignore | 1 + .../java/org/xbib/elx/api/BulkProcessor.java | 2 +- .../java/org/xbib/elx/api/ExtendedClient.java | 2 +- .../org/xbib/elx/api/ReadClientProvider.java | 2 +- .../elx/common/AbstractExtendedClient.java | 13 ++-- .../org/xbib/elx/common/ClientBuilder.java | 11 +++- .../elx/common/DefaultBulkController.java | 28 ++++++--- .../xbib/elx/common/DefaultBulkProcessor.java | 2 +- .../java/org/xbib/elx/common/Parameters.java | 12 ++++ .../org/xbib/elx/common/io/package-info.java | 2 +- .../org/xbib/elx/common/package-info.java | 2 +- .../xbib/elx/common/util/package-info.java | 2 +- .../org/xbib/elx/common/test/AliasTest.java | 5 +- .../xbib/elx/common/test/TestExtension.java | 4 +- elx-http/build.gradle | 9 +++ .../mapping/get/HttpGetMappingsAction.java | 4 +- .../org/xbib/elx/http/ExtendedHttpClient.java | 3 +- .../java/org/xbib/elx/http/HttpAction.java | 62 +++++++++---------- .../org/xbib/elx/http/HttpActionContext.java | 12 ++-- .../org/xbib/elx/http/HttpActionFuture.java | 2 +- .../health/HttpClusterHealthAction.java | 4 +- .../node/info/HttpNodesInfoAction.java | 14 +++-- .../HttpClusterUpdateSettingsAction.java | 4 +- .../cluster/state/HttpClusterStateAction.java | 4 +- .../alias/HttpIndicesAliasesAction.java | 4 +- .../indices/alias/get/HttpGetAliasAction.java | 4 +- .../indices/create/HttpCreateIndexAction.java | 4 +- .../indices/delete/HttpDeleteIndexAction.java | 4 +- .../indices/HttpIndicesExistsAction.java | 4 +- .../refresh/HttpRefreshIndexAction.java | 4 +- .../settings/get/HttpGetSettingsAction.java | 4 +- .../put/HttpUpdateSettingsAction.java | 4 +- .../elx/http/action/bulk/HttpBulkAction.java | 4 +- .../elx/http/action/get/HttpExistsAction.java | 4 +- .../elx/http/action/get/HttpGetAction.java | 4 +- .../http/action/index/HttpIndexAction.java | 4 +- .../elx/http/action/main/HttpMainAction.java | 4 +- .../http/action/search/HttpSearchAction.java | 4 +- .../http/action/update/HttpUpdateAction.java | 4 +- elx-http/src/test/resources/log4j2.xml | 2 +- .../java/org/xbib/elx/node/package-info.java | 2 +- .../org/xbib/elx/node/test/ClientTest.java | 8 +-- .../xbib/elx/node/test/IndexPruneTest.java | 28 ++++----- .../xbib/elx/node/test/IndexShiftTest.java | 16 ++--- .../org/xbib/elx/node/test/SmokeTest.java | 18 +++--- .../org/xbib/elx/node/test/TestExtension.java | 2 +- .../transport/ExtendedTransportClient.java | 12 ++-- .../xbib/elx/transport/test/ClientTest.java | 26 ++++---- .../elx/transport/test/DuplicateIDTest.java | 10 +-- .../elx/transport/test/IndexPruneTest.java | 28 ++++----- .../elx/transport/test/IndexShiftTest.java | 24 +++---- .../xbib/elx/transport/test/SmokeTest.java | 14 ++--- elx-transport/src/test/resources/log4j2.xml | 2 +- gradle.properties | 13 ++-- 54 files changed, 262 insertions(+), 209 deletions(-) diff --git a/.gitignore b/.gitignore index b92da43..852078a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ /.project /.gradle build +out plugins diff --git a/elx-api/src/main/java/org/xbib/elx/api/BulkProcessor.java b/elx-api/src/main/java/org/xbib/elx/api/BulkProcessor.java index 4d38d1c..0ab7b79 100644 --- a/elx-api/src/main/java/org/xbib/elx/api/BulkProcessor.java +++ b/elx-api/src/main/java/org/xbib/elx/api/BulkProcessor.java @@ -29,7 +29,7 @@ public interface BulkProcessor extends Closeable, Flushable { /** * A listener for the execution. */ - public interface Listener { + interface Listener { /** * Callback before the bulk is executed. diff --git a/elx-api/src/main/java/org/xbib/elx/api/ExtendedClient.java b/elx-api/src/main/java/org/xbib/elx/api/ExtendedClient.java index f3fda84..a6325f6 100644 --- a/elx-api/src/main/java/org/xbib/elx/api/ExtendedClient.java +++ b/elx-api/src/main/java/org/xbib/elx/api/ExtendedClient.java @@ -317,7 +317,7 @@ public interface ExtendedClient extends Flushable, Closeable { /** * Force segment merge of an index. - * @param indexDefinition th eindex definition + * @param indexDefinition the index definition * @return this */ boolean forceMerge(IndexDefinition indexDefinition); diff --git a/elx-api/src/main/java/org/xbib/elx/api/ReadClientProvider.java b/elx-api/src/main/java/org/xbib/elx/api/ReadClientProvider.java index b815af7..bc0eb16 100644 --- a/elx-api/src/main/java/org/xbib/elx/api/ReadClientProvider.java +++ b/elx-api/src/main/java/org/xbib/elx/api/ReadClientProvider.java @@ -2,5 +2,5 @@ package org.xbib.elx.api; public interface ReadClientProvider { - C getReadClient(); + C getReadClient(); } diff --git a/elx-common/src/main/java/org/xbib/elx/common/AbstractExtendedClient.java b/elx-common/src/main/java/org/xbib/elx/common/AbstractExtendedClient.java index 54e0efa..417bc1e 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/AbstractExtendedClient.java +++ b/elx-common/src/main/java/org/xbib/elx/common/AbstractExtendedClient.java @@ -2,6 +2,7 @@ package org.xbib.elx.common; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchTimeoutException; @@ -194,16 +195,17 @@ public abstract class AbstractExtendedClient implements ExtendedClient { @Override public AbstractExtendedClient init(Settings settings) throws IOException { + logger.log(Level.INFO, "initializing with settings = " + settings.toDelimitedString(',')); if (client == null) { client = createClient(settings); } if (bulkMetric == null) { - this.bulkMetric = new DefaultBulkMetric(); - this.bulkMetric.init(settings); + bulkMetric = new DefaultBulkMetric(); + bulkMetric.init(settings); } if (bulkController == null) { - this.bulkController = new DefaultBulkController(this, bulkMetric); - this.bulkController.init(settings); + bulkController = new DefaultBulkController(this, bulkMetric); + bulkController.init(settings); } return this; } @@ -235,8 +237,7 @@ public abstract class AbstractExtendedClient implements ExtendedClient { public String getClusterName() { ensureActive(); try { - ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); - clusterStateRequest.clear(); + ClusterStateRequest clusterStateRequest = new ClusterStateRequest().clear(); ClusterStateResponse clusterStateResponse = client.execute(ClusterStateAction.INSTANCE, clusterStateRequest).actionGet(); return clusterStateResponse.getClusterName().value(); diff --git a/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java b/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java index ba9150f..e77a55a 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java +++ b/elx-common/src/main/java/org/xbib/elx/common/ClientBuilder.java @@ -1,5 +1,8 @@ package org.xbib.elx.common; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.settings.Settings; @@ -16,6 +19,8 @@ import java.util.ServiceLoader; @SuppressWarnings("rawtypes") public class ClientBuilder { + private static final Logger logger = LogManager.getLogger(ClientBuilder.class); + private final ElasticsearchClient client; private final Settings.Builder settingsBuilder; @@ -97,6 +102,10 @@ public class ClientBuilder { if (provider == null) { throw new IllegalArgumentException("no provider"); } - return (C) providerMap.get(provider).getExtendedClient().setClient(client).init(settingsBuilder.build()); + Settings settings = settingsBuilder.build(); + logger.log(Level.INFO, "settings = " + settings.toDelimitedString(',')); + return (C) providerMap.get(provider).getExtendedClient() + .setClient(client) + .init(settings); } } diff --git a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkController.java b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkController.java index 873145b..432cae4 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkController.java +++ b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkController.java @@ -49,6 +49,8 @@ public class DefaultBulkController implements BulkController { private AtomicBoolean active; + private boolean enableBulkLogging; + public DefaultBulkController(ExtendedClient client, BulkMetric bulkMetric) { this.client = client; this.bulkMetric = bulkMetric; @@ -76,11 +78,8 @@ public class DefaultBulkController implements BulkController { ByteSizeValue maxVolumePerRequest = settings.getAsBytesSize(Parameters.MAX_VOLUME_PER_REQUEST.name(), ByteSizeValue.parseBytesSizeValue(Parameters.DEFAULT_MAX_VOLUME_PER_REQUEST.getString(), "maxVolumePerRequest")); - if (logger.isInfoEnabled()) { - logger.info("bulk processor up with maxActionsPerRequest = {} maxConcurrentRequests = {} " + - "flushIngestInterval = {} maxVolumePerRequest = {}", - maxActionsPerRequest, maxConcurrentRequests, flushIngestInterval, maxVolumePerRequest); - } + this.enableBulkLogging = settings.getAsBoolean(Parameters.ENABLE_BULK_LOGGING.name(), + Parameters.ENABLE_BULK_LOGGING.getValue()); this.bulkListener = new BulkListener(); this.bulkProcessor = DefaultBulkProcessor.builder(client.getClient(), bulkListener) .setBulkActions(maxActionsPerRequest) @@ -89,6 +88,12 @@ public class DefaultBulkController implements BulkController { .setBulkSize(maxVolumePerRequest) .build(); this.active.set(true); + if (logger.isInfoEnabled()) { + logger.info("bulk processor up with maxActionsPerRequest = {} maxConcurrentRequests = {} " + + "flushIngestInterval = {} maxVolumePerRequest = {} bulk logging = {} logger debug = {} from settings = {}", + maxActionsPerRequest, maxConcurrentRequests, flushIngestInterval, maxVolumePerRequest, + enableBulkLogging, logger.isDebugEnabled(), settings.toDelimitedString(',')); + } } @Override @@ -115,6 +120,9 @@ public class DefaultBulkController implements BulkController { @Override public void index(IndexRequest indexRequest) { ensureActiveAndBulk(); + if (!active.get()) { + throw new IllegalStateException("inactive"); + } try { if (bulkMetric != null) { bulkMetric.getCurrentIngest().inc(indexRequest.index(), indexRequest.type(), indexRequest.id()); @@ -237,7 +245,7 @@ public class DefaultBulkController implements BulkController { private class BulkListener implements DefaultBulkProcessor.Listener { - private final Logger logger = LogManager.getLogger("org.xbib.elx.BulkProcessor.Listener"); + private final Logger logger = LogManager.getLogger(BulkListener.class.getName()); private Throwable lastBulkError = null; @@ -252,7 +260,7 @@ public class DefaultBulkController implements BulkController { bulkMetric.getCurrentIngestNumDocs().inc(n); bulkMetric.getTotalIngestSizeInBytes().inc(request.estimatedSizeInBytes()); } - if (logger.isDebugEnabled()) { + if (enableBulkLogging && logger.isDebugEnabled()) { logger.debug("before bulk [{}] [actions={}] [bytes={}] [concurrent requests={}]", executionId, request.numberOfActions(), @@ -282,7 +290,7 @@ public class DefaultBulkController implements BulkController { } } } - if (bulkMetric != null && logger.isDebugEnabled()) { + if (enableBulkLogging && logger.isDebugEnabled() && bulkMetric != null) { logger.debug("after bulk [{}] [succeeded={}] [failed={}] [{}ms] {} concurrent requests", executionId, bulkMetric.getSucceeded().getCount(), @@ -291,7 +299,7 @@ public class DefaultBulkController implements BulkController { l); } if (n > 0) { - if (logger.isErrorEnabled()) { + if (enableBulkLogging && logger.isErrorEnabled()) { logger.error("bulk [{}] failed with {} failed items, failure message = {}", executionId, n, response.buildFailureMessage()); } @@ -309,7 +317,7 @@ public class DefaultBulkController implements BulkController { } lastBulkError = failure; active.set(false); - if (logger.isErrorEnabled()) { + if (enableBulkLogging && logger.isErrorEnabled()) { logger.error("after bulk [" + executionId + "] error", failure); } } diff --git a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java index 0abebc6..f80742a 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java +++ b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java @@ -124,7 +124,7 @@ public class DefaultBulkProcessor implements BulkProcessor { closed = true; if (scheduledFuture != null) { FutureUtils.cancel(scheduledFuture); - this.scheduler.shutdown(); + scheduler.shutdown(); } if (bulkRequest.numberOfActions() > 0) { execute(); diff --git a/elx-common/src/main/java/org/xbib/elx/common/Parameters.java b/elx-common/src/main/java/org/xbib/elx/common/Parameters.java index 28d10d7..73819e1 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/Parameters.java +++ b/elx-common/src/main/java/org/xbib/elx/common/Parameters.java @@ -2,6 +2,8 @@ package org.xbib.elx.common; public enum Parameters { + ENABLE_BULK_LOGGING(false), + DEFAULT_MAX_ACTIONS_PER_REQUEST(1000), DEFAULT_MAX_CONCURRENT_REQUESTS(Runtime.getRuntime().availableProcessors()), @@ -18,10 +20,16 @@ public enum Parameters { FLUSH_INTERVAL("flush_interval"); + boolean flag; + int num; String string; + Parameters(boolean flag) { + this.flag = flag; + } + Parameters(int num) { this.num = num; } @@ -30,6 +38,10 @@ public enum Parameters { this.string = string; } + boolean getValue() { + return flag; + } + int getNum() { return num; } diff --git a/elx-common/src/main/java/org/xbib/elx/common/io/package-info.java b/elx-common/src/main/java/org/xbib/elx/common/io/package-info.java index 492a3e2..5e86ba1 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/io/package-info.java +++ b/elx-common/src/main/java/org/xbib/elx/common/io/package-info.java @@ -1,4 +1,4 @@ /** - * + * I/O helpers for Elasticsearch client extensions. */ package org.xbib.elx.common.io; diff --git a/elx-common/src/main/java/org/xbib/elx/common/package-info.java b/elx-common/src/main/java/org/xbib/elx/common/package-info.java index ced4357..4971f08 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/package-info.java +++ b/elx-common/src/main/java/org/xbib/elx/common/package-info.java @@ -1,4 +1,4 @@ /** - * + * Common classes for Elasticsearch client extensions. */ package org.xbib.elx.common; diff --git a/elx-common/src/main/java/org/xbib/elx/common/util/package-info.java b/elx-common/src/main/java/org/xbib/elx/common/util/package-info.java index 20a7cbb..cd393c9 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/util/package-info.java +++ b/elx-common/src/main/java/org/xbib/elx/common/util/package-info.java @@ -1,4 +1,4 @@ /** - * + * Utilities for Elasticsearch client extensions. */ package org.xbib.elx.common.util; diff --git a/elx-common/src/test/java/org/xbib/elx/common/test/AliasTest.java b/elx-common/src/test/java/org/xbib/elx/common/test/AliasTest.java index 63491bf..fb31cde 100644 --- a/elx-common/src/test/java/org/xbib/elx/common/test/AliasTest.java +++ b/elx-common/src/test/java/org/xbib/elx/common/test/AliasTest.java @@ -71,15 +71,14 @@ class AliasTest { indexRequest = new CreateIndexRequest("test20160103"); client.execute(CreateIndexAction.INSTANCE, indexRequest).actionGet(); IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); - String[] indices = new String[]{"test20160101", "test20160102", "test20160103"}; - String[] aliases = new String[]{alias}; + String[] indices = new String[] { "test20160101", "test20160102", "test20160103" }; + String[] aliases = new String[] { alias }; IndicesAliasesRequest.AliasActions aliasAction = new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.ADD) .indices(indices) .aliases(aliases); indicesAliasesRequest.addAliasAction(aliasAction); client.execute(IndicesAliasesAction.INSTANCE, indicesAliasesRequest).actionGet(); - GetAliasesRequest getAliasesRequest = new GetAliasesRequest(); getAliasesRequest.aliases(alias); GetAliasesResponse getAliasesResponse = diff --git a/elx-common/src/test/java/org/xbib/elx/common/test/TestExtension.java b/elx-common/src/test/java/org/xbib/elx/common/test/TestExtension.java index 5439034..a45d0c2 100644 --- a/elx-common/src/test/java/org/xbib/elx/common/test/TestExtension.java +++ b/elx-common/src/test/java/org/xbib/elx/common/test/TestExtension.java @@ -86,7 +86,7 @@ public class TestExtension implements ParameterResolver, BeforeEachCallback, Aft logger.info("starting cluster with helper " + helper + " at " + helper.getHome()); helper.startNode("1"); NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true); - NodesInfoResponse response = helper.client("1"). execute(NodesInfoAction.INSTANCE, nodesInfoRequest).actionGet(); + NodesInfoResponse response = helper.client("1").execute(NodesInfoAction.INSTANCE, nodesInfoRequest).actionGet(); TransportAddress address = response.getNodes().get(0).getTransport().getAddress().publishAddress(); String host = address.address().getHostName(); int port = address.address().getPort(); @@ -158,7 +158,7 @@ public class TestExtension implements ParameterResolver, BeforeEachCallback, Aft return helper; } - class Helper { + static class Helper { String home; diff --git a/elx-http/build.gradle b/elx-http/build.gradle index 39534d0..108a88c 100644 --- a/elx-http/build.gradle +++ b/elx-http/build.gradle @@ -1,6 +1,15 @@ +import org.apache.tools.ant.taskdefs.condition.Os + dependencies{ compile project(':elx-common') compile "org.xbib.elasticsearch:transport-netty4:${rootProject.property('elasticsearch-server.version')}" compile "org.xbib:netty-http-client:${project.property('xbib-netty-http.version')}" + runtime "org.bouncycastle:bcpkix-jdk15on:${project.property('bouncycastle.version')}" + if (Os.isFamily(Os.FAMILY_MAC)) { + runtime "io.netty:netty-tcnative-boringssl-static:${project.property('tcnative-legacy-macosx.version')}" + } else if (Os.isFamily(Os.FAMILY_UNIX)) { + runtime "io.netty:netty-tcnative-boringssl-static:${project.property('tcnative.version')}" + runtime "org.xbib:netty-http-epoll:${project.property('xbib-netty-http.version')}" + } testCompile "org.xbib.elasticsearch:elasticsearch-analysis-common:${rootProject.property('elasticsearch-server.version')}" } diff --git a/elx-http/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/HttpGetMappingsAction.java b/elx-http/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/HttpGetMappingsAction.java index 0a7afb1..d8f3ddd 100644 --- a/elx-http/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/HttpGetMappingsAction.java +++ b/elx-http/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/HttpGetMappingsAction.java @@ -6,7 +6,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; import java.util.Map; @@ -23,7 +23,7 @@ public class HttpGetMappingsAction extends HttpAction { if (logger.isDebugEnabled()) { - logger.log(Level.DEBUG, "got response: " + fullHttpResponse.status().code() + - " headers = " + fullHttpResponse.headers().entries() + - " content = " + fullHttpResponse.content().toString(StandardCharsets.UTF_8)); + logger.log(Level.DEBUG, "got response: " + fullHttpResponse.getStatus().getCode() + + " headers = " + fullHttpResponse.getHeaders() + + " content = " + fullHttpResponse.getBody().toString(StandardCharsets.UTF_8)); } httpActionContext.setHttpResponse(fullHttpResponse); - if (fullHttpResponse.status().equals(HttpResponseStatus.OK)) { + if (fullHttpResponse.getStatus().getCode() == HttpResponseStatus.OK.code()) { listener.onResponse(parseToResponse(httpActionContext)); } else { ElasticsearchStatusException statusException = parseToError(httpActionContext); @@ -88,68 +88,68 @@ public abstract class HttpAction httpActionContext) { - String mediaType = httpActionContext.getHttpResponse().headers().get(HttpHeaderNames.CONTENT_TYPE); + String mediaType = httpActionContext.getHttpResponse().getHeaders().getHeader(HttpHeaderNames.CONTENT_TYPE); XContentType xContentType = XContentType.fromMediaTypeOrFormat(mediaType); if (xContentType == null) { throw new IllegalStateException("unsupported content-type: " + mediaType); @@ -157,7 +157,7 @@ public abstract class HttpAction entityParser(); diff --git a/elx-http/src/main/java/org/xbib/elx/http/HttpActionContext.java b/elx-http/src/main/java/org/xbib/elx/http/HttpActionContext.java index 0a0abeb..93e6fa9 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/HttpActionContext.java +++ b/elx-http/src/main/java/org/xbib/elx/http/HttpActionContext.java @@ -1,9 +1,9 @@ package org.xbib.elx.http; -import io.netty.handler.codec.http.FullHttpResponse; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; -import org.xbib.netty.http.client.transport.Transport; +import org.xbib.netty.http.client.api.Transport; +import org.xbib.netty.http.common.HttpResponse; /** * HTTP action context. @@ -21,7 +21,7 @@ public class HttpActionContext setHttpResponse(FullHttpResponse fullHttpResponse) { - this.httpResponse = fullHttpResponse; + public HttpActionContext setHttpResponse(HttpResponse httpResponse) { + this.httpResponse = httpResponse; return this; } - public FullHttpResponse getHttpResponse() { + public HttpResponse getHttpResponse() { return httpResponse; } } diff --git a/elx-http/src/main/java/org/xbib/elx/http/HttpActionFuture.java b/elx-http/src/main/java/org/xbib/elx/http/HttpActionFuture.java index facc32b..3794b9c 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/HttpActionFuture.java +++ b/elx-http/src/main/java/org/xbib/elx/http/HttpActionFuture.java @@ -7,7 +7,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.BaseFuture; import org.elasticsearch.common.util.concurrent.UncategorizedExecutionException; -import org.xbib.netty.http.client.transport.Transport; +import org.xbib.netty.http.client.api.Transport; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/health/HttpClusterHealthAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/health/HttpClusterHealthAction.java index a79ac00..09925b7 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/health/HttpClusterHealthAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/health/HttpClusterHealthAction.java @@ -6,7 +6,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -18,7 +18,7 @@ public class HttpClusterHealthAction extends HttpAction httpContext) { Map map = null; - String string = (String)map.get("cluster_name"); - ClusterName clusterName = new ClusterName(string); + //String string = (String)map.get("cluster_name"); + ClusterName clusterName = new ClusterName(""); List nodeInfoList = new LinkedList<>(); - map = (Map)map.get("nodes"); + //map = (Map)map.get("nodes"); + for (Map.Entry entry : map.entrySet()) { String nodeId = entry.getKey(); String ephemeralId = null; diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/settings/HttpClusterUpdateSettingsAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/settings/HttpClusterUpdateSettingsAction.java index 972c34a..9090fe3 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/settings/HttpClusterUpdateSettingsAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/admin/cluster/settings/HttpClusterUpdateSettingsAction.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; import java.io.UncheckedIOException; @@ -24,7 +24,7 @@ public class HttpClusterUpdateSettingsAction extends HttpAction list = new ArrayList<>(); if (request.metaData()) { list.add("metadata"); diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/alias/HttpIndicesAliasesAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/alias/HttpIndicesAliasesAction.java index c3ea236..2816e7a 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/alias/HttpIndicesAliasesAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/alias/HttpIndicesAliasesAction.java @@ -11,7 +11,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -23,7 +23,7 @@ public class HttpIndicesAliasesAction extends HttpAction { @Override - protected RequestBuilder createHttpRequest(String url, GetAliasesRequest request) { + protected Request.Builder createHttpRequest(String url, GetAliasesRequest request) { // beware of this inconsistency, request.indices() always return empty array String index = request.indices() != null ? String.join(",", request.indices()) + "/" : ""; String aliases = request.aliases() != null ? String.join(",", request.aliases()) + "/" : ""; diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/create/HttpCreateIndexAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/create/HttpCreateIndexAction.java index b135b92..2c867db 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/create/HttpCreateIndexAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/admin/indices/create/HttpCreateIndexAction.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -22,7 +22,7 @@ public class HttpCreateIndexAction extends HttpAction { } @Override - protected RequestBuilder createHttpRequest(String url, BulkRequest request) throws IOException { + protected Request.Builder createHttpRequest(String url, BulkRequest request) throws IOException { StringBuilder bulkContent = new StringBuilder(); for (DocWriteRequest actionRequest : request.requests()) { if (actionRequest instanceof IndexRequest) { diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpExistsAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpExistsAction.java index d7c3969..5a6e39f 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpExistsAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpExistsAction.java @@ -7,7 +7,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -19,7 +19,7 @@ public class HttpExistsAction extends HttpAction { } @Override - protected RequestBuilder createHttpRequest(String url, GetRequest request) { + protected Request.Builder createHttpRequest(String url, GetRequest request) { return newHeadRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id()); } diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpGetAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpGetAction.java index 419d0ba..d273548 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpGetAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/get/HttpGetAction.java @@ -7,7 +7,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -19,7 +19,7 @@ public class HttpGetAction extends HttpAction { } @Override - protected RequestBuilder createHttpRequest(String url, GetRequest request) { + protected Request.Builder createHttpRequest(String url, GetRequest request) { return newGetRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id()); } diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/index/HttpIndexAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/index/HttpIndexAction.java index 93de3dd..a010872 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/index/HttpIndexAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/index/HttpIndexAction.java @@ -7,7 +7,7 @@ import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -19,7 +19,7 @@ public class HttpIndexAction extends HttpAction { } @Override - protected RequestBuilder createHttpRequest(String url, IndexRequest request) { + protected Request.Builder createHttpRequest(String url, IndexRequest request) { return newPutRequest(url, "/" + request.index() + "/" + request.type() + "/" + request.id(), request.source()); } diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/main/HttpMainAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/main/HttpMainAction.java index 7b17831..7bc9658 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/main/HttpMainAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/main/HttpMainAction.java @@ -7,7 +7,7 @@ import org.elasticsearch.action.main.MainResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -19,7 +19,7 @@ public class HttpMainAction extends HttpAction { } @Override - protected RequestBuilder createHttpRequest(String url, MainRequest request) { + protected Request.Builder createHttpRequest(String url, MainRequest request) { return newGetRequest(url, "/"); } diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/search/HttpSearchAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/search/HttpSearchAction.java index 8fe9523..a2e84fe 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/search/HttpSearchAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/search/HttpSearchAction.java @@ -6,7 +6,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.XContentParser; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -18,7 +18,7 @@ public class HttpSearchAction extends HttpAction } @Override - protected RequestBuilder createHttpRequest(String url, SearchRequest request) { + protected Request.Builder createHttpRequest(String url, SearchRequest request) { // request.indices() always empty array String index = request.indices() != null ? String.join(",", request.indices()) + "/" : ""; return newPostRequest(url, index + "_search", request.source().toString()); diff --git a/elx-http/src/main/java/org/xbib/elx/http/action/update/HttpUpdateAction.java b/elx-http/src/main/java/org/xbib/elx/http/action/update/HttpUpdateAction.java index 8138bee..606ff53 100644 --- a/elx-http/src/main/java/org/xbib/elx/http/action/update/HttpUpdateAction.java +++ b/elx-http/src/main/java/org/xbib/elx/http/action/update/HttpUpdateAction.java @@ -11,7 +11,7 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.xbib.elx.http.HttpAction; -import org.xbib.netty.http.client.RequestBuilder; +import org.xbib.netty.http.client.api.Request; import java.io.IOException; @@ -23,7 +23,7 @@ public class HttpUpdateAction extends HttpAction } @Override - protected RequestBuilder createHttpRequest(String url, UpdateRequest updateRequest) { + protected Request.Builder createHttpRequest(String url, UpdateRequest updateRequest) { try { // The Java API allows update requests with different content types // set for the partial document and the upsert document. This client diff --git a/elx-http/src/test/resources/log4j2.xml b/elx-http/src/test/resources/log4j2.xml index 6c323f8..1258d7f 100644 --- a/elx-http/src/test/resources/log4j2.xml +++ b/elx-http/src/test/resources/log4j2.xml @@ -6,7 +6,7 @@ - + diff --git a/elx-node/src/main/java/org/xbib/elx/node/package-info.java b/elx-node/src/main/java/org/xbib/elx/node/package-info.java index 1216a48..c2a9dfb 100644 --- a/elx-node/src/main/java/org/xbib/elx/node/package-info.java +++ b/elx-node/src/main/java/org/xbib/elx/node/package-info.java @@ -1,4 +1,4 @@ /** - * + * Node client extensions. */ package org.xbib.elx.node; 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 0cc3b10..ec7ef9b 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 @@ -141,7 +141,7 @@ class ClientTest { void testThreadedRandomDocs() throws Exception { int maxthreads = Runtime.getRuntime().availableProcessors(); Long maxActionsPerRequest = MAX_ACTIONS_PER_REQUEST; - final Long actions = ACTIONS; + final long actions = ACTIONS; logger.info("maxthreads={} maxactions={} maxloop={}", maxthreads, maxActionsPerRequest, actions); final ExtendedNodeClient client = ClientBuilder.builder(helper.client("1")) .provider(ExtendedNodeClientProvider.class) @@ -169,13 +169,13 @@ class ClientTest { }); } logger.info("waiting for latch..."); - if (latch.await(60L, TimeUnit.SECONDS)) { + if (latch.await(30L, TimeUnit.SECONDS)) { logger.info("flush..."); client.flush(); - client.waitForResponses(60L, TimeUnit.SECONDS); + client.waitForResponses(30L, TimeUnit.SECONDS); logger.info("got all responses, executor service shutdown..."); executorService.shutdown(); - executorService.awaitTermination(60L, TimeUnit.SECONDS); + executorService.awaitTermination(30L, TimeUnit.SECONDS); logger.info("pool is shut down"); } else { logger.warn("latch timeout"); diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/IndexPruneTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/IndexPruneTest.java index b729716..43e87ea 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/IndexPruneTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/IndexPruneTest.java @@ -45,22 +45,22 @@ class IndexPruneTest { .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .build(); - client.newIndex("test1", settings); - client.shiftIndex("test", "test1", Collections.emptyList()); - client.newIndex("test2", settings); - client.shiftIndex("test", "test2", Collections.emptyList()); - client.newIndex("test3", settings); - client.shiftIndex("test", "test3", Collections.emptyList()); - client.newIndex("test4", settings); - client.shiftIndex("test", "test4", Collections.emptyList()); + client.newIndex("test_prune1", settings); + client.shiftIndex("test_prune", "test_prune1", Collections.emptyList()); + client.newIndex("test_prune2", settings); + client.shiftIndex("test_prune", "test_prune2", Collections.emptyList()); + client.newIndex("test_prune3", settings); + client.shiftIndex("test_prune", "test_prune3", Collections.emptyList()); + client.newIndex("test_prune4", settings); + client.shiftIndex("test_prune", "test_prune4", Collections.emptyList()); IndexPruneResult indexPruneResult = - client.pruneIndex("test", "test4", 2, 2, true); - assertTrue(indexPruneResult.getDeletedIndices().contains("test1")); - assertTrue(indexPruneResult.getDeletedIndices().contains("test2")); - assertFalse(indexPruneResult.getDeletedIndices().contains("test3")); - assertFalse(indexPruneResult.getDeletedIndices().contains("test4")); + client.pruneIndex("test_prune", "test_prune4", 2, 2, true); + assertTrue(indexPruneResult.getDeletedIndices().contains("test_prune1")); + assertTrue(indexPruneResult.getDeletedIndices().contains("test_prune2")); + assertFalse(indexPruneResult.getDeletedIndices().contains("test_prune3")); + assertFalse(indexPruneResult.getDeletedIndices().contains("test_prune4")); List list = new ArrayList<>(); - for (String index : Arrays.asList("test1", "test2", "test3", "test4")) { + for (String index : Arrays.asList("test_prune1", "test_prune2", "test_prune3", "test_prune4")) { IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(); indicesExistsRequest.indices(index); IndicesExistsResponse indicesExistsResponse = diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/IndexShiftTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/IndexShiftTest.java index 3ca8c69..fb7aaaf 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/IndexShiftTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/IndexShiftTest.java @@ -41,21 +41,21 @@ class IndexShiftTest { .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .build(); - client.newIndex("test1234", settings); + client.newIndex("test_shift", settings); for (int i = 0; i < 1; i++) { - client.index("test1234", helper.randomString(1), false, + client.index("test_shift", helper.randomString(1), false, "{ \"name\" : \"" + helper.randomString(32) + "\"}"); } client.flush(); client.waitForResponses(30L, TimeUnit.SECONDS); IndexShiftResult indexShiftResult = - client.shiftIndex("test", "test1234", Arrays.asList("a", "b", "c")); + client.shiftIndex("test", "test_shift", Arrays.asList("a", "b", "c")); assertTrue(indexShiftResult.getNewAliases().contains("a")); assertTrue(indexShiftResult.getNewAliases().contains("b")); assertTrue(indexShiftResult.getNewAliases().contains("c")); assertTrue(indexShiftResult.getMovedAliases().isEmpty()); - Map aliases = client.getAliases("test1234"); + Map aliases = client.getAliases("test_shift"); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); assertTrue(aliases.containsKey("c")); @@ -68,15 +68,15 @@ class IndexShiftTest { assertTrue(aliases.containsKey("c")); assertTrue(aliases.containsKey("test")); - client.newIndex("test5678", settings); + client.newIndex("test_shift2", settings); for (int i = 0; i < 1; i++) { - client.index("test5678", helper.randomString(1), false, + client.index("test_shift2", helper.randomString(1), false, "{ \"name\" : \"" + helper.randomString(32) + "\"}"); } client.flush(); client.waitForResponses(30L, TimeUnit.SECONDS); - indexShiftResult = client.shiftIndex("test", "test5678", Arrays.asList("d", "e", "f"), + indexShiftResult = client.shiftIndex("test", "test_shift2", Arrays.asList("d", "e", "f"), (request, index, alias) -> request.addAliasAction(IndicesAliasesRequest.AliasActions.add() .index(index).alias(alias).filter(QueryBuilders.termQuery("my_key", alias))) ); @@ -87,7 +87,7 @@ class IndexShiftTest { assertTrue(indexShiftResult.getMovedAliases().contains("b")); assertTrue(indexShiftResult.getMovedAliases().contains("c")); - aliases = client.getAliases("test5678"); + aliases = client.getAliases("test_shift2"); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); assertTrue(aliases.containsKey("c")); 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 3435df9..a3e444d 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 @@ -34,20 +34,20 @@ class SmokeTest { .build(); try { assertEquals(helper.getClusterName(), client.getClusterName()); - client.newIndex("test"); - client.index("test", "1", true, "{ \"name\" : \"Hello World\"}"); // single doc ingest + client.newIndex("test_smoke"); + client.index("test_smoke", "1", true, "{ \"name\" : \"Hello World\"}"); // single doc ingest client.flush(); client.waitForResponses(30, TimeUnit.SECONDS); - client.checkMapping("test"); - client.update("test", "1", "{ \"name\" : \"Another name\"}"); - client.delete("test", "1"); + client.checkMapping("test_smoke"); + client.update("test_smoke", "1", "{ \"name\" : \"Another name\"}"); + client.delete("test_smoke", "1"); client.flush(); client.waitForResponses(30, TimeUnit.SECONDS); - client.waitForRecovery("test", 10L, TimeUnit.SECONDS); - client.delete("test", "1"); + client.waitForRecovery("test_smoke", 10L, TimeUnit.SECONDS); + client.delete("test_smoke", "1"); client.flush(); - client.deleteIndex("test"); - IndexDefinition indexDefinition = client.buildIndexDefinitionFromSettings("test", Settings.builder() + client.deleteIndex("test_smoke"); + IndexDefinition indexDefinition = client.buildIndexDefinitionFromSettings("test_smoke", Settings.builder() .build()); assertEquals(0, indexDefinition.getReplicaLevel()); client.newIndex(indexDefinition); diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/TestExtension.java b/elx-node/src/test/java/org/xbib/elx/node/test/TestExtension.java index 06d8893..e3a8cf8 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/TestExtension.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/TestExtension.java @@ -157,7 +157,7 @@ public class TestExtension implements ParameterResolver, BeforeEachCallback, Aft return helper; } - class Helper { + static class Helper { String home; 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 b772420..b5b3a51 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 @@ -1,5 +1,6 @@ package org.xbib.elx.transport; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; @@ -48,11 +49,11 @@ public class ExtendedTransportClient extends AbstractExtendedClient { + " " + System.getProperty("java.vm.version") + " Elasticsearch " + Version.CURRENT.toString(); Settings transportClientSettings = getTransportClientSettings(settings); - XContentBuilder settingsBuilder = XContentFactory.jsonBuilder().startObject(); + //XContentBuilder settingsBuilder = XContentFactory.jsonBuilder().startObject(); XContentBuilder effectiveSettingsBuilder = XContentFactory.jsonBuilder().startObject(); - logger.info("creating transport client on {} with custom settings {} and effective settings {}", + logger.log(Level.INFO, "creating transport client on {} with settings {}", systemIdentifier, - Strings.toString(settings.toXContent(settingsBuilder, ToXContent.EMPTY_PARAMS).endObject()), + //Strings.toString(settings.toXContent(settingsBuilder, ToXContent.EMPTY_PARAMS).endObject()), Strings.toString(transportClientSettings.toXContent(effectiveSettingsBuilder, ToXContent.EMPTY_PARAMS).endObject())); return new MyTransportClient(transportClientSettings, Collections.singletonList(Netty4Plugin.class)); @@ -138,11 +139,14 @@ public class ExtendedTransportClient extends AbstractExtendedClient { private Settings getTransportClientSettings(Settings settings) { return Settings.builder() + // "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(), String.valueOf(Runtime.getRuntime().availableProcessors()))) + // "transport.type" .put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME) .build(); @@ -154,7 +158,7 @@ public class ExtendedTransportClient extends AbstractExtendedClient { } } - class MyTransportClient extends TransportClient { + static class MyTransportClient extends TransportClient { MyTransportClient(Settings settings, Collection> plugins) { super(settings, 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 0300f96..76e6bf5 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 @@ -1,5 +1,6 @@ package org.xbib.elx.transport.test; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction; @@ -37,9 +38,9 @@ class ClientTest { private static final Logger logger = LogManager.getLogger(ClientTest.class.getName()); - private static final Long ACTIONS = 1000L; + private static final Long ACTIONS = 10000L; - private static final Long MAX_ACTIONS_PER_REQUEST = 100L; + private static final Long MAX_ACTIONS_PER_REQUEST = 10000L; private final TestExtension.Helper helper; @@ -51,9 +52,9 @@ class ClientTest { void testSingleDoc() throws Exception { final ExtendedTransportClient client = ClientBuilder.builder() .provider(ExtendedTransportClientProvider.class) + .put(helper.getTransportSettings()) .put(Parameters.MAX_ACTIONS_PER_REQUEST.name(), MAX_ACTIONS_PER_REQUEST) .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(30)) - .put(helper.getTransportSettings()) .build(); try { client.newIndex("test"); @@ -76,8 +77,8 @@ class ClientTest { void testNewIndex() throws Exception { final ExtendedTransportClient client = ClientBuilder.builder() .provider(ExtendedTransportClientProvider.class) - .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(5)) .put(helper.getTransportSettings()) + .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(5)) .build(); client.newIndex("test"); client.close(); @@ -87,8 +88,8 @@ class ClientTest { void testMapping() throws Exception { final ExtendedTransportClient client = ClientBuilder.builder() .provider(ExtendedTransportClientProvider.class) - .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(5)) .put(helper.getTransportSettings()) + .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(5)) .build(); XContentBuilder builder = JsonXContent.contentBuilder() .startObject() @@ -114,9 +115,9 @@ class ClientTest { long numactions = ACTIONS; final ExtendedTransportClient client = ClientBuilder.builder() .provider(ExtendedTransportClientProvider.class) + .put(helper.getTransportSettings()) .put(Parameters.MAX_ACTIONS_PER_REQUEST.name(), MAX_ACTIONS_PER_REQUEST) .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(60)) - .put(helper.getTransportSettings()) .build(); try { client.newIndex("test"); @@ -144,6 +145,7 @@ class ClientTest { searchRequest.indices("test"); searchRequest.source(builder); SearchResponse searchResponse = client.getClient().execute(SearchAction.INSTANCE, searchRequest).actionGet(); + logger.log(Level.INFO, searchResponse.toString()); assertEquals(numactions, searchResponse.getHits().getTotalHits()); client.close(); } @@ -153,14 +155,15 @@ class ClientTest { void testThreadedRandomDocs() throws Exception { int maxthreads = Runtime.getRuntime().availableProcessors(); Long maxActionsPerRequest = MAX_ACTIONS_PER_REQUEST; - final Long actions = ACTIONS; + final long actions = ACTIONS; logger.info("maxthreads={} maxactions={} maxloop={}", maxthreads, maxActionsPerRequest, actions); final ExtendedTransportClient client = ClientBuilder.builder() .provider(ExtendedTransportClientProvider.class) + .put(helper.getTransportSettings()) .put(Parameters.MAX_CONCURRENT_REQUESTS.name(), maxthreads * 2) .put(Parameters.MAX_ACTIONS_PER_REQUEST.name(), maxActionsPerRequest) .put(Parameters.FLUSH_INTERVAL.name(), TimeValue.timeValueSeconds(60)) - .put(helper.getTransportSettings()) + .put(Parameters.ENABLE_BULK_LOGGING.name(), "true") .build(); try { Settings settings = Settings.builder() @@ -182,13 +185,13 @@ class ClientTest { }); } logger.info("waiting for latch..."); - if (latch.await(60L, TimeUnit.SECONDS)) { + if (latch.await(30L, TimeUnit.SECONDS)) { logger.info("flush..."); client.flush(); - client.waitForResponses(60L, TimeUnit.SECONDS); + client.waitForResponses(30L, TimeUnit.SECONDS); logger.info("got all responses, executor service shutdown..."); executorService.shutdown(); - executorService.awaitTermination(60L, TimeUnit.SECONDS); + executorService.awaitTermination(30L, TimeUnit.SECONDS); logger.info("pool is shut down"); } else { logger.warn("latch timeout"); @@ -212,6 +215,7 @@ class ClientTest { searchRequest.indices("test"); searchRequest.source(builder); SearchResponse searchResponse = client.getClient().execute(SearchAction.INSTANCE, searchRequest).actionGet(); + logger.log(Level.INFO, searchResponse.toString()); assertEquals(maxthreads * actions, searchResponse.getHits().getTotalHits()); client.close(); } 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 fe98d3c..c1afc40 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 @@ -45,20 +45,20 @@ class DuplicateIDTest { .put(helper.getTransportSettings()) .build(); try { - client.newIndex("test"); + client.newIndex("test_dup"); for (int i = 0; i < ACTIONS; i++) { - client.index("test", helper.randomString(1), false, + client.index("test_dup", helper.randomString(1), false, "{ \"name\" : \"" + helper.randomString(32) + "\"}"); } client.flush(); client.waitForResponses(30L, TimeUnit.SECONDS); - client.refreshIndex("test"); + client.refreshIndex("test_dup"); SearchSourceBuilder builder = new SearchSourceBuilder(); builder.query(QueryBuilders.matchAllQuery()); builder.size(0); SearchRequest searchRequest = new SearchRequest(); - searchRequest.indices("test"); - searchRequest.types("test"); + searchRequest.indices("test_dup"); + searchRequest.types("test_dup"); searchRequest.source(builder); SearchResponse searchResponse = helper.client("1").execute(SearchAction.INSTANCE, searchRequest).actionGet(); diff --git a/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexPruneTest.java b/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexPruneTest.java index c2b46bc..8d82ba3 100644 --- a/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexPruneTest.java +++ b/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexPruneTest.java @@ -46,22 +46,22 @@ class IndexPruneTest { .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .build(); - client.newIndex("test1", settings); - client.shiftIndex("test", "test1", Collections.emptyList()); - client.newIndex("test2", settings); - client.shiftIndex("test", "test2", Collections.emptyList()); - client.newIndex("test3", settings); - client.shiftIndex("test", "test3", Collections.emptyList()); - client.newIndex("test4", settings); - client.shiftIndex("test", "test4", Collections.emptyList()); + client.newIndex("test_prune1", settings); + client.shiftIndex("test_prune", "test_prune1", Collections.emptyList()); + client.newIndex("test_prune2", settings); + client.shiftIndex("test_prune", "test_prune2", Collections.emptyList()); + client.newIndex("test_prune3", settings); + client.shiftIndex("test_prune", "test_prune3", Collections.emptyList()); + client.newIndex("test_prune4", settings); + client.shiftIndex("test_prune", "test_prune4", Collections.emptyList()); IndexPruneResult indexPruneResult = - client.pruneIndex("test", "test4", 2, 2, true); - assertTrue(indexPruneResult.getDeletedIndices().contains("test1")); - assertTrue(indexPruneResult.getDeletedIndices().contains("test2")); - assertFalse(indexPruneResult.getDeletedIndices().contains("test3")); - assertFalse(indexPruneResult.getDeletedIndices().contains("test4")); + client.pruneIndex("test_prune", "test_prune4", 2, 2, true); + assertTrue(indexPruneResult.getDeletedIndices().contains("test_prune1")); + assertTrue(indexPruneResult.getDeletedIndices().contains("test_prune2")); + assertFalse(indexPruneResult.getDeletedIndices().contains("test_prune3")); + assertFalse(indexPruneResult.getDeletedIndices().contains("test_prune4")); List list = new ArrayList<>(); - for (String index : Arrays.asList("test1", "test2", "test3", "test4")) { + for (String index : Arrays.asList("test_prune1", "test_prune2", "test_prune3", "test_prune4")) { IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(); indicesExistsRequest.indices(index); IndicesExistsResponse indicesExistsResponse = diff --git a/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexShiftTest.java b/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexShiftTest.java index a26f4d9..f182956 100644 --- a/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexShiftTest.java +++ b/elx-transport/src/test/java/org/xbib/elx/transport/test/IndexShiftTest.java @@ -42,38 +42,38 @@ class IndexShiftTest { .put("index.number_of_shards", 1) .put("index.number_of_replicas", 0) .build(); - client.newIndex("test1234", settings); + client.newIndex("test_shift1234", settings); for (int i = 0; i < 1; i++) { - client.index("test1234", helper.randomString(1), false, + client.index("test_shift1234", helper.randomString(1), false, "{ \"name\" : \"" + helper.randomString(32) + "\"}"); } client.flush(); client.waitForResponses(30L, TimeUnit.SECONDS); IndexShiftResult indexShiftResult = - client.shiftIndex("test", "test1234", Arrays.asList("a", "b", "c")); + client.shiftIndex("test_shift", "test_shift1234", Arrays.asList("a", "b", "c")); assertTrue(indexShiftResult.getNewAliases().contains("a")); assertTrue(indexShiftResult.getNewAliases().contains("b")); assertTrue(indexShiftResult.getNewAliases().contains("c")); assertTrue(indexShiftResult.getMovedAliases().isEmpty()); - Map aliases = client.getAliases("test1234"); + Map aliases = client.getAliases("test_shift1234"); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); assertTrue(aliases.containsKey("c")); - assertTrue(aliases.containsKey("test")); - String resolved = client.resolveAlias("test"); + assertTrue(aliases.containsKey("test_shift")); + String resolved = client.resolveAlias("test_shift"); aliases = client.getAliases(resolved); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); assertTrue(aliases.containsKey("c")); - assertTrue(aliases.containsKey("test")); - client.newIndex("test5678", settings); + assertTrue(aliases.containsKey("test_shift")); + client.newIndex("test_shift5678", settings); for (int i = 0; i < 1; i++) { - client.index("test5678", helper.randomString(1), false, + client.index("test_shift5678", helper.randomString(1), false, "{ \"name\" : \"" + helper.randomString(32) + "\"}"); } client.flush(); client.waitForResponses(30L, TimeUnit.SECONDS); - indexShiftResult = client.shiftIndex("test", "test5678", Arrays.asList("d", "e", "f"), + indexShiftResult = client.shiftIndex("test_shift", "test_shift5678", Arrays.asList("d", "e", "f"), (request, index, alias) -> request.addAliasAction(IndicesAliasesRequest.AliasActions.add() .index(index).alias(alias).filter(QueryBuilders.termQuery("my_key", alias))) ); @@ -83,14 +83,14 @@ class IndexShiftTest { assertTrue(indexShiftResult.getMovedAliases().contains("a")); assertTrue(indexShiftResult.getMovedAliases().contains("b")); assertTrue(indexShiftResult.getMovedAliases().contains("c")); - aliases = client.getAliases("test5678"); + aliases = client.getAliases("test_shift5678"); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); assertTrue(aliases.containsKey("c")); assertTrue(aliases.containsKey("d")); assertTrue(aliases.containsKey("e")); assertTrue(aliases.containsKey("f")); - resolved = client.resolveAlias("test"); + resolved = client.resolveAlias("test_shift"); aliases = client.getAliases(resolved); assertTrue(aliases.containsKey("a")); assertTrue(aliases.containsKey("b")); 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 0435439..992cff6 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 @@ -35,15 +35,15 @@ class SmokeTest { .build(); try { assertEquals(helper.getClusterName(), client.getClusterName()); - client.newIndex("test"); - client.index("test", "1", true, "{ \"name\" : \"Hello World\"}"); // single doc ingest - client.update("test", "1", "{ \"name\" : \"Another name\"}"); - client.delete("test", "1"); + client.newIndex("test_smoke"); + client.index("test_smoke", "1", true, "{ \"name\" : \"Hello World\"}"); // single doc ingest + client.update("test_smoke", "1", "{ \"name\" : \"Another name\"}"); + client.delete("test_smoke", "1"); client.flush(); client.waitForResponses(30, TimeUnit.SECONDS); - client.checkMapping("test"); - client.deleteIndex("test"); - IndexDefinition indexDefinition = client.buildIndexDefinitionFromSettings("test", Settings.builder() + client.checkMapping("test_smoke"); + client.deleteIndex("test_smoke"); + IndexDefinition indexDefinition = client.buildIndexDefinitionFromSettings("test_smoke", Settings.builder() .build()); assertEquals(0, indexDefinition.getReplicaLevel()); client.newIndex(indexDefinition); diff --git a/elx-transport/src/test/resources/log4j2.xml b/elx-transport/src/test/resources/log4j2.xml index 6c323f8..1258d7f 100644 --- a/elx-transport/src/test/resources/log4j2.xml +++ b/elx-transport/src/test/resources/log4j2.xml @@ -6,7 +6,7 @@ - + diff --git a/gradle.properties b/gradle.properties index 6b7b5a6..5db0fcb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,16 @@ group = org.xbib name = elx -version = 6.3.2.3 +version = 6.3.2.4 profile = default release = 0 -elasticsearch-server.version = 6.3.2.3 -log4j.version = 2.11.1 -xbib-metrics.version = 1.2.0 -xbib-netty-http.version = 4.1.35.0 +elasticsearch-server.version = 6.3.2.4 +log4j.version = 2.12.1 +xbib-metrics.version = 2.0.0 +xbib-netty-http.version = 4.1.48.0 +tcnative.version = 2.0.29.Final +tcnative-legacy-macosx.version = 2.0.26.Final +bouncycastle.version = 1.64 # test junit.version = 5.4.2