summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2021-11-22 12:41:47 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-11-22 12:41:47 +0000
commit7d823977c6e3f634e42d3672834ba61eca37ea31 (patch)
tree50e98ab52de3842677f1f4faa0c5e5279e3df8ee
parent7b00238e264a79531db36b8b801ed33f1794945a (diff)
parent0b6d3d8c5ff4439397b702a1525b80c08ac77af3 (diff)
Merge "Remove support for ElasticSearch indexes" into stable-3.5
-rwxr-xr-xDocumentation/backend_licenses.txt18
-rw-r--r--Documentation/backup.txt4
-rw-r--r--Documentation/config-accounts.txt2
-rw-r--r--Documentation/config-gerrit.txt103
-rw-r--r--Documentation/dev-bazel.txt20
-rw-r--r--Documentation/licenses.txt19
-rw-r--r--WORKSPACE22
-rw-r--r--java/com/google/gerrit/acceptance/GerritServer.java1
-rw-r--r--java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java408
-rw-r--r--java/com/google/gerrit/elasticsearch/BUILD33
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java143
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java181
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticConfiguration.java137
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticException.java27
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java126
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticIndexModule.java69
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticIndexVersionDiscovery.java61
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticIndexVersionManager.java82
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticMapping.java123
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java130
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java63
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticQueryBuilder.java163
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java157
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticSetting.java97
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticStoredValue.java86
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticVersion.java66
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/BoolQueryBuilder.java89
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/ExistsQueryBuilder.java38
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/MatchAllQueryBuilder.java31
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/MatchQueryBuilder.java62
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/QueryBuilder.java31
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/QueryBuilders.java103
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/QuerySourceBuilder.java32
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/RangeQueryBuilder.java89
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/RegexpQueryBuilder.java51
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/SearchSourceBuilder.java112
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/TermQueryBuilder.java67
-rw-r--r--java/com/google/gerrit/elasticsearch/builders/XContentBuilder.java168
-rw-r--r--java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java41
-rw-r--r--java/com/google/gerrit/elasticsearch/bulk/BulkRequest.java43
-rw-r--r--java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java22
-rw-r--r--java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java22
-rw-r--r--java/com/google/gerrit/elasticsearch/bulk/UpdateRequest.java63
-rw-r--r--java/com/google/gerrit/httpd/init/BUILD1
-rw-r--r--java/com/google/gerrit/httpd/init/WebAppInitializer.java3
-rw-r--r--java/com/google/gerrit/index/IndexType.java10
-rw-r--r--java/com/google/gerrit/lucene/LuceneIndexModule.java2
-rw-r--r--java/com/google/gerrit/pgm/BUILD1
-rw-r--r--java/com/google/gerrit/pgm/Daemon.java4
-rw-r--r--java/com/google/gerrit/pgm/Reindex.java4
-rw-r--r--java/com/google/gerrit/pgm/init/BUILD1
-rw-r--r--java/com/google/gerrit/pgm/init/BaseInit.java3
-rw-r--r--java/com/google/gerrit/pgm/init/InitIndex.java9
-rw-r--r--java/com/google/gerrit/pgm/init/index/IndexModuleOnInit.java7
-rw-r--r--java/com/google/gerrit/pgm/init/index/elasticsearch/ElasticIndexModuleOnInit.java41
-rw-r--r--java/com/google/gerrit/server/index/AbstractIndexModule.java1
-rw-r--r--java/com/google/gerrit/testing/InMemoryModule.java6
-rw-r--r--java/com/google/gerrit/testing/IndexConfig.java10
-rw-r--r--java/com/google/gerrit/testing/TestLoggingActivator.java7
-rw-r--r--javatests/com/google/gerrit/acceptance/pgm/BUILD19
-rw-r--r--javatests/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java28
-rw-r--r--javatests/com/google/gerrit/acceptance/ssh/BUILD18
-rw-r--r--javatests/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java38
-rw-r--r--javatests/com/google/gerrit/elasticsearch/BUILD85
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticConfigurationTest.java129
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticContainer.java66
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticTestUtils.java54
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticV7QueryAccountsTest.java64
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticV7QueryChangesTest.java95
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticV7QueryGroupsTest.java64
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticV7QueryProjectsTest.java64
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticVersionTest.java46
-rw-r--r--lib/LICENSE-elasticsearch5
-rw-r--r--lib/elasticsearch-rest-client/BUILD9
-rw-r--r--lib/httpcomponents/BUILD17
-rw-r--r--lib/jackson/BUILD1
-rw-r--r--lib/log/BUILD1
-rwxr-xr-xlib/nongoogle_test.sh2
-rw-r--r--lib/testcontainers/BUILD9
-rw-r--r--tools/eclipse/BUILD1
-rw-r--r--tools/nongoogle.bzl14
-rw-r--r--tools/release_noter/release_noter.py1
82 files changed, 10 insertions, 4335 deletions
diff --git a/Documentation/backend_licenses.txt b/Documentation/backend_licenses.txt
index 3113682c41..5d4109ea1a 100755
--- a/Documentation/backend_licenses.txt
+++ b/Documentation/backend_licenses.txt
@@ -61,10 +61,8 @@ Apache2.0
* guice:guice-library
* guice:guice-servlet
* guice:javax_inject
-* httpcomponents:httpasyncclient
* httpcomponents:httpclient
* httpcomponents:httpcore
-* httpcomponents:httpcore-nio
* jackson:jackson-core
* jetty:http
* jetty:io
@@ -1113,22 +1111,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----
-[[elasticsearch]]
-elasticsearch
-
-* elasticsearch-rest-client:elasticsearch-rest-client
-
-[[elasticsearch_license]]
-----
-Elasticsearch
-Copyright 2009-2015 Elasticsearch
-
-This product includes software developed by The Apache Software
-Foundation (http://www.apache.org/).
-
-----
-
-
[[flexmark]]
flexmark
diff --git a/Documentation/backup.txt b/Documentation/backup.txt
index dd470355df..9139e712bc 100644
--- a/Documentation/backup.txt
+++ b/Documentation/backup.txt
@@ -45,10 +45,6 @@ The _Lucene_ search index is stored in the `${SITE}/index` folder.
It can be recomputed from primary data in the git repositories but
reindexing may take a long time hence backing up the index makes sense
for production installations.
-+
-If you have chosen to use _Elastic Search_ for indexing,
-refer to its
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html[backup documentation,role=external,window=_blank].
[#optional-backup-cache]
Caches::
diff --git a/Documentation/config-accounts.txt b/Documentation/config-accounts.txt
index 7a7cef2d86..4597704fd8 100644
--- a/Documentation/config-accounts.txt
+++ b/Documentation/config-accounts.txt
@@ -112,7 +112,7 @@ Accessing the account data in Git is not fast enough for account
queries, since it requires accessing all user branches and parsing
all files in each of them. To overcome this Gerrit has a secondary
index for accounts. The account index is either based on
-link:config-gerrit.html#index.type[Lucene or Elasticsearch].
+link:config-gerrit.html#index.type[Lucene].
Via the link:rest-api-accounts.html#query-account[Query Account] REST
endpoint link:user-search-accounts.html[generic account queries] are
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index f0ad944d76..6a5f6a82d4 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -3118,13 +3118,6 @@ values are:
A link:http://lucene.apache.org/[Lucene] index is used.
+
+
-* `ELASTICSEARCH` look into link:#elasticsearch[Elasticsearch section]
-+
-An link:https://www.elastic.co/products/elasticsearch[Elasticsearch,role=external,window=_blank] index is
-used. Refer to the link:#elasticsearch[Elasticsearch section] for further
-configuration details.
-
-+
By default, `LUCENE`.
[[index.threads]]index.threads::
@@ -3162,11 +3155,6 @@ Maximum limit to allow for search queries. Requesting results above this
limit will truncate the list (but will still set `_more_changes` on
result lists). Set to 0 for no limit.
+
-When `index.type` is set to `ELASTICSEARCH`, this value should not exceed
-the `index.max_result_window` value configured on the Elasticsearch
-server. If a value is not configured during site initialization, defaults to
-10000, which is the default value of `index.max_result_window` in Elasticsearch.
-+
When `index.type` is set to `LUCENE`, defaults to no limit.
[[index.maxPages]]index.maxPages::
@@ -3235,7 +3223,7 @@ Defaults to `true`.
+
Whether the scheduled indexer is enabled. If the scheduled indexer is
disabled you must implement other means to keep the group index for the
-replica up-to-date (e.g. by using ElasticSearch for the indexes).
+replica up-to-date.
+
Defaults to `true`.
@@ -3368,95 +3356,6 @@ Sample Lucene index configuration:
----
-[[elasticsearch]]
-=== Section elasticsearch
-
-WARNING: Support for Elasticsearch is still experimental and is not recommended
-for production use. For compatibility information, please refer to the
-link:https://www.gerritcodereview.com/elasticsearch.html[project homepage,role=external,window=_blank].
-
-Note that when Gerrit is configured to use Elasticsearch, the Elasticsearch
-server(s) must be reachable during the site initialization.
-
-[[elasticsearch.prefix]]elasticsearch.prefix::
-+
-This setting can be used to prefix index names to allow multiple Gerrit
-instances in a single Elasticsearch cluster. Prefix `gerrit1_` would result in a
-change index named `gerrit1_changes_0001`.
-+
-Not set by default.
-
-[[elasticsearch.server]]elasticsearch.server::
-+
-Elasticsearch server URI in the form `http[s]://hostname:port`. The `port` is
-optional and defaults to `9200` if not specified.
-+
-At least one server must be specified. May be specified multiple times to
-configure multiple Elasticsearch servers.
-+
-Note that the site initialization program only allows to configure a single
-server. To configure multiple servers the `gerrit.config` file must be edited
-manually.
-
-[[elasticsearch.numberOfShards]]elasticsearch.numberOfShards::
-+
-Sets the number of shards to use per index. Refer to the
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#_static_index_settings[
-Elasticsearch documentation,role=external,window=_blank] for details.
-+
-Defaults to 1.
-
-[[elasticsearch.numberOfReplicas]]elasticsearch.numberOfReplicas::
-+
-Sets the number of replicas to use per index. Refer to the
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings[
-Elasticsearch documentation,role=external,window=_blank] for details.
-+
-Defaults to 1.
-
-[[elasticsearch.maxResultWindow]]elasticsearch.maxResultWindow::
-+
-Sets the maximum value of `from + size` for searches to use per index. Refer to the
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings[
-Elasticsearch documentation,role=external,window=_blank] for details.
-+
-Defaults to 10000.
-
-[[elasticsearch.connectTimeout]]elasticsearch.connectTimeout::
-+
-Sets the timeout for connecting to elasticsearch.
-+
-Defaults to `1 second`.
-
-[[elasticsearch.socketTimeout]]elasticsearch.socketTimeout::
-+
-Sets the timeout for the underlying connection. For more information, refer to
-link:#httpd.idleTimeout[`httpd.idleTimeout`].
-+
-Defaults to `30 seconds`.
-
-==== Elasticsearch Security
-
-When security is enabled in Elasticsearch, the username and password must be provided.
-Note that the same username and password are used for all servers.
-
-For further information about Elasticsearch security, please refer to
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/security-getting-started.html[the documentation,role=external,window=_blank].
-This is the current documentation link. Select another Elasticsearch version
-from the dropdown menu available on that page if need be.
-
-[[elasticsearch.username]]elasticsearch.username::
-+
-Username used to connect to Elasticsearch.
-+
-If a password is set, defaults to `elastic`, otherwise not set by default.
-
-[[elasticsearch.password]]elasticsearch.password::
-+
-Password used to connect to Elasticsearch.
-+
-Not set by default.
-
[[event]]
=== Section event
diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt
index c3237ed22c..1f28561614 100644
--- a/Documentation/dev-bazel.txt
+++ b/Documentation/dev-bazel.txt
@@ -370,15 +370,12 @@ To run the tests against a specific index backend (LUCENE, FAKE):
bazel test --test_env=GERRIT_INDEX_TYPE=LUCENE //...
----
-Elastic search is not currently supported in integration tests.
-
The following values are currently supported for the group name:
* annotation
* api
* docker
* edit
-* elastic
* git
* git-protocol-v2
* git-upload-archive
@@ -411,23 +408,6 @@ Example:
Now attach with a debugger to the port `5005`. For example use "Remote Java Application" launch
configuration in Eclipe and specify the port `5005`.
-[[elasticsearch]]
-=== Elasticsearch
-
-Successfully running the Elasticsearch tests requires Docker, and
-may require setting the local virtual memory on
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html[linux,role=external,window=_blank] and
-link:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_set_vm_max_map_count_to_at_least_262144[macOS,role=external,window=_blank].
-
-On macOS, if using link:https://docs.docker.com/docker-for-mac/[Docker Desktop,role=external,window=_blank],
-the effective memory value can be set in the Preferences, under the Advanced tab.
-The default value usually does not suffice and is causing premature container exits.
-That default is currently 2 GB and should be set to at least 5 (GB).
-
-If Docker is not available, the Elasticsearch tests will be skipped.
-Note that Bazel currently does not show
-link:https://github.com/bazelbuild/bazel/issues/3476[the skipped tests,role=external,window=_blank].
-
[[logging]]
=== Controlling logging level
diff --git a/Documentation/licenses.txt b/Documentation/licenses.txt
index 86ff904e34..685e73b6f9 100644
--- a/Documentation/licenses.txt
+++ b/Documentation/licenses.txt
@@ -62,11 +62,8 @@ Apache2.0
* guice:guice-library
* guice:guice-servlet
* guice:javax_inject
-* httpcomponents:httpasyncclient
* httpcomponents:httpclient
* httpcomponents:httpcore
-* httpcomponents:httpcore-nio
-* jackson:jackson-core
* jetty:http
* jetty:io
* jetty:jmx
@@ -1114,22 +1111,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----
-[[elasticsearch]]
-elasticsearch
-
-* elasticsearch-rest-client:elasticsearch-rest-client
-
-[[elasticsearch_license]]
-----
-Elasticsearch
-Copyright 2009-2015 Elasticsearch
-
-This product includes software developed by The Apache Software
-Foundation (http://www.apache.org/).
-
-----
-
-
[[flexmark]]
flexmark
diff --git a/WORKSPACE b/WORKSPACE
index 7a27ed2db9..ec1b51e680 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -778,12 +778,6 @@ maven_jar(
sha1 = "fd369423346b2f1525c413e33f8cf95b09c92cbd",
)
-# Base the following org.apache.httpcomponents versions on what
-# elasticsearch-rest-client explicitly depends on, except for
-# commons-codec (non-http) which is not necessary yet. Note that
-# below httpcore version(s) differs from the HTTPCOMP_VERS range,
-# upstream: that specific dependency has no HTTPCOMP_VERS version
-# equivalent currently.
HTTPCOMP_VERS = "4.5.2"
maven_jar(
@@ -974,19 +968,3 @@ yarn_install(
)
external_plugin_deps()
-
-# When upgrading elasticsearch-rest-client, also upgrade httpcore-nio
-# and httpasyncclient as necessary in tools/nongoogle.bzl. Consider
-# also the other org.apache.httpcomponents dependencies in
-# WORKSPACE.
-maven_jar(
- name = "elasticsearch-rest-client",
- artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.8.1",
- sha1 = "59feefe006a96a39f83b0dfb6780847e06c1d0a8",
-)
-
-maven_jar(
- name = "testcontainers-elasticsearch",
- artifact = "org.testcontainers:elasticsearch:" + TESTCONTAINERS_VERSION,
- sha1 = "595e3a50f59cd3c1d281ca6c1bc4037e277a1353",
-)
diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java
index a5b5235225..f13f02e9c5 100644
--- a/java/com/google/gerrit/acceptance/GerritServer.java
+++ b/java/com/google/gerrit/acceptance/GerritServer.java
@@ -478,7 +478,6 @@ public class GerritServer implements AutoCloseable {
} else {
daemon.setIndexModule(FakeIndexModule.latestVersion(false));
}
- // Elastic search is not supported in integration tests yet.
daemon.setEnableHttpd(desc.httpd());
daemon.setInMemory(true);
diff --git a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java b/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
deleted file mode 100644
index 562464df6e..0000000000
--- a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
+++ /dev/null
@@ -1,408 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.ImmutableList.toImmutableList;
-import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Streams;
-import com.google.common.flogger.FluentLogger;
-import com.google.common.io.BaseEncoding;
-import com.google.common.io.CharStreams;
-import com.google.gerrit.common.Nullable;
-import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
-import com.google.gerrit.elasticsearch.builders.QueryBuilder;
-import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder;
-import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
-import com.google.gerrit.entities.converter.ProtoConverter;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.FieldDef;
-import com.google.gerrit.index.FieldType;
-import com.google.gerrit.index.Index;
-import com.google.gerrit.index.QueryOptions;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.query.DataSource;
-import com.google.gerrit.index.query.FieldBundle;
-import com.google.gerrit.index.query.ListResultSet;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.index.query.ResultSet;
-import com.google.gerrit.proto.Protos;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.IndexUtils;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.protobuf.MessageLite;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.sql.Timestamp;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Function;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpStatus;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.nio.entity.NStringEntity;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-
-abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
- protected static final String BULK = "_bulk";
- protected static final String MAPPINGS = "mappings";
- protected static final String ORDER = "order";
- protected static final String DESC_SORT_ORDER = "desc";
- protected static final String ASC_SORT_ORDER = "asc";
- protected static final String UNMAPPED_TYPE = "unmapped_type";
- protected static final String SEARCH = "_search";
- protected static final String SETTINGS = "settings";
-
- static byte[] decodeBase64(String base64String) {
- return BaseEncoding.base64().decode(base64String);
- }
-
- protected static <T> List<T> decodeProtos(
- JsonObject doc, String fieldName, ProtoConverter<?, T> converter) {
- JsonArray field = doc.getAsJsonArray(fieldName);
- if (field == null) {
- return null;
- }
- return Streams.stream(field)
- .map(JsonElement::getAsString)
- .map(AbstractElasticIndex::decodeBase64)
- .map(bytes -> parseProtoFrom(bytes, converter))
- .collect(toImmutableList());
- }
-
- protected static <P extends MessageLite, T> T parseProtoFrom(
- byte[] bytes, ProtoConverter<P, T> converter) {
- P message = Protos.parseUnchecked(converter.getParser(), bytes);
- return converter.fromProto(message);
- }
-
- static String getContent(Response response) throws IOException {
- HttpEntity responseEntity = response.getEntity();
- String content = "";
- if (responseEntity != null) {
- InputStream contentStream = responseEntity.getContent();
- try (Reader reader = new InputStreamReader(contentStream, UTF_8)) {
- content = CharStreams.toString(reader);
- }
- }
- return content;
- }
-
- private final ElasticConfiguration config;
- private final Schema<V> schema;
- private final SitePaths sitePaths;
- private final String indexNameRaw;
-
- protected final ElasticRestClientProvider client;
- protected final String indexName;
- protected final Gson gson;
- protected final ElasticQueryBuilder queryBuilder;
-
- AbstractElasticIndex(
- ElasticConfiguration config,
- SitePaths sitePaths,
- Schema<V> schema,
- ElasticRestClientProvider client,
- String indexName) {
- this.config = config;
- this.sitePaths = sitePaths;
- this.schema = schema;
- this.gson = new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
- this.queryBuilder = new ElasticQueryBuilder();
- this.indexName = config.getIndexName(indexName, schema.getVersion());
- this.indexNameRaw = indexName;
- this.client = client;
- }
-
- @Override
- public Schema<V> getSchema() {
- return schema;
- }
-
- @Override
- public void close() {
- // Do nothing. Client is closed by the provider.
- }
-
- @Override
- public void markReady(boolean ready) {
- IndexUtils.setReady(sitePaths, indexNameRaw, schema.getVersion(), ready);
- }
-
- @Override
- public void delete(K id) {
- String uri = getURI(BULK);
- Response response = postRequest(uri, getDeleteActions(id), getRefreshParam());
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format("Failed to delete %s from index %s: %s", id, indexName, statusCode));
- }
- }
-
- @Override
- public void deleteAll() {
- // Delete the index, if it exists.
- String endpoint = indexName + client.adapter().indicesExistParams();
- Response response = performRequest("HEAD", endpoint);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode == HttpStatus.SC_OK) {
- response = performRequest("DELETE", indexName);
- statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format("Failed to delete index %s: %s", indexName, statusCode));
- }
- }
-
- // Recreate the index.
- String indexCreationFields = concatJsonString(getSettings(), getMappings());
- response = performRequest("PUT", indexName, indexCreationFields);
- statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- String error = String.format("Failed to create index %s: %s", indexName, statusCode);
- throw new StorageException(error);
- }
- }
-
- protected abstract String getDeleteActions(K id);
-
- protected abstract String getMappings();
-
- private String getSettings() {
- return gson.toJson(ImmutableMap.of(SETTINGS, ElasticSetting.createSetting(config)));
- }
-
- protected abstract String getId(V v);
-
- protected String getMappingsForSingleType(MappingProperties properties) {
- return getMappingsFor(properties);
- }
-
- protected String getMappingsFor(MappingProperties properties) {
- JsonObject mappings = new JsonObject();
-
- mappings.add(MAPPINGS, gson.toJsonTree(properties));
- return gson.toJson(mappings);
- }
-
- protected String getDeleteRequest(K id) {
- return new DeleteRequest(id.toString(), indexName).toString();
- }
-
- protected abstract V fromDocument(JsonObject doc, Set<String> fields);
-
- protected FieldBundle toFieldBundle(JsonObject doc) {
- Map<String, FieldDef<V, ?>> allFields = getSchema().getFields();
- ListMultimap<String, Object> rawFields = ArrayListMultimap.create();
- for (Map.Entry<String, JsonElement> element :
- doc.get(client.adapter().rawFieldsKey()).getAsJsonObject().entrySet()) {
- checkArgument(
- allFields.containsKey(element.getKey()), "Unrecognized field " + element.getKey());
- FieldType<?> type = allFields.get(element.getKey()).getType();
- Iterable<JsonElement> innerItems =
- element.getValue().isJsonArray()
- ? element.getValue().getAsJsonArray()
- : Collections.singleton(element.getValue());
- for (JsonElement inner : innerItems) {
- if (type == FieldType.EXACT || type == FieldType.FULL_TEXT || type == FieldType.PREFIX) {
- rawFields.put(element.getKey(), inner.getAsString());
- } else if (type == FieldType.INTEGER || type == FieldType.INTEGER_RANGE) {
- rawFields.put(element.getKey(), inner.getAsInt());
- } else if (type == FieldType.LONG) {
- rawFields.put(element.getKey(), inner.getAsLong());
- } else if (type == FieldType.TIMESTAMP) {
- rawFields.put(element.getKey(), new Timestamp(inner.getAsLong()));
- } else if (type == FieldType.STORED_ONLY) {
- rawFields.put(element.getKey(), decodeBase64(inner.getAsString()));
- } else {
- throw FieldType.badFieldType(type);
- }
- }
- }
- return new FieldBundle(rawFields);
- }
-
- protected String toAction(String type, String id, String action) {
- JsonObject properties = new JsonObject();
- properties.addProperty("_id", id);
- properties.addProperty("_index", indexName);
- properties.addProperty("_type", type);
-
- JsonObject jsonAction = new JsonObject();
- jsonAction.add(action, properties);
- return jsonAction.toString() + System.lineSeparator();
- }
-
- protected void addNamedElement(String name, JsonObject element, JsonArray array) {
- JsonObject arrayElement = new JsonObject();
- arrayElement.add(name, element);
- array.add(arrayElement);
- }
-
- protected Map<String, String> getRefreshParam() {
- Map<String, String> params = new HashMap<>();
- params.put("refresh", "true");
- return params;
- }
-
- protected String getSearch(SearchSourceBuilder searchSource, JsonArray sortArray) {
- JsonObject search = new JsonParser().parse(searchSource.toString()).getAsJsonObject();
- search.add("sort", sortArray);
- return gson.toJson(search);
- }
-
- protected JsonArray getSortArray(String idFieldName) {
- JsonObject properties = new JsonObject();
- properties.addProperty(ORDER, ASC_SORT_ORDER);
-
- JsonArray sortArray = new JsonArray();
- addNamedElement(idFieldName, properties, sortArray);
- return sortArray;
- }
-
- protected String getURI(String request) {
- try {
- return URLEncoder.encode(indexName, UTF_8.toString()) + "/" + request;
- } catch (UnsupportedEncodingException e) {
- throw new StorageException(e);
- }
- }
-
- protected Response postRequest(String uri, Object payload) {
- return performRequest("POST", uri, payload);
- }
-
- protected Response postRequest(String uri, Object payload, Map<String, String> params) {
- return performRequest("POST", uri, payload, params);
- }
-
- private String concatJsonString(String target, String addition) {
- return target.substring(0, target.length() - 1) + "," + addition.substring(1);
- }
-
- private Response performRequest(String method, String uri) {
- return performRequest(method, uri, null);
- }
-
- private Response performRequest(String method, String uri, @Nullable Object payload) {
- return performRequest(method, uri, payload, Collections.emptyMap());
- }
-
- private Response performRequest(
- String method, String uri, @Nullable Object payload, Map<String, String> params) {
- Request request = new Request(method, uri.startsWith("/") ? uri : "/" + uri);
- if (payload != null) {
- String payloadStr = payload instanceof String ? (String) payload : payload.toString();
- request.setEntity(new NStringEntity(payloadStr, ContentType.APPLICATION_JSON));
- }
- for (Map.Entry<String, String> entry : params.entrySet()) {
- request.addParameter(entry.getKey(), entry.getValue());
- }
- try {
- return client.get().performRequest(request);
- } catch (IOException e) {
- throw new StorageException(e);
- }
- }
-
- protected class ElasticQuerySource implements DataSource<V> {
- private final QueryOptions opts;
- private final String search;
-
- ElasticQuerySource(Predicate<V> p, QueryOptions opts, JsonArray sortArray)
- throws QueryParseException {
- this.opts = opts;
- QueryBuilder qb = queryBuilder.toQueryBuilder(p);
- SearchSourceBuilder searchSource =
- new SearchSourceBuilder(client.adapter())
- .query(qb)
- .from(opts.start())
- .size(opts.limit())
- .fields(Lists.newArrayList(opts.fields()));
- search = getSearch(searchSource, sortArray);
- }
-
- @Override
- public int getCardinality() {
- return 10;
- }
-
- @Override
- public ResultSet<V> read() {
- return readImpl(doc -> AbstractElasticIndex.this.fromDocument(doc, opts.fields()));
- }
-
- @Override
- public ResultSet<FieldBundle> readRaw() {
- return readImpl(AbstractElasticIndex.this::toFieldBundle);
- }
-
- private <T> ResultSet<T> readImpl(Function<JsonObject, T> mapper) {
- try {
- String uri = getURI(SEARCH);
- Response response =
- performRequest(HttpPost.METHOD_NAME, uri, search, Collections.emptyMap());
- StatusLine statusLine = response.getStatusLine();
- if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
- String content = getContent(response);
- JsonObject obj =
- new JsonParser().parse(content).getAsJsonObject().getAsJsonObject("hits");
- if (obj.get("hits") != null) {
- JsonArray json = obj.getAsJsonArray("hits");
- ImmutableList.Builder<T> results = ImmutableList.builderWithExpectedSize(json.size());
- for (int i = 0; i < json.size(); i++) {
- T mapperResult = mapper.apply(json.get(i).getAsJsonObject());
- if (mapperResult != null) {
- results.add(mapperResult);
- }
- }
- return new ListResultSet<>(results.build());
- }
- } else {
- logger.atSevere().log(statusLine.getReasonPhrase());
- }
- return new ListResultSet<>(ImmutableList.of());
- } catch (IOException e) {
- throw new StorageException(e);
- }
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/BUILD b/java/com/google/gerrit/elasticsearch/BUILD
deleted file mode 100644
index 8bab80b3e7..0000000000
--- a/java/com/google/gerrit/elasticsearch/BUILD
+++ /dev/null
@@ -1,33 +0,0 @@
-load("@rules_java//java:defs.bzl", "java_library")
-
-java_library(
- name = "elasticsearch",
- srcs = glob(["**/*.java"]),
- visibility = ["//visibility:public"],
- deps = [
- "//java/com/google/gerrit/common:annotations",
- "//java/com/google/gerrit/entities",
- "//java/com/google/gerrit/exceptions",
- "//java/com/google/gerrit/extensions:api",
- "//java/com/google/gerrit/index",
- "//java/com/google/gerrit/index:query_exception",
- "//java/com/google/gerrit/index/project",
- "//java/com/google/gerrit/lifecycle",
- "//java/com/google/gerrit/proto",
- "//java/com/google/gerrit/server",
- "//lib:gson",
- "//lib:guava",
- "//lib:jgit",
- "//lib:protobuf",
- "//lib/commons:lang",
- "//lib/elasticsearch-rest-client",
- "//lib/flogger:api",
- "//lib/guice",
- "//lib/guice:guice-assistedinject",
- "//lib/httpcomponents:httpasyncclient",
- "//lib/httpcomponents:httpclient",
- "//lib/httpcomponents:httpcore",
- "//lib/httpcomponents:httpcore-nio",
- "//lib/jackson:jackson-core",
- ],
-)
diff --git a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
deleted file mode 100644
index 8967789381..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
-import com.google.gerrit.elasticsearch.bulk.BulkRequest;
-import com.google.gerrit.elasticsearch.bulk.IndexRequest;
-import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
-import com.google.gerrit.entities.Account;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.QueryOptions;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.query.DataSource;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.server.account.AccountCache;
-import com.google.gerrit.server.account.AccountState;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.IndexUtils;
-import com.google.gerrit.server.index.account.AccountField;
-import com.google.gerrit.server.index.account.AccountIndex;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.assistedinject.Assisted;
-import java.util.Set;
-import org.apache.http.HttpStatus;
-import org.elasticsearch.client.Response;
-
-public class ElasticAccountIndex extends AbstractElasticIndex<Account.Id, AccountState>
- implements AccountIndex {
- static class AccountMapping {
- final MappingProperties accounts;
-
- AccountMapping(Schema<AccountState> schema, ElasticQueryAdapter adapter) {
- this.accounts = ElasticMapping.createMapping(schema, adapter);
- }
- }
-
- private static final String ACCOUNTS = "accounts";
-
- private final AccountMapping mapping;
- private final Provider<AccountCache> accountCache;
- private final Schema<AccountState> schema;
-
- @Inject
- ElasticAccountIndex(
- ElasticConfiguration cfg,
- SitePaths sitePaths,
- Provider<AccountCache> accountCache,
- ElasticRestClientProvider client,
- @Assisted Schema<AccountState> schema) {
- super(cfg, sitePaths, schema, client, ACCOUNTS);
- this.accountCache = accountCache;
- this.mapping = new AccountMapping(schema, client.adapter());
- this.schema = schema;
- }
-
- @Override
- public void replace(AccountState as) {
- BulkRequest bulk =
- new IndexRequest(getId(as), indexName)
- .add(new UpdateRequest<>(schema, as, ImmutableSet.of()));
-
- String uri = getURI(BULK);
- Response response = postRequest(uri, bulk, getRefreshParam());
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format(
- "Failed to replace account %s in index %s: %s",
- as.account().id(), indexName, statusCode));
- }
- }
-
- @Override
- public DataSource<AccountState> getSource(Predicate<AccountState> p, QueryOptions opts)
- throws QueryParseException {
- JsonArray sortArray =
- getSortArray(
- schema.useLegacyNumericFields()
- ? AccountField.ID.getName()
- : AccountField.ID_STR.getName());
- return new ElasticQuerySource(
- p,
- opts.filterFields(o -> IndexUtils.accountFields(o, schema.useLegacyNumericFields())),
- sortArray);
- }
-
- @Override
- protected String getDeleteActions(Account.Id a) {
- return getDeleteRequest(a);
- }
-
- @Override
- protected String getMappings() {
- return getMappingsForSingleType(mapping.accounts);
- }
-
- @Override
- protected String getId(AccountState as) {
- return as.account().id().toString();
- }
-
- @Override
- protected AccountState fromDocument(JsonObject json, Set<String> fields) {
- JsonElement source = json.get("_source");
- if (source == null) {
- source = json.getAsJsonObject().get("fields");
- }
-
- Account.Id id =
- Account.id(
- source
- .getAsJsonObject()
- .get(
- schema.useLegacyNumericFields()
- ? AccountField.ID.getName()
- : AccountField.ID_STR.getName())
- .getAsInt());
- // Use the AccountCache rather than depending on any stored fields in the document (of which
- // there shouldn't be any). The most expensive part to compute anyway is the effective group
- // IDs, and we don't have a good way to reindex when those change.
- // If the account doesn't exist return an empty AccountState to represent the missing account
- // to account the fact that the account exists in the index.
- return accountCache.get().getEvenIfMissing(id);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
deleted file mode 100644
index 7d4e0c7827..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
-import com.google.gerrit.elasticsearch.bulk.BulkRequest;
-import com.google.gerrit.elasticsearch.bulk.IndexRequest;
-import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
-import com.google.gerrit.entities.Change;
-import com.google.gerrit.entities.Project;
-import com.google.gerrit.entities.converter.ChangeProtoConverter;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.FieldDef;
-import com.google.gerrit.index.QueryOptions;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.query.DataSource;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.server.change.MergeabilityComputationBehavior;
-import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.IndexUtils;
-import com.google.gerrit.server.index.change.ChangeField;
-import com.google.gerrit.server.index.change.ChangeIndex;
-import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import java.util.Set;
-import org.apache.http.HttpStatus;
-import org.eclipse.jgit.lib.Config;
-import org.elasticsearch.client.Response;
-
-/** Secondary index implementation using Elasticsearch. */
-class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
- implements ChangeIndex {
- static class ChangeMapping {
- final MappingProperties changes;
- final MappingProperties openChanges;
- final MappingProperties closedChanges;
-
- ChangeMapping(Schema<ChangeData> schema, ElasticQueryAdapter adapter) {
- MappingProperties mapping = ElasticMapping.createMapping(schema, adapter);
- this.changes = mapping;
- this.openChanges = mapping;
- this.closedChanges = mapping;
- }
- }
-
- private static final String CHANGES = "changes";
-
- private final ChangeMapping mapping;
- private final ChangeData.Factory changeDataFactory;
- private final Schema<ChangeData> schema;
- private final FieldDef<ChangeData, ?> idField;
- private final ImmutableSet<String> skipFields;
-
- @Inject
- ElasticChangeIndex(
- ElasticConfiguration cfg,
- ChangeData.Factory changeDataFactory,
- SitePaths sitePaths,
- ElasticRestClientProvider clientBuilder,
- @GerritServerConfig Config gerritConfig,
- @Assisted Schema<ChangeData> schema) {
- super(cfg, sitePaths, schema, clientBuilder, CHANGES);
- this.changeDataFactory = changeDataFactory;
- this.schema = schema;
- this.mapping = new ChangeMapping(schema, client.adapter());
- this.idField =
- this.schema.useLegacyNumericFields() ? ChangeField.LEGACY_ID : ChangeField.LEGACY_ID_STR;
- this.skipFields =
- MergeabilityComputationBehavior.fromConfig(gerritConfig).includeInIndex()
- ? ImmutableSet.of()
- : ImmutableSet.of(ChangeField.MERGEABLE.getName());
- }
-
- @Override
- public void replace(ChangeData cd) {
- BulkRequest bulk =
- new IndexRequest(getId(cd), indexName).add(new UpdateRequest<>(schema, cd, skipFields));
-
- String uri = getURI(BULK);
- Response response = postRequest(uri, bulk, getRefreshParam());
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format(
- "Failed to replace change %s in index %s: %s", cd.getId(), indexName, statusCode));
- }
- }
-
- @Override
- public DataSource<ChangeData> getSource(Predicate<ChangeData> p, QueryOptions opts)
- throws QueryParseException {
- QueryOptions filteredOpts =
- opts.filterFields(o -> IndexUtils.changeFields(o, schema.useLegacyNumericFields()));
- return new ElasticQuerySource(p, filteredOpts, getSortArray());
- }
-
- private JsonArray getSortArray() {
- JsonObject properties = new JsonObject();
- properties.addProperty(ORDER, DESC_SORT_ORDER);
-
- JsonArray sortArray = new JsonArray();
- addNamedElement(ChangeField.UPDATED.getName(), properties, sortArray);
- addNamedElement(ChangeField.MERGED_ON.getName(), getMergedOnSortOptions(), sortArray);
- addNamedElement(idField.getName(), properties, sortArray);
- return sortArray;
- }
-
- private JsonObject getMergedOnSortOptions() {
- JsonObject sortOptions = new JsonObject();
- sortOptions.addProperty(ORDER, DESC_SORT_ORDER);
- // Ignore the sort field if it does not exist in index. Otherwise the search would fail on open
- // changes, because the corresponding documents do not have mergedOn field.
- sortOptions.addProperty(UNMAPPED_TYPE, ElasticMapping.TIMESTAMP_FIELD_TYPE);
- return sortOptions;
- }
-
- @Override
- protected String getDeleteActions(Change.Id c) {
- return getDeleteRequest(c);
- }
-
- @Override
- protected String getMappings() {
- return getMappingsFor(mapping.changes);
- }
-
- @Override
- protected String getId(ChangeData cd) {
- return cd.getId().toString();
- }
-
- @Override
- protected ChangeData fromDocument(JsonObject json, Set<String> fields) {
- JsonElement sourceElement = json.get("_source");
- if (sourceElement == null) {
- sourceElement = json.getAsJsonObject().get("fields");
- }
- JsonObject source = sourceElement.getAsJsonObject();
- JsonElement c = source.get(ChangeField.CHANGE.getName());
-
- if (c == null) {
- int id = source.get(idField.getName()).getAsInt();
- // IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
- String projectName = requireNonNull(source.get(ChangeField.PROJECT.getName()).getAsString());
- return changeDataFactory.create(Project.nameKey(projectName), Change.id(id));
- }
-
- ChangeData cd =
- changeDataFactory.create(
- parseProtoFrom(decodeBase64(c.getAsString()), ChangeProtoConverter.INSTANCE));
-
- for (FieldDef<ChangeData, ?> field : getSchema().getFields().values()) {
- if (fields.contains(field.getName()) && source.get(field.getName()) != null) {
- field.setIfPossible(cd, new ElasticStoredValue(source.get(field.getName())));
- }
- }
-
- return cd;
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java b/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
deleted file mode 100644
index c443529798..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static com.google.common.base.MoreObjects.firstNonNull;
-
-import com.google.common.base.Strings;
-import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.inject.Inject;
-import com.google.inject.ProvisionException;
-import com.google.inject.Singleton;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpHost;
-import org.eclipse.jgit.lib.Config;
-import org.elasticsearch.client.RestClientBuilder;
-
-@Singleton
-class ElasticConfiguration {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
- static final String SECTION_ELASTICSEARCH = "elasticsearch";
- static final String KEY_PASSWORD = "password";
- static final String KEY_USERNAME = "username";
- static final String KEY_PREFIX = "prefix";
- static final String KEY_SERVER = "server";
- static final String KEY_NUMBER_OF_SHARDS = "numberOfShards";
- static final String KEY_NUMBER_OF_REPLICAS = "numberOfReplicas";
- static final String KEY_MAX_RESULT_WINDOW = "maxResultWindow";
- static final String KEY_CONNECT_TIMEOUT = "connectTimeout";
- static final String KEY_SOCKET_TIMEOUT = "socketTimeout";
-
- static final String DEFAULT_PORT = "9200";
- static final String DEFAULT_USERNAME = "elastic";
- static final int DEFAULT_NUMBER_OF_SHARDS = 1;
- static final int DEFAULT_NUMBER_OF_REPLICAS = 1;
- static final int DEFAULT_MAX_RESULT_WINDOW = 10000;
- static final int DEFAULT_CONNECT_TIMEOUT = RestClientBuilder.DEFAULT_CONNECT_TIMEOUT_MILLIS;
- static final int DEFAULT_SOCKET_TIMEOUT = RestClientBuilder.DEFAULT_SOCKET_TIMEOUT_MILLIS;
-
- private final Config cfg;
- private final List<HttpHost> hosts;
-
- final String username;
- final String password;
- final int numberOfShards;
- final int numberOfReplicas;
- final int maxResultWindow;
- final int connectTimeout;
- final int socketTimeout;
- final String prefix;
-
- @Inject
- ElasticConfiguration(@GerritServerConfig Config cfg) {
- this.cfg = cfg;
- this.password = cfg.getString(SECTION_ELASTICSEARCH, null, KEY_PASSWORD);
- this.username =
- password == null
- ? null
- : firstNonNull(
- cfg.getString(SECTION_ELASTICSEARCH, null, KEY_USERNAME), DEFAULT_USERNAME);
- this.prefix = Strings.nullToEmpty(cfg.getString(SECTION_ELASTICSEARCH, null, KEY_PREFIX));
- this.numberOfShards =
- cfg.getInt(SECTION_ELASTICSEARCH, null, KEY_NUMBER_OF_SHARDS, DEFAULT_NUMBER_OF_SHARDS);
- this.numberOfReplicas =
- cfg.getInt(SECTION_ELASTICSEARCH, null, KEY_NUMBER_OF_REPLICAS, DEFAULT_NUMBER_OF_REPLICAS);
- this.maxResultWindow =
- cfg.getInt(SECTION_ELASTICSEARCH, null, KEY_MAX_RESULT_WINDOW, DEFAULT_MAX_RESULT_WINDOW);
- this.connectTimeout =
- (int)
- cfg.getTimeUnit(
- SECTION_ELASTICSEARCH,
- null,
- KEY_CONNECT_TIMEOUT,
- DEFAULT_CONNECT_TIMEOUT,
- TimeUnit.MILLISECONDS);
- this.socketTimeout =
- (int)
- cfg.getTimeUnit(
- SECTION_ELASTICSEARCH,
- null,
- KEY_SOCKET_TIMEOUT,
- DEFAULT_SOCKET_TIMEOUT,
- TimeUnit.MILLISECONDS);
- this.hosts = new ArrayList<>();
- for (String server : cfg.getStringList(SECTION_ELASTICSEARCH, null, KEY_SERVER)) {
- try {
- URI uri = new URI(server);
- int port = uri.getPort();
- HttpHost httpHost =
- new HttpHost(
- uri.getHost(), port == -1 ? Integer.valueOf(DEFAULT_PORT) : port, uri.getScheme());
- this.hosts.add(httpHost);
- } catch (URISyntaxException | IllegalArgumentException e) {
- logger.atSevere().log("Invalid server URI %s: %s", server, e.getMessage());
- }
- }
-
- if (hosts.isEmpty()) {
- throw new ProvisionException("No valid Elasticsearch servers configured");
- }
-
- logger.atInfo().log("Elasticsearch servers: %s", hosts);
- }
-
- Config getConfig() {
- return cfg;
- }
-
- HttpHost[] getHosts() {
- return hosts.toArray(new HttpHost[hosts.size()]);
- }
-
- String getIndexName(String name, int schemaVersion) {
- return String.format("%s%s_%04d", prefix, name, schemaVersion);
- }
-
- int getNumberOfShards() {
- return numberOfShards;
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticException.java b/java/com/google/gerrit/elasticsearch/ElasticException.java
deleted file mode 100644
index d4baf75d27..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-class ElasticException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- ElasticException(String message) {
- super(message);
- }
-
- ElasticException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java b/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
deleted file mode 100644
index 781ed43051..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
-import com.google.gerrit.elasticsearch.bulk.BulkRequest;
-import com.google.gerrit.elasticsearch.bulk.IndexRequest;
-import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
-import com.google.gerrit.entities.AccountGroup;
-import com.google.gerrit.entities.InternalGroup;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.QueryOptions;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.query.DataSource;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.server.account.GroupCache;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.IndexUtils;
-import com.google.gerrit.server.index.group.GroupField;
-import com.google.gerrit.server.index.group.GroupIndex;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.assistedinject.Assisted;
-import java.util.Set;
-import org.apache.http.HttpStatus;
-import org.elasticsearch.client.Response;
-
-public class ElasticGroupIndex extends AbstractElasticIndex<AccountGroup.UUID, InternalGroup>
- implements GroupIndex {
- static class GroupMapping {
- final MappingProperties groups;
-
- GroupMapping(Schema<InternalGroup> schema, ElasticQueryAdapter adapter) {
- this.groups = ElasticMapping.createMapping(schema, adapter);
- }
- }
-
- private static final String GROUPS = "groups";
-
- private final GroupMapping mapping;
- private final Provider<GroupCache> groupCache;
- private final Schema<InternalGroup> schema;
-
- @Inject
- ElasticGroupIndex(
- ElasticConfiguration cfg,
- SitePaths sitePaths,
- Provider<GroupCache> groupCache,
- ElasticRestClientProvider client,
- @Assisted Schema<InternalGroup> schema) {
- super(cfg, sitePaths, schema, client, GROUPS);
- this.groupCache = groupCache;
- this.mapping = new GroupMapping(schema, client.adapter());
- this.schema = schema;
- }
-
- @Override
- public void replace(InternalGroup group) {
- BulkRequest bulk =
- new IndexRequest(getId(group), indexName)
- .add(new UpdateRequest<>(schema, group, ImmutableSet.of()));
-
- String uri = getURI(BULK);
- Response response = postRequest(uri, bulk, getRefreshParam());
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format(
- "Failed to replace group %s in index %s: %s",
- group.getGroupUUID().get(), indexName, statusCode));
- }
- }
-
- @Override
- public DataSource<InternalGroup> getSource(Predicate<InternalGroup> p, QueryOptions opts)
- throws QueryParseException {
- JsonArray sortArray = getSortArray(GroupField.UUID.getName());
- return new ElasticQuerySource(p, opts.filterFields(IndexUtils::groupFields), sortArray);
- }
-
- @Override
- protected String getDeleteActions(AccountGroup.UUID g) {
- return getDeleteRequest(g);
- }
-
- @Override
- protected String getMappings() {
- return getMappingsForSingleType(mapping.groups);
- }
-
- @Override
- protected String getId(InternalGroup group) {
- return group.getGroupUUID().get();
- }
-
- @Override
- protected InternalGroup fromDocument(JsonObject json, Set<String> fields) {
- JsonElement source = json.get("_source");
- if (source == null) {
- source = json.getAsJsonObject().get("fields");
- }
-
- AccountGroup.UUID uuid =
- AccountGroup.uuid(source.getAsJsonObject().get(GroupField.UUID.getName()).getAsString());
- // Use the GroupCache rather than depending on any stored fields in the
- // document (of which there shouldn't be any).
- return groupCache.get().get(uuid).orElse(null);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticIndexModule.java b/java/com/google/gerrit/elasticsearch/ElasticIndexModule.java
deleted file mode 100644
index 15d6126d45..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticIndexModule.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.index.project.ProjectIndex;
-import com.google.gerrit.server.index.AbstractIndexModule;
-import com.google.gerrit.server.index.VersionManager;
-import com.google.gerrit.server.index.account.AccountIndex;
-import com.google.gerrit.server.index.change.ChangeIndex;
-import com.google.gerrit.server.index.group.GroupIndex;
-import java.util.Map;
-
-public class ElasticIndexModule extends AbstractIndexModule {
- public static ElasticIndexModule singleVersionWithExplicitVersions(
- Map<String, Integer> versions, int threads, boolean slave) {
- return new ElasticIndexModule(versions, threads, slave);
- }
-
- public static ElasticIndexModule latestVersion(boolean slave) {
- return new ElasticIndexModule(null, 0, slave);
- }
-
- private ElasticIndexModule(Map<String, Integer> singleVersions, int threads, boolean slave) {
- super(singleVersions, threads, slave);
- }
-
- @Override
- public void configure() {
- super.configure();
- install(ElasticRestClientProvider.module());
- }
-
- @Override
- protected Class<? extends AccountIndex> getAccountIndex() {
- return ElasticAccountIndex.class;
- }
-
- @Override
- protected Class<? extends ChangeIndex> getChangeIndex() {
- return ElasticChangeIndex.class;
- }
-
- @Override
- protected Class<? extends GroupIndex> getGroupIndex() {
- return ElasticGroupIndex.class;
- }
-
- @Override
- protected Class<? extends ProjectIndex> getProjectIndex() {
- return ElasticProjectIndex.class;
- }
-
- @Override
- protected Class<? extends VersionManager> getVersionManager() {
- return ElasticIndexVersionManager.class;
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticIndexVersionDiscovery.java b/java/com/google/gerrit/elasticsearch/ElasticIndexVersionDiscovery.java
deleted file mode 100644
index 100022a181..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticIndexVersionDiscovery.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static java.util.stream.Collectors.toList;
-
-import com.google.common.flogger.FluentLogger;
-import com.google.gson.JsonParser;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.IOException;
-import java.util.List;
-import org.apache.http.HttpStatus;
-import org.apache.http.StatusLine;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-
-@Singleton
-class ElasticIndexVersionDiscovery {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
- private final ElasticRestClientProvider client;
-
- @Inject
- ElasticIndexVersionDiscovery(ElasticRestClientProvider client) {
- this.client = client;
- }
-
- List<String> discover(String prefix, String indexName) throws IOException {
- String name = prefix + indexName + "_";
- Request request = new Request("GET", client.adapter().getVersionDiscoveryUrl(name));
- Response response = client.get().performRequest(request);
-
- StatusLine statusLine = response.getStatusLine();
- if (statusLine.getStatusCode() != HttpStatus.SC_OK) {
- String message =
- String.format(
- "Failed to discover index versions for %s: %d: %s",
- name, statusLine.getStatusCode(), statusLine.getReasonPhrase());
- logger.atSevere().log(message);
- throw new IOException(message);
- }
-
- return new JsonParser()
- .parse(AbstractElasticIndex.getContent(response)).getAsJsonObject().entrySet().stream()
- .map(e -> e.getKey().replace(name, ""))
- .collect(toList());
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticIndexVersionManager.java b/java/com/google/gerrit/elasticsearch/ElasticIndexVersionManager.java
deleted file mode 100644
index b9d86d5967..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticIndexVersionManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.base.Strings;
-import com.google.common.flogger.FluentLogger;
-import com.google.common.primitives.Ints;
-import com.google.gerrit.index.Index;
-import com.google.gerrit.index.IndexDefinition;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.server.config.GerritServerConfig;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.GerritIndexStatus;
-import com.google.gerrit.server.index.OnlineUpgradeListener;
-import com.google.gerrit.server.index.VersionManager;
-import com.google.gerrit.server.plugincontext.PluginSetContext;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.TreeMap;
-import org.eclipse.jgit.lib.Config;
-
-@Singleton
-public class ElasticIndexVersionManager extends VersionManager {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
- private final String prefix;
- private final ElasticIndexVersionDiscovery versionDiscovery;
-
- @Inject
- ElasticIndexVersionManager(
- @GerritServerConfig Config cfg,
- SitePaths sitePaths,
- PluginSetContext<OnlineUpgradeListener> listeners,
- Collection<IndexDefinition<?, ?, ?>> defs,
- ElasticIndexVersionDiscovery versionDiscovery) {
- super(sitePaths, listeners, defs, VersionManager.getOnlineUpgrade(cfg));
- this.versionDiscovery = versionDiscovery;
- prefix = Strings.nullToEmpty(cfg.getString("elasticsearch", null, "prefix"));
- }
-
- @Override
- protected <K, V, I extends Index<K, V>> TreeMap<Integer, Version<V>> scanVersions(
- IndexDefinition<K, V, I> def, GerritIndexStatus cfg) {
- TreeMap<Integer, Version<V>> versions = new TreeMap<>();
- try {
- List<String> discovered = versionDiscovery.discover(prefix, def.getName());
- logger.atFine().log("Discovered versions for %s: %s", def.getName(), discovered);
- for (String version : discovered) {
- Integer v = Ints.tryParse(version);
- if (v == null || version.length() != 4) {
- logger.atWarning().log("Unrecognized version in index %s: %s", def.getName(), version);
- continue;
- }
- versions.put(v, new Version<>(null, v, true, cfg.getReady(def.getName(), v)));
- }
- } catch (IOException e) {
- logger.atSevere().withCause(e).log("Error scanning index: %s", def.getName());
- }
-
- for (Schema<V> schema : def.getSchemas().values()) {
- int v = schema.getVersion();
- boolean exists = versions.containsKey(v);
- versions.put(v, new Version<>(schema, v, exists, cfg.getReady(def.getName(), v)));
- }
- return versions;
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticMapping.java b/java/com/google/gerrit/elasticsearch/ElasticMapping.java
deleted file mode 100644
index edd05c9bb6..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticMapping.java
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gerrit.index.FieldDef;
-import com.google.gerrit.index.FieldType;
-import com.google.gerrit.index.Schema;
-import java.util.Map;
-
-class ElasticMapping {
-
- protected static final String TIMESTAMP_FIELD_TYPE = "date";
- protected static final String TIMESTAMP_FIELD_FORMAT = "dateOptionalTime";
-
- static MappingProperties createMapping(Schema<?> schema, ElasticQueryAdapter adapter) {
- ElasticMapping.Builder mapping = new ElasticMapping.Builder(adapter);
- for (FieldDef<?, ?> field : schema.getFields().values()) {
- String name = field.getName();
- FieldType<?> fieldType = field.getType();
- if (fieldType == FieldType.EXACT) {
- mapping.addExactField(name);
- } else if (fieldType == FieldType.TIMESTAMP) {
- mapping.addTimestamp(name);
- } else if (fieldType == FieldType.INTEGER
- || fieldType == FieldType.INTEGER_RANGE
- || fieldType == FieldType.LONG) {
- mapping.addNumber(name);
- } else if (fieldType == FieldType.FULL_TEXT) {
- mapping.addStringWithAnalyzer(name);
- } else if (fieldType == FieldType.PREFIX || fieldType == FieldType.STORED_ONLY) {
- mapping.addString(name);
- } else {
- throw new IllegalStateException("Unsupported field type: " + fieldType.getName());
- }
- }
- return mapping.build();
- }
-
- static class Builder {
- private final ElasticQueryAdapter adapter;
- private final ImmutableMap.Builder<String, FieldProperties> fields =
- new ImmutableMap.Builder<>();
-
- Builder(ElasticQueryAdapter adapter) {
- this.adapter = adapter;
- }
-
- MappingProperties build() {
- MappingProperties properties = new MappingProperties();
- properties.properties = fields.build();
- return properties;
- }
-
- Builder addExactField(String name) {
- FieldProperties key = new FieldProperties(adapter.exactFieldType());
- key.index = adapter.indexProperty();
- FieldProperties properties;
- properties = new FieldProperties(adapter.exactFieldType());
- properties.fields = ImmutableMap.of("key", key);
- fields.put(name, properties);
- return this;
- }
-
- Builder addTimestamp(String name) {
- FieldProperties properties = new FieldProperties(TIMESTAMP_FIELD_TYPE);
- properties.type = TIMESTAMP_FIELD_TYPE;
- properties.format = TIMESTAMP_FIELD_FORMAT;
- fields.put(name, properties);
- return this;
- }
-
- Builder addNumber(String name) {
- fields.put(name, new FieldProperties("long"));
- return this;
- }
-
- Builder addString(String name) {
- fields.put(name, new FieldProperties(adapter.stringFieldType()));
- return this;
- }
-
- Builder addStringWithAnalyzer(String name) {
- FieldProperties key = new FieldProperties(adapter.stringFieldType());
- key.analyzer = "custom_with_char_filter";
- fields.put(name, key);
- return this;
- }
-
- Builder add(String name, String type) {
- fields.put(name, new FieldProperties(type));
- return this;
- }
- }
-
- static class MappingProperties {
- Map<String, FieldProperties> properties;
- }
-
- static class FieldProperties {
- String type;
- String index;
- String format;
- String analyzer;
- Map<String, FieldProperties> fields;
-
- FieldProperties(String type) {
- this.type = type;
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java b/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java
deleted file mode 100644
index b8bfc3889f..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticProjectIndex.java
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
-import com.google.gerrit.elasticsearch.bulk.BulkRequest;
-import com.google.gerrit.elasticsearch.bulk.IndexRequest;
-import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
-import com.google.gerrit.entities.Project;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.QueryOptions;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.project.ProjectData;
-import com.google.gerrit.index.project.ProjectField;
-import com.google.gerrit.index.project.ProjectIndex;
-import com.google.gerrit.index.query.DataSource;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.index.IndexUtils;
-import com.google.gerrit.server.project.ProjectCache;
-import com.google.gerrit.server.project.ProjectState;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.assistedinject.Assisted;
-import java.util.Optional;
-import java.util.Set;
-import org.apache.http.HttpStatus;
-import org.elasticsearch.client.Response;
-
-public class ElasticProjectIndex extends AbstractElasticIndex<Project.NameKey, ProjectData>
- implements ProjectIndex {
- static class ProjectMapping {
- MappingProperties projects;
-
- ProjectMapping(Schema<ProjectData> schema, ElasticQueryAdapter adapter) {
- this.projects = ElasticMapping.createMapping(schema, adapter);
- }
- }
-
- static final String PROJECTS = "projects";
-
- private final ProjectMapping mapping;
- private final Provider<ProjectCache> projectCache;
- private final Schema<ProjectData> schema;
-
- @Inject
- ElasticProjectIndex(
- ElasticConfiguration cfg,
- SitePaths sitePaths,
- Provider<ProjectCache> projectCache,
- ElasticRestClientProvider client,
- @Assisted Schema<ProjectData> schema) {
- super(cfg, sitePaths, schema, client, PROJECTS);
- this.projectCache = projectCache;
- this.schema = schema;
- this.mapping = new ProjectMapping(schema, client.adapter());
- }
-
- @Override
- public void replace(ProjectData projectState) {
- BulkRequest bulk =
- new IndexRequest(projectState.getProject().getName(), indexName)
- .add(new UpdateRequest<>(schema, projectState, ImmutableSet.of()));
-
- String uri = getURI(BULK);
- Response response = postRequest(uri, bulk, getRefreshParam());
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK) {
- throw new StorageException(
- String.format(
- "Failed to replace project %s in index %s: %s",
- projectState.getProject().getName(), indexName, statusCode));
- }
- }
-
- @Override
- public DataSource<ProjectData> getSource(Predicate<ProjectData> p, QueryOptions opts)
- throws QueryParseException {
- JsonArray sortArray = getSortArray(ProjectField.NAME.getName());
- return new ElasticQuerySource(p, opts.filterFields(IndexUtils::projectFields), sortArray);
- }
-
- @Override
- protected String getDeleteActions(Project.NameKey nameKey) {
- return getDeleteRequest(nameKey);
- }
-
- @Override
- protected String getMappings() {
- return getMappingsForSingleType(mapping.projects);
- }
-
- @Override
- protected String getId(ProjectData projectState) {
- return projectState.getProject().getName();
- }
-
- @Override
- protected ProjectData fromDocument(JsonObject json, Set<String> fields) {
- JsonElement source = json.get("_source");
- if (source == null) {
- source = json.getAsJsonObject().get("fields");
- }
-
- Project.NameKey nameKey =
- Project.nameKey(source.getAsJsonObject().get(ProjectField.NAME.getName()).getAsString());
- Optional<ProjectState> state = projectCache.get().get(nameKey);
- if (!state.isPresent()) {
- return null;
- }
- return state.get().toProjectData();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java b/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java
deleted file mode 100644
index 19d990181d..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticQueryAdapter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-public class ElasticQueryAdapter {
- private static final String INDICES = "?allow_no_indices=false";
-
- private final String searchFilteringName;
- private final String exactFieldType;
- private final String stringFieldType;
- private final String indexProperty;
- private final String rawFieldsKey;
- private final String versionDiscoveryUrl;
-
- ElasticQueryAdapter() {
- this.versionDiscoveryUrl = "/%s*";
- this.searchFilteringName = "_source";
- this.exactFieldType = "keyword";
- this.stringFieldType = "text";
- this.indexProperty = "true";
- this.rawFieldsKey = "_source";
- }
-
- public String searchFilteringName() {
- return searchFilteringName;
- }
-
- String indicesExistParams() {
- return INDICES;
- }
-
- String exactFieldType() {
- return exactFieldType;
- }
-
- String stringFieldType() {
- return stringFieldType;
- }
-
- String indexProperty() {
- return indexProperty;
- }
-
- String rawFieldsKey() {
- return rawFieldsKey;
- }
-
- String getVersionDiscoveryUrl(String name) {
- return String.format(versionDiscoveryUrl, name);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticQueryBuilder.java b/java/com/google/gerrit/elasticsearch/ElasticQueryBuilder.java
deleted file mode 100644
index 40ac603957..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticQueryBuilder.java
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.elasticsearch.builders.BoolQueryBuilder;
-import com.google.gerrit.elasticsearch.builders.QueryBuilder;
-import com.google.gerrit.elasticsearch.builders.QueryBuilders;
-import com.google.gerrit.index.FieldDef;
-import com.google.gerrit.index.FieldType;
-import com.google.gerrit.index.query.AndPredicate;
-import com.google.gerrit.index.query.IndexPredicate;
-import com.google.gerrit.index.query.IntegerRangePredicate;
-import com.google.gerrit.index.query.NotPredicate;
-import com.google.gerrit.index.query.OrPredicate;
-import com.google.gerrit.index.query.PostFilterPredicate;
-import com.google.gerrit.index.query.Predicate;
-import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.index.query.RegexPredicate;
-import com.google.gerrit.index.query.TimestampRangePredicate;
-import java.time.Instant;
-
-public class ElasticQueryBuilder {
-
- <T> QueryBuilder toQueryBuilder(Predicate<T> p) throws QueryParseException {
- if (p instanceof AndPredicate) {
- return and(p);
- } else if (p instanceof OrPredicate) {
- return or(p);
- } else if (p instanceof NotPredicate) {
- return not(p);
- } else if (p instanceof IndexPredicate) {
- return fieldQuery((IndexPredicate<T>) p);
- } else if (p instanceof PostFilterPredicate) {
- return QueryBuilders.matchAllQuery();
- } else {
- throw new QueryParseException("cannot create query for index: " + p);
- }
- }
-
- private <T> BoolQueryBuilder and(Predicate<T> p) throws QueryParseException {
- BoolQueryBuilder b = QueryBuilders.boolQuery();
- for (Predicate<T> c : p.getChildren()) {
- b.must(toQueryBuilder(c));
- }
- return b;
- }
-
- private <T> BoolQueryBuilder or(Predicate<T> p) throws QueryParseException {
- BoolQueryBuilder q = QueryBuilders.boolQuery();
- for (Predicate<T> c : p.getChildren()) {
- q.should(toQueryBuilder(c));
- }
- return q;
- }
-
- private <T> QueryBuilder not(Predicate<T> p) throws QueryParseException {
- Predicate<T> n = p.getChild(0);
- if (n instanceof TimestampRangePredicate) {
- return notTimestamp((TimestampRangePredicate<T>) n);
- }
-
- // Lucene does not support negation, start with all and subtract.
- BoolQueryBuilder q = QueryBuilders.boolQuery();
- q.must(QueryBuilders.matchAllQuery());
- q.mustNot(toQueryBuilder(n));
- return q;
- }
-
- private <T> QueryBuilder fieldQuery(IndexPredicate<T> p) throws QueryParseException {
- FieldType<?> type = p.getType();
- FieldDef<?, ?> field = p.getField();
- String name = field.getName();
- String value = p.getValue();
-
- if (type == FieldType.INTEGER) {
- // QueryBuilder encodes integer fields as prefix coded bits,
- // which elasticsearch's queryString can't handle.
- // Create integer terms with string representations instead.
- return QueryBuilders.termQuery(name, value);
- } else if (type == FieldType.INTEGER_RANGE) {
- return intRangeQuery(p);
- } else if (type == FieldType.TIMESTAMP) {
- return timestampQuery(p);
- } else if (type == FieldType.EXACT) {
- return exactQuery(p);
- } else if (type == FieldType.PREFIX) {
- return QueryBuilders.matchPhrasePrefixQuery(name, value);
- } else if (type == FieldType.FULL_TEXT) {
- return QueryBuilders.matchPhraseQuery(name, value);
- } else {
- throw FieldType.badFieldType(p.getType());
- }
- }
-
- private <T> QueryBuilder intRangeQuery(IndexPredicate<T> p) throws QueryParseException {
- if (p instanceof IntegerRangePredicate) {
- IntegerRangePredicate<T> r = (IntegerRangePredicate<T>) p;
- int minimum = r.getMinimumValue();
- int maximum = r.getMaximumValue();
- if (minimum == maximum) {
- // Just fall back to a standard integer query.
- return QueryBuilders.termQuery(p.getField().getName(), minimum);
- }
- return QueryBuilders.rangeQuery(p.getField().getName()).gte(minimum).lte(maximum);
- }
- throw new QueryParseException("not an integer range: " + p);
- }
-
- private <T> QueryBuilder notTimestamp(TimestampRangePredicate<T> r) throws QueryParseException {
- if (r.getMinTimestamp().getTime() == 0) {
- return QueryBuilders.rangeQuery(r.getField().getName())
- .gt(Instant.ofEpochMilli(r.getMaxTimestamp().getTime()));
- }
- throw new QueryParseException("cannot negate: " + r);
- }
-
- private <T> QueryBuilder timestampQuery(IndexPredicate<T> p) throws QueryParseException {
- if (p instanceof TimestampRangePredicate) {
- TimestampRangePredicate<T> r = (TimestampRangePredicate<T>) p;
- if (r.getMaxTimestamp().getTime() == Long.MAX_VALUE) {
- // The time range only has the start value, search from the start to the max supported value
- // Long.MAX_VALUE
- return QueryBuilders.rangeQuery(r.getField().getName())
- .gte(Instant.ofEpochMilli(r.getMinTimestamp().getTime()));
- }
- return QueryBuilders.rangeQuery(r.getField().getName())
- .gte(Instant.ofEpochMilli(r.getMinTimestamp().getTime()))
- .lte(Instant.ofEpochMilli(r.getMaxTimestamp().getTime()));
- }
- throw new QueryParseException("not a timestamp: " + p);
- }
-
- private <T> QueryBuilder exactQuery(IndexPredicate<T> p) {
- String name = p.getField().getName();
- String value = p.getValue();
-
- if (!p.getField().isRepeatable() && value.isEmpty()) {
- return new BoolQueryBuilder().mustNot(QueryBuilders.existsQuery(name));
- } else if (p instanceof RegexPredicate) {
- if (value.startsWith("^")) {
- value = value.substring(1);
- }
- if (value.endsWith("$") && !value.endsWith("\\$") && !value.endsWith("\\\\$")) {
- value = value.substring(0, value.length() - 1);
- }
- return QueryBuilders.regexpQuery(name + ".key", value);
- } else {
- return QueryBuilders.termQuery(name + ".key", value);
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java b/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java
deleted file mode 100644
index b41f3653b9..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.extensions.events.LifecycleListener;
-import com.google.gerrit.lifecycle.LifecycleModule;
-import com.google.gson.JsonParser;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import java.io.IOException;
-import org.apache.http.HttpStatus;
-import org.apache.http.StatusLine;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-import org.elasticsearch.client.RestClientBuilder;
-
-@Singleton
-class ElasticRestClientProvider implements Provider<RestClient>, LifecycleListener {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
- private final ElasticConfiguration cfg;
-
- private volatile RestClient client;
- private ElasticQueryAdapter adapter;
-
- @Inject
- ElasticRestClientProvider(ElasticConfiguration cfg) {
- this.cfg = cfg;
- }
-
- public static LifecycleModule module() {
- return new LifecycleModule() {
- @Override
- protected void configure() {
- listener().to(ElasticRestClientProvider.class);
- }
- };
- }
-
- @Override
- public RestClient get() {
- if (client == null) {
- synchronized (this) {
- if (client == null) {
- client = build();
- ElasticVersion version = getVersion();
- logger.atInfo().log("Elasticsearch integration version %s", version);
- adapter = new ElasticQueryAdapter();
- }
- }
- }
- return client;
- }
-
- @Override
- public void start() {}
-
- @Override
- public void stop() {
- if (client != null) {
- try {
- client.close();
- } catch (IOException e) {
- // Ignore. We can't do anything about it.
- }
- }
- }
-
- ElasticQueryAdapter adapter() {
- get(); // Make sure we're connected
- return adapter;
- }
-
- public static class FailedToGetVersion extends ElasticException {
- private static final long serialVersionUID = 1L;
- private static final String MESSAGE = "Failed to get Elasticsearch version";
-
- FailedToGetVersion(StatusLine status) {
- super(String.format("%s: %d %s", MESSAGE, status.getStatusCode(), status.getReasonPhrase()));
- }
-
- FailedToGetVersion(Throwable cause) {
- super(MESSAGE, cause);
- }
- }
-
- private ElasticVersion getVersion() throws ElasticException {
- try {
- Response response = client.performRequest(new Request("GET", "/"));
- StatusLine statusLine = response.getStatusLine();
- if (statusLine.getStatusCode() != HttpStatus.SC_OK) {
- throw new FailedToGetVersion(statusLine);
- }
- String version =
- new JsonParser()
- .parse(AbstractElasticIndex.getContent(response))
- .getAsJsonObject()
- .get("version")
- .getAsJsonObject()
- .get("number")
- .getAsString();
- logger.atInfo().log("Connected to Elasticsearch version %s", version);
- return ElasticVersion.forVersion(version);
- } catch (IOException e) {
- throw new FailedToGetVersion(e);
- }
- }
-
- private RestClient build() {
- RestClientBuilder builder = RestClient.builder(cfg.getHosts());
- setConfiguredTimeouts(builder);
- setConfiguredCredentialsIfAny(builder);
- return builder.build();
- }
-
- private void setConfiguredTimeouts(RestClientBuilder builder) {
- builder.setRequestConfigCallback(
- (RequestConfig.Builder requestConfigBuilder) ->
- requestConfigBuilder
- .setConnectTimeout(cfg.connectTimeout)
- .setSocketTimeout(cfg.socketTimeout));
- }
-
- private void setConfiguredCredentialsIfAny(RestClientBuilder builder) {
- String username = cfg.username;
- String password = cfg.password;
- if (username != null && password != null) {
- CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
- credentialsProvider.setCredentials(
- AuthScope.ANY, new UsernamePasswordCredentials(username, password));
- builder.setHttpClientConfigCallback(
- (HttpAsyncClientBuilder httpClientBuilder) ->
- httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticSetting.java b/java/com/google/gerrit/elasticsearch/ElasticSetting.java
deleted file mode 100644
index 7ec0566a88..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticSetting.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-
-class ElasticSetting {
- /** The custom char mappings of "." to " " and "_" to " " in the form of UTF-8 */
- private static final ImmutableMap<String, String> CUSTOM_CHAR_MAPPING =
- ImmutableMap.of("\\u002E", "\\u0020", "\\u005F", "\\u0020");
-
- static SettingProperties createSetting(ElasticConfiguration config) {
- return new ElasticSetting.Builder().addCharFilter().addAnalyzer().build(config);
- }
-
- static class Builder {
- private final ImmutableMap.Builder<String, FieldProperties> fields =
- new ImmutableMap.Builder<>();
-
- SettingProperties build(ElasticConfiguration config) {
- SettingProperties properties = new SettingProperties();
- properties.analysis = fields.build();
- properties.numberOfShards = config.getNumberOfShards();
- properties.numberOfReplicas = config.numberOfReplicas;
- properties.maxResultWindow = config.maxResultWindow;
- return properties;
- }
-
- Builder addCharFilter() {
- FieldProperties charMapping = new FieldProperties("mapping");
- charMapping.mappings = getCustomCharMappings(CUSTOM_CHAR_MAPPING);
-
- FieldProperties charFilter = new FieldProperties();
- charFilter.customMapping = charMapping;
- fields.put("char_filter", charFilter);
- return this;
- }
-
- Builder addAnalyzer() {
- FieldProperties customAnalyzer = new FieldProperties("custom");
- customAnalyzer.tokenizer = "standard";
- customAnalyzer.charFilter = new String[] {"custom_mapping"};
- customAnalyzer.filter = new String[] {"lowercase"};
-
- FieldProperties analyzer = new FieldProperties();
- analyzer.customWithCharFilter = customAnalyzer;
- fields.put("analyzer", analyzer);
- return this;
- }
-
- private static String[] getCustomCharMappings(ImmutableMap<String, String> map) {
- int mappingIndex = 0;
- int numOfMappings = map.size();
- String[] mapping = new String[numOfMappings];
- for (Map.Entry<String, String> e : map.entrySet()) {
- mapping[mappingIndex++] = e.getKey() + "=>" + e.getValue();
- }
- return mapping;
- }
- }
-
- static class SettingProperties {
- Map<String, FieldProperties> analysis;
- Integer numberOfShards;
- Integer numberOfReplicas;
- Integer maxResultWindow;
- }
-
- static class FieldProperties {
- String tokenizer;
- String type;
- String[] charFilter;
- String[] filter;
- String[] mappings;
- FieldProperties customMapping;
- FieldProperties customWithCharFilter;
-
- FieldProperties() {}
-
- FieldProperties(String type) {
- this.type = type;
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticStoredValue.java b/java/com/google/gerrit/elasticsearch/ElasticStoredValue.java
deleted file mode 100644
index a02a715f67..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticStoredValue.java
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (C) 2021 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static com.google.common.collect.ImmutableList.toImmutableList;
-
-import com.google.gerrit.index.StoredValue;
-import com.google.gson.JsonElement;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.time.format.DateTimeFormatter;
-import java.util.stream.StreamSupport;
-
-/** Bridge to recover fields from the elastic index. */
-public class ElasticStoredValue implements StoredValue {
- private final JsonElement field;
-
- ElasticStoredValue(JsonElement field) {
- this.field = field;
- }
-
- @Override
- public String asString() {
- return field.getAsString();
- }
-
- @Override
- public Iterable<String> asStrings() {
- return StreamSupport.stream(field.getAsJsonArray().spliterator(), false)
- .map(f -> f.getAsString())
- .collect(toImmutableList());
- }
-
- @Override
- public Integer asInteger() {
- return field.getAsInt();
- }
-
- @Override
- public Iterable<Integer> asIntegers() {
- return StreamSupport.stream(field.getAsJsonArray().spliterator(), false)
- .map(f -> f.getAsInt())
- .collect(toImmutableList());
- }
-
- @Override
- public Long asLong() {
- return field.getAsLong();
- }
-
- @Override
- public Iterable<Long> asLongs() {
- return StreamSupport.stream(field.getAsJsonArray().spliterator(), false)
- .map(f -> f.getAsLong())
- .collect(toImmutableList());
- }
-
- @Override
- public Timestamp asTimestamp() {
- return Timestamp.from(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(field.getAsString())));
- }
-
- @Override
- public byte[] asByteArray() {
- return AbstractElasticIndex.decodeBase64(field.getAsString());
- }
-
- @Override
- public Iterable<byte[]> asByteArrays() {
- return StreamSupport.stream(field.getAsJsonArray().spliterator(), false)
- .map(f -> AbstractElasticIndex.decodeBase64(f.getAsString()))
- .collect(toImmutableList());
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticVersion.java b/java/com/google/gerrit/elasticsearch/ElasticVersion.java
deleted file mode 100644
index b5bf44b220..0000000000
--- a/java/com/google/gerrit/elasticsearch/ElasticVersion.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.common.base.Joiner;
-import java.util.regex.Pattern;
-
-public enum ElasticVersion {
- V7_6("7.6.*"),
- V7_7("7.7.*"),
- V7_8("7.8.*");
-
- private final String version;
- private final Pattern pattern;
-
- ElasticVersion(String version) {
- this.version = version;
- this.pattern = Pattern.compile(version);
- }
-
- public static class UnsupportedVersion extends ElasticException {
- private static final long serialVersionUID = 1L;
-
- UnsupportedVersion(String version) {
- super(
- String.format(
- "Unsupported version: [%s]. Supported versions: %s", version, supportedVersions()));
- }
- }
-
- /**
- * Convert a version String to an ElasticVersion if supported.
- *
- * @param version for which to return an ElasticVersion
- * @return the corresponding ElasticVersion if supported
- */
- public static ElasticVersion forVersion(String version) {
- for (ElasticVersion value : ElasticVersion.values()) {
- if (value.pattern.matcher(version).matches()) {
- return value;
- }
- }
- throw new UnsupportedVersion(version);
- }
-
- public static String supportedVersions() {
- return Joiner.on(", ").join(ElasticVersion.values());
- }
-
- @Override
- public String toString() {
- return version;
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/BoolQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/BoolQueryBuilder.java
deleted file mode 100644
index a204919cbc..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/BoolQueryBuilder.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A Query that matches documents matching boolean combinations of other queries.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.BoolQueryBuilder.
- */
-public class BoolQueryBuilder extends QueryBuilder {
-
- private final List<QueryBuilder> mustClauses = new ArrayList<>();
-
- private final List<QueryBuilder> mustNotClauses = new ArrayList<>();
-
- private final List<QueryBuilder> filterClauses = new ArrayList<>();
-
- private final List<QueryBuilder> shouldClauses = new ArrayList<>();
-
- /**
- * Adds a query that <b>must</b> appear in the matching documents and will contribute to scoring.
- */
- public BoolQueryBuilder must(QueryBuilder queryBuilder) {
- mustClauses.add(queryBuilder);
- return this;
- }
-
- /**
- * Adds a query that <b>must not</b> appear in the matching documents and will not contribute to
- * scoring.
- */
- public BoolQueryBuilder mustNot(QueryBuilder queryBuilder) {
- mustNotClauses.add(queryBuilder);
- return this;
- }
-
- /**
- * Adds a query that <i>should</i> appear in the matching documents. For a boolean query with no
- * <tt>MUST</tt> clauses one or more <code>SHOULD</code> clauses must match a document for the
- * BooleanQuery to match.
- */
- public BoolQueryBuilder should(QueryBuilder queryBuilder) {
- shouldClauses.add(queryBuilder);
- return this;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("bool");
- doXArrayContent("must", mustClauses, builder);
- doXArrayContent("filter", filterClauses, builder);
- doXArrayContent("must_not", mustNotClauses, builder);
- doXArrayContent("should", shouldClauses, builder);
- builder.endObject();
- }
-
- private void doXArrayContent(String field, List<QueryBuilder> clauses, XContentBuilder builder)
- throws IOException {
- if (clauses.isEmpty()) {
- return;
- }
- if (clauses.size() == 1) {
- builder.field(field);
- clauses.get(0).toXContent(builder);
- } else {
- builder.startArray(field);
- for (QueryBuilder clause : clauses) {
- clause.toXContent(builder);
- }
- builder.endArray();
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/ExistsQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/ExistsQueryBuilder.java
deleted file mode 100644
index 1b058d7799..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/ExistsQueryBuilder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/**
- * Constructs a query that only match on documents that the field has a value in them.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.ExistsQueryBuilder.
- */
-class ExistsQueryBuilder extends QueryBuilder {
-
- private final String name;
-
- ExistsQueryBuilder(String name) {
- this.name = name;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("exists");
- builder.field("field", name);
- builder.endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/MatchAllQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/MatchAllQueryBuilder.java
deleted file mode 100644
index a3b303cff4..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/MatchAllQueryBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/**
- * A query that matches on all documents.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.MatchAllQueryBuilder.
- */
-class MatchAllQueryBuilder extends QueryBuilder {
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("match_all");
- builder.endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/MatchQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/MatchQueryBuilder.java
deleted file mode 100644
index c0becd1e4b..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/MatchQueryBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-import java.util.Locale;
-
-/**
- * Match query is a query that analyzes the text and constructs a query as the result of the
- * analysis. It can construct different queries based on the type provided.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.MatchQueryBuilder.
- */
-class MatchQueryBuilder extends QueryBuilder {
-
- enum Type {
- /** The text is analyzed and used as a phrase query. */
- MATCH_PHRASE,
- /** The text is analyzed and used in a phrase query, with the last term acting as a prefix. */
- MATCH_PHRASE_PREFIX;
-
- @Override
- public String toString() {
- return name().toLowerCase(Locale.US);
- }
- }
-
- private final String name;
-
- private final Object text;
-
- private Type type;
-
- /** Constructs a new text query. */
- MatchQueryBuilder(String name, Object text) {
- this.name = name;
- this.text = text;
- }
-
- /** Sets the type of the text query. */
- MatchQueryBuilder type(Type type) {
- this.type = type;
- return this;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject(type.toString()).field(name, text).endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/QueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/QueryBuilder.java
deleted file mode 100644
index d6f154ecc7..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/QueryBuilder.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/** A trimmed down version of org.elasticsearch.index.query.QueryBuilder. */
-public abstract class QueryBuilder {
-
- protected QueryBuilder() {}
-
- protected void toXContent(XContentBuilder builder) throws IOException {
- builder.startObject();
- doXContent(builder);
- builder.endObject();
- }
-
- protected abstract void doXContent(XContentBuilder builder) throws IOException;
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/QueryBuilders.java b/java/com/google/gerrit/elasticsearch/builders/QueryBuilders.java
deleted file mode 100644
index 940146f147..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/QueryBuilders.java
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-/**
- * A static factory for simple "import static" usage.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.QueryBuilders.
- */
-public abstract class QueryBuilders {
-
- /** A query that match on all documents. */
- public static MatchAllQueryBuilder matchAllQuery() {
- return new MatchAllQueryBuilder();
- }
-
- /**
- * Creates a text query with type "PHRASE" for the provided field name and text.
- *
- * @param name The field name.
- * @param text The query text (to be analyzed).
- */
- public static MatchQueryBuilder matchPhraseQuery(String name, Object text) {
- return new MatchQueryBuilder(name, text).type(MatchQueryBuilder.Type.MATCH_PHRASE);
- }
-
- /**
- * Creates a match query with type "PHRASE_PREFIX" for the provided field name and text.
- *
- * @param name The field name.
- * @param text The query text (to be analyzed).
- */
- public static MatchQueryBuilder matchPhrasePrefixQuery(String name, Object text) {
- return new MatchQueryBuilder(name, text).type(MatchQueryBuilder.Type.MATCH_PHRASE_PREFIX);
- }
-
- /**
- * A Query that matches documents containing a term.
- *
- * @param name The name of the field
- * @param value The value of the term
- */
- public static TermQueryBuilder termQuery(String name, String value) {
- return new TermQueryBuilder(name, value);
- }
-
- /**
- * A Query that matches documents containing a term.
- *
- * @param name The name of the field
- * @param value The value of the term
- */
- public static TermQueryBuilder termQuery(String name, int value) {
- return new TermQueryBuilder(name, value);
- }
-
- /**
- * A Query that matches documents within an range of terms.
- *
- * @param name The field name
- */
- public static RangeQueryBuilder rangeQuery(String name) {
- return new RangeQueryBuilder(name);
- }
-
- /**
- * A Query that matches documents containing terms with a specified regular expression.
- *
- * @param name The name of the field
- * @param regexp The regular expression
- */
- public static RegexpQueryBuilder regexpQuery(String name, String regexp) {
- return new RegexpQueryBuilder(name, regexp);
- }
-
- /** A Query that matches documents matching boolean combinations of other queries. */
- public static BoolQueryBuilder boolQuery() {
- return new BoolQueryBuilder();
- }
-
- /**
- * A filter to filter only documents where a field exists in them.
- *
- * @param name The name of the field
- */
- public static ExistsQueryBuilder existsQuery(String name) {
- return new ExistsQueryBuilder(name);
- }
-
- private QueryBuilders() {}
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/QuerySourceBuilder.java b/java/com/google/gerrit/elasticsearch/builders/QuerySourceBuilder.java
deleted file mode 100644
index 1cb5c82554..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/QuerySourceBuilder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/** A trimmed down and modified version of org.elasticsearch.action.support.QuerySourceBuilder. */
-class QuerySourceBuilder {
-
- private final QueryBuilder queryBuilder;
-
- QuerySourceBuilder(QueryBuilder queryBuilder) {
- this.queryBuilder = queryBuilder;
- }
-
- void innerToXContent(XContentBuilder builder) throws IOException {
- builder.field("query");
- queryBuilder.toXContent(builder);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/RangeQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/RangeQueryBuilder.java
deleted file mode 100644
index 32dbc0e485..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/RangeQueryBuilder.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/**
- * A Query that matches documents within an range of terms.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.RangeQueryBuilder.
- */
-public class RangeQueryBuilder extends QueryBuilder {
-
- private final String name;
- private Object from;
- private Object to;
- private boolean includeLower = true;
- private boolean includeUpper = true;
-
- /**
- * A Query that matches documents within an range of terms.
- *
- * @param name The field name
- */
- RangeQueryBuilder(String name) {
- this.name = name;
- }
-
- /** The from part of the range query. Null indicates unbounded. */
- public RangeQueryBuilder gt(Object from) {
- this.from = from;
- this.includeLower = false;
- return this;
- }
-
- /** The from part of the range query. Null indicates unbounded. */
- public RangeQueryBuilder gte(Object from) {
- this.from = from;
- this.includeLower = true;
- return this;
- }
-
- /** The from part of the range query. Null indicates unbounded. */
- public RangeQueryBuilder gte(int from) {
- this.from = from;
- this.includeLower = true;
- return this;
- }
-
- /** The to part of the range query. Null indicates unbounded. */
- public RangeQueryBuilder lte(Object to) {
- this.to = to;
- this.includeUpper = true;
- return this;
- }
-
- /** The to part of the range query. Null indicates unbounded. */
- public RangeQueryBuilder lte(int to) {
- this.to = to;
- this.includeUpper = true;
- return this;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("range");
- builder.startObject(name);
-
- builder.field("from", from);
- builder.field("to", to);
- builder.field("include_lower", includeLower);
- builder.field("include_upper", includeUpper);
-
- builder.endObject();
- builder.endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/RegexpQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/RegexpQueryBuilder.java
deleted file mode 100644
index b81ec2053e..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/RegexpQueryBuilder.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/**
- * A Query that does fuzzy matching for a specific value.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.RegexpQueryBuilder.
- */
-class RegexpQueryBuilder extends QueryBuilder {
-
- private final String name;
- private final String regexp;
-
- /**
- * Constructs a new term query.
- *
- * @param name The name of the field
- * @param regexp The regular expression
- */
- RegexpQueryBuilder(String name, String regexp) {
- this.name = name;
- this.regexp = regexp;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("regexp");
- builder.startObject(name);
-
- builder.field("value", regexp);
- builder.field("flags_value", 65535);
-
- builder.endObject();
- builder.endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/SearchSourceBuilder.java b/java/com/google/gerrit/elasticsearch/builders/SearchSourceBuilder.java
deleted file mode 100644
index 35cbea99b6..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/SearchSourceBuilder.java
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import com.google.gerrit.elasticsearch.ElasticQueryAdapter;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * A search source builder allowing to easily build search source.
- *
- * <p>A trimmed down and modified version of org.elasticsearch.search.builder.SearchSourceBuilder.
- */
-public class SearchSourceBuilder {
- private final ElasticQueryAdapter adapter;
-
- private QuerySourceBuilder querySourceBuilder;
-
- private int from = -1;
-
- private int size = -1;
-
- private List<String> fieldNames;
-
- /** Constructs a new search source builder. */
- public SearchSourceBuilder(ElasticQueryAdapter adapter) {
- this.adapter = adapter;
- }
-
- /** Constructs a new search source builder with a search query. */
- public SearchSourceBuilder query(QueryBuilder query) {
- if (this.querySourceBuilder == null) {
- this.querySourceBuilder = new QuerySourceBuilder(query);
- }
- return this;
- }
-
- /** From index to start the search from. Defaults to <tt>0</tt>. */
- public SearchSourceBuilder from(int from) {
- this.from = from;
- return this;
- }
-
- /** The number of search hits to return. Defaults to <tt>10</tt>. */
- public SearchSourceBuilder size(int size) {
- this.size = size;
- return this;
- }
-
- /**
- * Sets the fields to load and return as part of the search request. If none are specified, the
- * source of the document will be returned.
- */
- public SearchSourceBuilder fields(List<String> fields) {
- this.fieldNames = fields;
- return this;
- }
-
- @Override
- public final String toString() {
- try {
- XContentBuilder builder = new XContentBuilder();
- toXContent(builder);
- return builder.string();
- } catch (IOException ioe) {
- return "";
- }
- }
-
- private void toXContent(XContentBuilder builder) throws IOException {
- builder.startObject();
- innerToXContent(builder);
- builder.endObject();
- }
-
- private void innerToXContent(XContentBuilder builder) throws IOException {
- if (from != -1) {
- builder.field("from", from);
- }
- if (size != -1) {
- builder.field("size", size);
- }
-
- if (querySourceBuilder != null) {
- querySourceBuilder.innerToXContent(builder);
- }
-
- if (fieldNames != null) {
- if (fieldNames.size() == 1) {
- builder.field(adapter.searchFilteringName(), fieldNames.get(0));
- } else {
- builder.startArray(adapter.searchFilteringName());
- for (String fieldName : fieldNames) {
- builder.value(fieldName);
- }
- builder.endArray();
- }
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/TermQueryBuilder.java b/java/com/google/gerrit/elasticsearch/builders/TermQueryBuilder.java
deleted file mode 100644
index 2b407c66ec..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/TermQueryBuilder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import java.io.IOException;
-
-/**
- * A Query that matches documents containing a term.
- *
- * <p>A trimmed down version of org.elasticsearch.index.query.TermQueryBuilder.
- */
-class TermQueryBuilder extends QueryBuilder {
-
- private final String name;
-
- private final Object value;
-
- /**
- * Constructs a new term query.
- *
- * @param name The name of the field
- * @param value The value of the term
- */
- TermQueryBuilder(String name, String value) {
- this(name, (Object) value);
- }
-
- /**
- * Constructs a new term query.
- *
- * @param name The name of the field
- * @param value The value of the term
- */
- TermQueryBuilder(String name, int value) {
- this(name, (Object) value);
- }
-
- /**
- * Constructs a new term query.
- *
- * @param name The name of the field
- * @param value The value of the term
- */
- private TermQueryBuilder(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-
- @Override
- protected void doXContent(XContentBuilder builder) throws IOException {
- builder.startObject("term");
- builder.field(name, value);
- builder.endObject();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/builders/XContentBuilder.java b/java/com/google/gerrit/elasticsearch/builders/XContentBuilder.java
deleted file mode 100644
index 9c44583e15..0000000000
--- a/java/com/google/gerrit/elasticsearch/builders/XContentBuilder.java
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project, 2009-2015 Elasticsearch
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.builders;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.time.format.DateTimeFormatter.ISO_INSTANT;
-
-import com.fasterxml.jackson.core.JsonEncoding;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.json.JsonReadFeature;
-import com.fasterxml.jackson.core.json.JsonWriteFeature;
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.Date;
-
-/** A trimmed down and modified version of org.elasticsearch.common.xcontent.XContentBuilder. */
-public final class XContentBuilder implements Closeable {
-
- private final JsonGenerator generator;
-
- private final ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- /**
- * Constructs a new builder. Make sure to call {@link #close()} when the builder is done with.
- * Inspired from org.elasticsearch.common.xcontent.json.JsonXContent static block.
- */
- public XContentBuilder() throws IOException {
- this.generator =
- JsonFactory.builder()
- .configure(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES, true)
- .configure(JsonWriteFeature.QUOTE_FIELD_NAMES, true)
- .configure(JsonReadFeature.ALLOW_JAVA_COMMENTS, true)
- .configure(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false)
- .build()
- .createGenerator(bos, JsonEncoding.UTF8);
- }
-
- public XContentBuilder startObject(String name) throws IOException {
- field(name);
- startObject();
- return this;
- }
-
- public XContentBuilder startObject() throws IOException {
- generator.writeStartObject();
- return this;
- }
-
- public XContentBuilder endObject() throws IOException {
- generator.writeEndObject();
- return this;
- }
-
- public void startArray(String name) throws IOException {
- field(name);
- startArray();
- }
-
- private void startArray() throws IOException {
- generator.writeStartArray();
- }
-
- public void endArray() throws IOException {
- generator.writeEndArray();
- }
-
- public XContentBuilder field(String name) throws IOException {
- generator.writeFieldName(name);
- return this;
- }
-
- public XContentBuilder field(String name, String value) throws IOException {
- field(name);
- generator.writeString(value);
- return this;
- }
-
- public XContentBuilder field(String name, int value) throws IOException {
- field(name);
- generator.writeNumber(value);
- return this;
- }
-
- public XContentBuilder field(String name, Iterable<?> value) throws IOException {
- startArray(name);
- for (Object o : value) {
- value(o);
- }
- endArray();
- return this;
- }
-
- public XContentBuilder field(String name, Object value) throws IOException {
- field(name);
- writeValue(value);
- return this;
- }
-
- public XContentBuilder value(Object value) throws IOException {
- writeValue(value);
- return this;
- }
-
- public XContentBuilder field(String name, boolean value) throws IOException {
- field(name);
- generator.writeBoolean(value);
- return this;
- }
-
- public XContentBuilder value(String value) throws IOException {
- generator.writeString(value);
- return this;
- }
-
- @Override
- public void close() {
- try {
- generator.close();
- } catch (IOException e) {
- // ignore
- }
- }
-
- /** Returns a string representation of the builder (only applicable for text based xcontent). */
- public String string() {
- close();
- byte[] bytesArray = bos.toByteArray();
- return new String(bytesArray, UTF_8);
- }
-
- private void writeValue(Object value) throws IOException {
- if (value == null) {
- generator.writeNull();
- return;
- }
- Class<?> type = value.getClass();
- if (type == String.class) {
- generator.writeString((String) value);
- } else if (type == Integer.class) {
- generator.writeNumber(((Integer) value));
- } else if (type == byte[].class) {
- generator.writeBinary((byte[]) value);
- } else if (value instanceof Date) {
- generator.writeString(ISO_INSTANT.format(((Date) value).toInstant()));
- } else {
- // if this is a "value" object, like enum, DistanceUnit, ..., just toString it
- // yea, it can be misleading when toString a Java class, but really, jackson should be used in
- // that case
- generator.writeString(value.toString());
- // throw new ElasticsearchIllegalArgumentException("type not supported for generic value
- // conversion: " + type);
- }
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java b/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java
deleted file mode 100644
index 16b821ca41..0000000000
--- a/java/com/google/gerrit/elasticsearch/bulk/ActionRequest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.bulk;
-
-import com.google.gson.JsonObject;
-
-abstract class ActionRequest extends BulkRequest {
-
- private final String action;
- private final String id;
- private final String index;
-
- protected ActionRequest(String action, String id, String index) {
- this.action = action;
- this.id = id;
- this.index = index;
- }
-
- @Override
- protected String getRequest() {
- JsonObject properties = new JsonObject();
- properties.addProperty("_id", id);
- properties.addProperty("_index", index);
-
- JsonObject jsonAction = new JsonObject();
- jsonAction.add(action, properties);
- return jsonAction.toString() + System.lineSeparator();
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/bulk/BulkRequest.java b/java/com/google/gerrit/elasticsearch/bulk/BulkRequest.java
deleted file mode 100644
index be5ad8d25a..0000000000
--- a/java/com/google/gerrit/elasticsearch/bulk/BulkRequest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.bulk;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class BulkRequest {
-
- private final List<BulkRequest> requests = new ArrayList<>();
-
- protected BulkRequest() {
- add(this);
- }
-
- public BulkRequest add(BulkRequest request) {
- requests.add(request);
- return this;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- for (BulkRequest request : requests) {
- builder.append(request.getRequest());
- }
- return builder.toString();
- }
-
- protected abstract String getRequest();
-}
diff --git a/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java b/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java
deleted file mode 100644
index 6451b0fcef..0000000000
--- a/java/com/google/gerrit/elasticsearch/bulk/DeleteRequest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.bulk;
-
-public class DeleteRequest extends ActionRequest {
-
- public DeleteRequest(String id, String index) {
- super("delete", id, index);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java b/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java
deleted file mode 100644
index d90b80faca..0000000000
--- a/java/com/google/gerrit/elasticsearch/bulk/IndexRequest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.bulk;
-
-public class IndexRequest extends ActionRequest {
-
- public IndexRequest(String id, String index) {
- super("index", id, index);
- }
-}
diff --git a/java/com/google/gerrit/elasticsearch/bulk/UpdateRequest.java b/java/com/google/gerrit/elasticsearch/bulk/UpdateRequest.java
deleted file mode 100644
index 196b8d6ad3..0000000000
--- a/java/com/google/gerrit/elasticsearch/bulk/UpdateRequest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch.bulk;
-
-import static java.util.stream.Collectors.toList;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Streams;
-import com.google.gerrit.elasticsearch.builders.XContentBuilder;
-import com.google.gerrit.index.Schema;
-import com.google.gerrit.index.Schema.Values;
-import java.io.IOException;
-
-public class UpdateRequest<V> extends BulkRequest {
-
- private final Schema<V> schema;
- private final V v;
- private final ImmutableSet<String> skipFields;
-
- public UpdateRequest(Schema<V> schema, V v, ImmutableSet<String> skipFields) {
- this.schema = schema;
- this.v = v;
- this.skipFields = skipFields;
- }
-
- @Override
- protected String getRequest() {
- try (XContentBuilder closeable = new XContentBuilder()) {
- XContentBuilder builder = closeable.startObject();
- for (Values<V> values : schema.buildFields(v, skipFields)) {
- String name = values.getField().getName();
- if (values.getField().isRepeatable()) {
- builder.field(name, Streams.stream(values.getValues()).collect(toList()));
- } else {
- Object element = Iterables.getOnlyElement(values.getValues(), "");
- if (shouldAddElement(element)) {
- builder.field(name, element);
- }
- }
- }
- return builder.endObject().string() + System.lineSeparator();
- } catch (IOException e) {
- return e.toString();
- }
- }
-
- private boolean shouldAddElement(Object element) {
- return !(element instanceof String) || !((String) element).isEmpty();
- }
-}
diff --git a/java/com/google/gerrit/httpd/init/BUILD b/java/com/google/gerrit/httpd/init/BUILD
index adfbdcce9c..990b5d7c62 100644
--- a/java/com/google/gerrit/httpd/init/BUILD
+++ b/java/com/google/gerrit/httpd/init/BUILD
@@ -6,7 +6,6 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/auth",
- "//java/com/google/gerrit/elasticsearch",
"//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/gpg",
"//java/com/google/gerrit/httpd",
diff --git a/java/com/google/gerrit/httpd/init/WebAppInitializer.java b/java/com/google/gerrit/httpd/init/WebAppInitializer.java
index 8d179b54fd..9d5e5d50d5 100644
--- a/java/com/google/gerrit/httpd/init/WebAppInitializer.java
+++ b/java/com/google/gerrit/httpd/init/WebAppInitializer.java
@@ -19,7 +19,6 @@ import static com.google.inject.Stage.PRODUCTION;
import com.google.common.base.Splitter;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.auth.AuthModule;
-import com.google.gerrit.elasticsearch.ElasticIndexModule;
import com.google.gerrit.extensions.client.AuthType;
import com.google.gerrit.gpg.GpgModule;
import com.google.gerrit.httpd.AllRequestFilter;
@@ -369,8 +368,6 @@ public class WebAppInitializer extends GuiceServletContextListener implements Fi
private Module createIndexModule() {
if (indexType.isLucene()) {
return LuceneIndexModule.latestVersion(false, AutoFlush.ENABLED);
- } else if (indexType.isElasticsearch()) {
- return ElasticIndexModule.latestVersion(false);
} else if (indexType.isFake()) {
// Use Reflection so that we can omit the fake index binary in production code. Test code does
// compile the component in.
diff --git a/java/com/google/gerrit/index/IndexType.java b/java/com/google/gerrit/index/IndexType.java
index 0c3a76ad9e..75f83516f6 100644
--- a/java/com/google/gerrit/index/IndexType.java
+++ b/java/com/google/gerrit/index/IndexType.java
@@ -24,8 +24,7 @@ import java.util.Optional;
/**
* Index types supported by the secondary index.
*
- * <p>The explicitly known index types are Lucene (the default), Elasticsearch and a fake index used
- * in tests.
+ * <p>The explicitly known index types are Lucene (the default) and a fake index used in tests.
*
* <p>The third supported index type is any other type String value, deemed as custom. This is for
* configuring index types that are internal or not to be disclosed. Supporting custom index types
@@ -36,7 +35,6 @@ public class IndexType {
private static final String ENV_VAR = "GERRIT_INDEX_TYPE";
private static final String LUCENE = "lucene";
- private static final String ELASTICSEARCH = "elasticsearch";
private static final String FAKE = "fake";
private final String type;
@@ -77,17 +75,13 @@ public class IndexType {
}
public static ImmutableSet<String> getKnownTypes() {
- return ImmutableSet.of(LUCENE, ELASTICSEARCH, FAKE);
+ return ImmutableSet.of(LUCENE, FAKE);
}
public boolean isLucene() {
return type.equals(LUCENE);
}
- public boolean isElasticsearch() {
- return type.equals(ELASTICSEARCH);
- }
-
public boolean isFake() {
return type.equals(FAKE);
}
diff --git a/java/com/google/gerrit/lucene/LuceneIndexModule.java b/java/com/google/gerrit/lucene/LuceneIndexModule.java
index 73256b1171..3aa9c6ef1b 100644
--- a/java/com/google/gerrit/lucene/LuceneIndexModule.java
+++ b/java/com/google/gerrit/lucene/LuceneIndexModule.java
@@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.gerrit.index.IndexConfig;
import com.google.gerrit.index.project.ProjectIndex;
+import com.google.gerrit.server.ModuleImpl;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.index.AbstractIndexModule;
import com.google.gerrit.server.index.VersionManager;
@@ -29,6 +30,7 @@ import java.util.Map;
import org.apache.lucene.search.BooleanQuery;
import org.eclipse.jgit.lib.Config;
+@ModuleImpl(name = AbstractIndexModule.INDEX_MODULE)
public class LuceneIndexModule extends AbstractIndexModule {
private final AutoFlush autoFlush;
diff --git a/java/com/google/gerrit/pgm/BUILD b/java/com/google/gerrit/pgm/BUILD
index 387ff2de4a..3a1de5e56c 100644
--- a/java/com/google/gerrit/pgm/BUILD
+++ b/java/com/google/gerrit/pgm/BUILD
@@ -10,7 +10,6 @@ java_library(
"//java/com/google/gerrit/auth",
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
- "//java/com/google/gerrit/elasticsearch",
"//java/com/google/gerrit/entities",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api",
diff --git a/java/com/google/gerrit/pgm/Daemon.java b/java/com/google/gerrit/pgm/Daemon.java
index 6f544aadf0..ba367acafe 100644
--- a/java/com/google/gerrit/pgm/Daemon.java
+++ b/java/com/google/gerrit/pgm/Daemon.java
@@ -23,7 +23,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.auth.AuthModule;
import com.google.gerrit.common.Nullable;
-import com.google.gerrit.elasticsearch.ElasticIndexModule;
import com.google.gerrit.extensions.client.AuthType;
import com.google.gerrit.gpg.GpgModule;
import com.google.gerrit.httpd.AllRequestFilter;
@@ -541,9 +540,6 @@ public class Daemon extends SiteProgram {
if (indexType.isLucene()) {
return LuceneIndexModule.latestVersion(replica, AutoFlush.ENABLED);
}
- if (indexType.isElasticsearch()) {
- return ElasticIndexModule.latestVersion(replica);
- }
if (indexType.isFake()) {
// Use Reflection so that we can omit the fake index binary in production code. Test code does
// compile the component in.
diff --git a/java/com/google/gerrit/pgm/Reindex.java b/java/com/google/gerrit/pgm/Reindex.java
index 28a36c22a0..a12c08d7ff 100644
--- a/java/com/google/gerrit/pgm/Reindex.java
+++ b/java/com/google/gerrit/pgm/Reindex.java
@@ -19,7 +19,6 @@ import static java.util.stream.Collectors.toSet;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Die;
-import com.google.gerrit.elasticsearch.ElasticIndexModule;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.index.Index;
import com.google.gerrit.index.IndexDefinition;
@@ -158,9 +157,6 @@ public class Reindex extends SiteProgram {
indexModule =
LuceneIndexModule.singleVersionWithExplicitVersions(
versions, threads, replica, AutoFlush.DISABLED);
- } else if (indexType.isElasticsearch()) {
- indexModule =
- ElasticIndexModule.singleVersionWithExplicitVersions(versions, threads, replica);
} else if (indexType.isFake()) {
// Use Reflection so that we can omit the fake index binary in production code. Test code does
// compile the component in.
diff --git a/java/com/google/gerrit/pgm/init/BUILD b/java/com/google/gerrit/pgm/init/BUILD
index 62c95268af..5849711c22 100644
--- a/java/com/google/gerrit/pgm/init/BUILD
+++ b/java/com/google/gerrit/pgm/init/BUILD
@@ -9,7 +9,6 @@ java_library(
deps = [
"//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server",
- "//java/com/google/gerrit/elasticsearch",
"//java/com/google/gerrit/entities",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api",
diff --git a/java/com/google/gerrit/pgm/init/BaseInit.java b/java/com/google/gerrit/pgm/init/BaseInit.java
index c083296815..c1f57537d8 100644
--- a/java/com/google/gerrit/pgm/init/BaseInit.java
+++ b/java/com/google/gerrit/pgm/init/BaseInit.java
@@ -33,7 +33,6 @@ import com.google.gerrit.pgm.init.api.InstallPlugins;
import com.google.gerrit.pgm.init.api.LibraryDownload;
import com.google.gerrit.pgm.init.index.IndexManagerOnInit;
import com.google.gerrit.pgm.init.index.IndexModuleOnInit;
-import com.google.gerrit.pgm.init.index.elasticsearch.ElasticIndexModuleOnInit;
import com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit;
import com.google.gerrit.pgm.util.SiteProgram;
import com.google.gerrit.server.config.GerritServerConfigModule;
@@ -416,8 +415,6 @@ public class BaseInit extends SiteProgram {
IndexType indexType = IndexModule.getIndexType(dbInjector);
if (indexType.isLucene()) {
modules.add(new LuceneIndexModuleOnInit());
- } else if (indexType.isElasticsearch()) {
- modules.add(new ElasticIndexModuleOnInit());
} else if (indexType.isFake()) {
try {
Class<?> clazz = Class.forName("com.google.gerrit.index.testing.FakeIndexModuleOnInit");
diff --git a/java/com/google/gerrit/pgm/init/InitIndex.java b/java/com/google/gerrit/pgm/init/InitIndex.java
index 83d9261042..a6254fd592 100644
--- a/java/com/google/gerrit/pgm/init/InitIndex.java
+++ b/java/com/google/gerrit/pgm/init/InitIndex.java
@@ -39,7 +39,6 @@ class InitIndex implements InitStep {
private final SitePaths site;
private final InitFlags initFlags;
private final Section gerrit;
- private final Section.Factory sections;
@Inject
InitIndex(ConsoleUI ui, Section.Factory sections, SitePaths site, InitFlags initFlags) {
@@ -48,7 +47,6 @@ class InitIndex implements InitStep {
this.gerrit = sections.get("gerrit", null);
this.site = site;
this.initFlags = initFlags;
- this.sections = sections;
}
@Override
@@ -58,13 +56,6 @@ class InitIndex implements InitStep {
new IndexType(
index.select("Type", "type", IndexType.getDefault(), IndexType.getKnownTypes()));
- if (type.isElasticsearch()) {
- Section elasticsearch = sections.get("elasticsearch", null);
- elasticsearch.string("Index Prefix", "prefix", "gerrit_");
- elasticsearch.string("Server", "server", "http://localhost:9200");
- index.string("Result window size", "maxLimit", "10000");
- }
-
if ((site.isNew || isEmptySite()) && type.isLucene()) {
for (SchemaDefinitions<?> def : IndexModule.ALL_SCHEMA_DEFS) {
IndexUtils.setReady(site, def.getName(), def.getLatest().getVersion(), true);
diff --git a/java/com/google/gerrit/pgm/init/index/IndexModuleOnInit.java b/java/com/google/gerrit/pgm/init/index/IndexModuleOnInit.java
index 80de1e5413..d1d0729894 100644
--- a/java/com/google/gerrit/pgm/init/index/IndexModuleOnInit.java
+++ b/java/com/google/gerrit/pgm/init/index/IndexModuleOnInit.java
@@ -50,8 +50,7 @@ public class IndexModuleOnInit extends AbstractModule {
@Override
protected void configure() {
- // The AccountIndex implementations (LuceneAccountIndex and
- // ElasticAccountIndex) need AccountCache only for reading from the index.
+ // The LuceneAccountIndex needs AccountCache only for reading from the index.
// On init we only want to write to the index, hence we don't need the
// account cache.
bind(AccountCache.class).toProvider(Providers.of(null));
@@ -63,8 +62,8 @@ public class IndexModuleOnInit extends AbstractModule {
bind(AccountIndexCollection.class);
- // The GroupIndex implementations (LuceneGroupIndex and ElasticGroupIndex)
- // need GroupCache only for reading from the index. On init we only want to
+ // The LuceneGroupIndex needs GroupCache only for reading from the index. On init we only want
+ // to
// write to the index, hence we don't need the group cache.
bind(GroupCache.class).toProvider(Providers.of(null));
diff --git a/java/com/google/gerrit/pgm/init/index/elasticsearch/ElasticIndexModuleOnInit.java b/java/com/google/gerrit/pgm/init/index/elasticsearch/ElasticIndexModuleOnInit.java
deleted file mode 100644
index f086ab1920..0000000000
--- a/java/com/google/gerrit/pgm/init/index/elasticsearch/ElasticIndexModuleOnInit.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2017 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.pgm.init.index.elasticsearch;
-
-import com.google.gerrit.elasticsearch.ElasticAccountIndex;
-import com.google.gerrit.elasticsearch.ElasticGroupIndex;
-import com.google.gerrit.pgm.init.index.IndexModuleOnInit;
-import com.google.gerrit.server.index.account.AccountIndex;
-import com.google.gerrit.server.index.group.GroupIndex;
-import com.google.inject.AbstractModule;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-
-public class ElasticIndexModuleOnInit extends AbstractModule {
-
- @Override
- protected void configure() {
- install(
- new FactoryModuleBuilder()
- .implement(AccountIndex.class, ElasticAccountIndex.class)
- .build(AccountIndex.Factory.class));
-
- install(
- new FactoryModuleBuilder()
- .implement(GroupIndex.class, ElasticGroupIndex.class)
- .build(GroupIndex.Factory.class));
-
- install(new IndexModuleOnInit());
- }
-}
diff --git a/java/com/google/gerrit/server/index/AbstractIndexModule.java b/java/com/google/gerrit/server/index/AbstractIndexModule.java
index 352971f8a7..81c517f87b 100644
--- a/java/com/google/gerrit/server/index/AbstractIndexModule.java
+++ b/java/com/google/gerrit/server/index/AbstractIndexModule.java
@@ -33,6 +33,7 @@ import org.eclipse.jgit.lib.Config;
* index implementations, such as {@link com.google.gerrit.lucene.LuceneIndexModule}.
*/
public abstract class AbstractIndexModule extends AbstractModule {
+ public static final String INDEX_MODULE = "index-module";
private final int threads;
private final Map<String, Integer> singleVersions;
diff --git a/java/com/google/gerrit/testing/InMemoryModule.java b/java/com/google/gerrit/testing/InMemoryModule.java
index a45e9063cf..b9daa13770 100644
--- a/java/com/google/gerrit/testing/InMemoryModule.java
+++ b/java/com/google/gerrit/testing/InMemoryModule.java
@@ -248,8 +248,6 @@ public class InMemoryModule extends FactoryModule {
// For custom index types, callers must provide their own module.
if (indexType.isLucene()) {
install(luceneIndexModule());
- } else if (indexType.isElasticsearch()) {
- install(elasticIndexModule());
} else if (indexType.isFake()) {
install(fakeIndexModule());
}
@@ -324,10 +322,6 @@ public class InMemoryModule extends FactoryModule {
return indexModule("com.google.gerrit.lucene.LuceneIndexModule");
}
- private Module elasticIndexModule() {
- return indexModule("com.google.gerrit.elasticsearch.ElasticIndexModule");
- }
-
private Module fakeIndexModule() {
return indexModule("com.google.gerrit.index.testing.FakeIndexModule");
}
diff --git a/java/com/google/gerrit/testing/IndexConfig.java b/java/com/google/gerrit/testing/IndexConfig.java
index d68dcad461..13b346f6d7 100644
--- a/java/com/google/gerrit/testing/IndexConfig.java
+++ b/java/com/google/gerrit/testing/IndexConfig.java
@@ -43,16 +43,6 @@ public class IndexConfig {
return cfg;
}
- public static Config createForElasticsearch() {
- Config cfg = create();
-
- // For some reason enabling the staleness checker increases the flakiness of the Elasticsearch
- // tests. Hence disable the staleness checker.
- cfg.setBoolean("index", null, "autoReindexIfStale", false);
-
- return cfg;
- }
-
public static Config createForFake() {
return create();
}
diff --git a/java/com/google/gerrit/testing/TestLoggingActivator.java b/java/com/google/gerrit/testing/TestLoggingActivator.java
index b3ad86248c..ee1a525126 100644
--- a/java/com/google/gerrit/testing/TestLoggingActivator.java
+++ b/java/com/google/gerrit/testing/TestLoggingActivator.java
@@ -62,13 +62,6 @@ public class TestLoggingActivator {
.put("org.eclipse.jgit.internal.storage.file.FileSnapshot", Level.WARN)
.put("org.eclipse.jgit.util.FS", Level.WARN)
.put("org.eclipse.jgit.util.SystemReader", Level.WARN)
-
- // Silence non-critical messages from Elasticsearch.
- .put("org.elasticsearch", Level.WARN)
-
- // Silence non-critical messages from Docker for Elasticsearch query tests.
- .put("org.testcontainers", Level.WARN)
- .put("com.github.dockerjava.core", Level.WARN)
.build();
private static Level getGerritLogLevel() {
diff --git a/javatests/com/google/gerrit/acceptance/pgm/BUILD b/javatests/com/google/gerrit/acceptance/pgm/BUILD
index 5b18d026af..9fab01b495 100644
--- a/javatests/com/google/gerrit/acceptance/pgm/BUILD
+++ b/javatests/com/google/gerrit/acceptance/pgm/BUILD
@@ -4,7 +4,6 @@ load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
acceptance_tests(
srcs = glob(
["*IT.java"],
- exclude = ["ElasticReindexIT.java"],
),
group = "pgm",
labels = [
@@ -21,24 +20,6 @@ acceptance_tests(
],
)
-acceptance_tests(
- srcs = ["ElasticReindexIT.java"],
- group = "elastic",
- labels = [
- "docker",
- "elastic",
- "pgm",
- "no_windows",
- ],
- vm_args = ["-Xmx1024m"],
- deps = [
- ":util",
- "//java/com/google/gerrit/elasticsearch",
- "//java/com/google/gerrit/server/schema",
- "//javatests/com/google/gerrit/elasticsearch:elasticsearch_test_utils",
- ],
-)
-
java_library(
name = "util",
testonly = True,
diff --git a/javatests/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java b/javatests/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java
deleted file mode 100644
index 0632241d92..0000000000
--- a/javatests/com/google/gerrit/acceptance/pgm/ElasticReindexIT.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.acceptance.pgm;
-
-import static com.google.gerrit.elasticsearch.ElasticTestUtils.getConfig;
-
-import com.google.gerrit.elasticsearch.ElasticVersion;
-import com.google.gerrit.testing.ConfigSuite;
-import org.eclipse.jgit.lib.Config;
-
-public class ElasticReindexIT extends AbstractReindexTests {
- @ConfigSuite.Default
- public static Config elasticsearchV7() {
- return getConfig(ElasticVersion.V7_8);
- }
-}
diff --git a/javatests/com/google/gerrit/acceptance/ssh/BUILD b/javatests/com/google/gerrit/acceptance/ssh/BUILD
index ee1b221c1e..6dec6affbb 100644
--- a/javatests/com/google/gerrit/acceptance/ssh/BUILD
+++ b/javatests/com/google/gerrit/acceptance/ssh/BUILD
@@ -11,7 +11,6 @@ java_library(
acceptance_tests(
srcs = glob(
["*IT.java"],
- exclude = ["ElasticIndexIT.java"],
),
group = "ssh",
labels = ["ssh"],
@@ -23,20 +22,3 @@ acceptance_tests(
"//lib/commons:compress",
],
)
-
-acceptance_tests(
- srcs = ["ElasticIndexIT.java"],
- group = "elastic",
- labels = [
- "docker",
- "elastic",
- "exclusive",
- "ssh",
- ],
- deps = [
- ":util",
- "//java/com/google/gerrit/elasticsearch",
- "//javatests/com/google/gerrit/elasticsearch:elasticsearch_test_utils",
- "//lib/commons:compress",
- ],
-)
diff --git a/javatests/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java b/javatests/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java
deleted file mode 100644
index f35bcb79eb..0000000000
--- a/javatests/com/google/gerrit/acceptance/ssh/ElasticIndexIT.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.acceptance.ssh;
-
-import static com.google.gerrit.elasticsearch.ElasticTestUtils.createAllIndexes;
-import static com.google.gerrit.elasticsearch.ElasticTestUtils.getConfig;
-
-import com.google.gerrit.elasticsearch.ElasticVersion;
-import com.google.gerrit.index.IndexType;
-import com.google.gerrit.testing.ConfigSuite;
-import com.google.inject.Injector;
-import org.eclipse.jgit.lib.Config;
-
-/** Tests for every supported {@link IndexType#isElasticsearch()} most recent index version. */
-public class ElasticIndexIT extends AbstractIndexTests {
-
- @ConfigSuite.Default
- public static Config elasticsearchV7() {
- return getConfig(ElasticVersion.V7_8);
- }
-
- @Override
- public void configureIndex(Injector injector) {
- createAllIndexes(injector);
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/BUILD b/javatests/com/google/gerrit/elasticsearch/BUILD
deleted file mode 100644
index 303681176c..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/BUILD
+++ /dev/null
@@ -1,85 +0,0 @@
-load("@rules_java//java:defs.bzl", "java_library")
-load("//tools/bzl:junit.bzl", "junit_tests")
-
-java_library(
- name = "elasticsearch_test_utils",
- testonly = True,
- srcs = [
- "ElasticContainer.java",
- "ElasticTestUtils.java",
- ],
- visibility = ["//visibility:public"],
- deps = [
- "//java/com/google/gerrit/elasticsearch",
- "//java/com/google/gerrit/index",
- "//lib:guava",
- "//lib:jgit",
- "//lib:junit",
- "//lib/guice",
- "//lib/httpcomponents:httpcore",
- "//lib/jackson:jackson-annotations",
- "//lib/log:api",
- "//lib/testcontainers",
- "//lib/testcontainers:docker-java-api",
- "//lib/testcontainers:docker-java-transport",
- "//lib/testcontainers:testcontainers-elasticsearch",
- ],
-)
-
-ELASTICSEARCH_DEPS = [
- ":elasticsearch_test_utils",
- "//java/com/google/gerrit/elasticsearch",
- "//java/com/google/gerrit/testing:gerrit-test-util",
- "//lib/guice",
- "//lib:jgit",
-]
-
-HTTP_TEST_DEPS = [
- "//lib/httpcomponents:httpasyncclient",
- "//lib/httpcomponents:httpclient",
-]
-
-QUERY_TESTS_DEP = "//javatests/com/google/gerrit/server/query/%s:abstract_query_tests"
-
-TYPES = [
- "account",
- "change",
- "group",
- "project",
-]
-
-SUFFIX = "sTest.java"
-
-ELASTICSEARCH_TESTS_V7 = {i: "ElasticV7Query" + i.capitalize() + SUFFIX for i in TYPES}
-
-ELASTICSEARCH_TAGS = [
- "docker",
- "elastic",
-]
-
-[junit_tests(
- name = "elasticsearch_query_%ss_test_V7" % name,
- size = "large",
- srcs = [src],
- tags = ELASTICSEARCH_TAGS,
- deps = ELASTICSEARCH_DEPS + [QUERY_TESTS_DEP % name] + HTTP_TEST_DEPS,
-) for name, src in ELASTICSEARCH_TESTS_V7.items()]
-
-junit_tests(
- name = "elasticsearch_tests",
- size = "small",
- srcs = glob(
- ["*Test.java"],
- exclude = ["Elastic*Query*" + SUFFIX],
- ),
- tags = ["elastic"],
- deps = [
- "//java/com/google/gerrit/elasticsearch",
- "//java/com/google/gerrit/testing:gerrit-test-util",
- "//lib:guava",
- "//lib:jgit",
- "//lib/guice",
- "//lib/httpcomponents:httpcore",
- "//lib/truth",
- ],
-)
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticConfigurationTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticConfigurationTest.java
deleted file mode 100644
index 7e044c330f..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticConfigurationTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.DEFAULT_USERNAME;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.KEY_PASSWORD;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.KEY_PREFIX;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.KEY_SERVER;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.KEY_USERNAME;
-import static com.google.gerrit.elasticsearch.ElasticConfiguration.SECTION_ELASTICSEARCH;
-import static com.google.gerrit.testing.GerritJUnit.assertThrows;
-import static java.util.stream.Collectors.toList;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.ProvisionException;
-import java.util.Arrays;
-import org.apache.http.HttpHost;
-import org.eclipse.jgit.lib.Config;
-import org.junit.Test;
-
-public class ElasticConfigurationTest {
- @Test
- public void singleServerNoOtherConfig() throws Exception {
- Config cfg = newConfig();
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertHosts(esCfg, "http://elastic:1234");
- assertThat(esCfg.username).isNull();
- assertThat(esCfg.password).isNull();
- assertThat(esCfg.prefix).isEmpty();
- }
-
- @Test
- public void serverWithoutPortSpecified() throws Exception {
- Config cfg = new Config();
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_SERVER, "http://elastic");
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertHosts(esCfg, "http://elastic:9200");
- }
-
- @Test
- public void prefix() throws Exception {
- Config cfg = newConfig();
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_PREFIX, "myprefix");
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertThat(esCfg.prefix).isEqualTo("myprefix");
- }
-
- @Test
- public void withAuthentication() throws Exception {
- Config cfg = newConfig();
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_USERNAME, "myself");
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_PASSWORD, "s3kr3t");
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertThat(esCfg.username).isEqualTo("myself");
- assertThat(esCfg.password).isEqualTo("s3kr3t");
- }
-
- @Test
- public void withAuthenticationPasswordOnlyUsesDefaultUsername() throws Exception {
- Config cfg = newConfig();
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_PASSWORD, "s3kr3t");
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertThat(esCfg.username).isEqualTo(DEFAULT_USERNAME);
- assertThat(esCfg.password).isEqualTo("s3kr3t");
- }
-
- @Test
- public void multipleServers() throws Exception {
- Config cfg = new Config();
- cfg.setStringList(
- SECTION_ELASTICSEARCH,
- null,
- KEY_SERVER,
- ImmutableList.of("http://elastic1:1234", "http://elastic2:1234"));
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertHosts(esCfg, "http://elastic1:1234", "http://elastic2:1234");
- }
-
- @Test
- public void noServers() throws Exception {
- assertProvisionException(new Config());
- }
-
- @Test
- public void singleServerInvalid() throws Exception {
- Config cfg = new Config();
- cfg.setString(SECTION_ELASTICSEARCH, null, KEY_SERVER, "foo");
- assertProvisionException(cfg);
- }
-
- @Test
- public void multipleServersIncludingInvalid() throws Exception {
- Config cfg = new Config();
- cfg.setStringList(
- SECTION_ELASTICSEARCH, null, KEY_SERVER, ImmutableList.of("http://elastic1:1234", "foo"));
- ElasticConfiguration esCfg = new ElasticConfiguration(cfg);
- assertHosts(esCfg, "http://elastic1:1234");
- }
-
- private static Config newConfig() {
- Config config = new Config();
- config.setString(SECTION_ELASTICSEARCH, null, KEY_SERVER, "http://elastic:1234");
- return config;
- }
-
- private void assertHosts(ElasticConfiguration cfg, Object... hostURIs) throws Exception {
- assertThat(Arrays.asList(cfg.getHosts()).stream().map(HttpHost::toURI).collect(toList()))
- .containsExactly(hostURIs);
- }
-
- private void assertProvisionException(Config cfg) {
- ProvisionException thrown =
- assertThrows(ProvisionException.class, () -> new ElasticConfiguration(cfg));
- assertThat(thrown).hasMessageThat().contains("No valid Elasticsearch servers configured");
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
deleted file mode 100644
index c3309610e5..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import org.apache.http.HttpHost;
-import org.junit.AssumptionViolatedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-/* Helper class for running ES integration tests in docker container */
-public class ElasticContainer extends ElasticsearchContainer {
- private static final int ELASTICSEARCH_DEFAULT_PORT = 9200;
-
- public static ElasticContainer createAndStart(ElasticVersion version) {
- // Assumption violation is not natively supported by Testcontainers.
- // See https://github.com/testcontainers/testcontainers-java/issues/343
- try {
- ElasticContainer container = new ElasticContainer(version);
- container.start();
- return container;
- } catch (Throwable t) {
- throw new AssumptionViolatedException("Unable to start container", t);
- }
- }
-
- private static String getImageName(ElasticVersion version) {
- switch (version) {
- case V7_6:
- return "blacktop/elasticsearch:7.6.2";
- case V7_7:
- return "blacktop/elasticsearch:7.7.1";
- case V7_8:
- return "blacktop/elasticsearch:7.8.1";
- }
- throw new IllegalStateException("No tests for version: " + version.name());
- }
-
- private ElasticContainer(ElasticVersion version) {
- super(
- DockerImageName.parse(getImageName(version))
- .asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"));
- }
-
- @Override
- protected Logger logger() {
- return LoggerFactory.getLogger("org.testcontainers");
- }
-
- public HttpHost getHttpHost() {
- return new HttpHost(getContainerIpAddress(), getMappedPort(ELASTICSEARCH_DEFAULT_PORT));
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticTestUtils.java b/javatests/com/google/gerrit/elasticsearch/ElasticTestUtils.java
deleted file mode 100644
index dcc688032a..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticTestUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.index.IndexDefinition;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-import java.util.Collection;
-import java.util.UUID;
-import org.eclipse.jgit.lib.Config;
-
-public final class ElasticTestUtils {
- public static void configure(Config config, ElasticContainer container, String prefix) {
- String hostname = container.getHttpHost().getHostName();
- int port = container.getHttpHost().getPort();
- config.setString("index", null, "type", "elasticsearch");
- config.setString("elasticsearch", null, "server", "http://" + hostname + ":" + port);
- config.setString("elasticsearch", null, "prefix", prefix);
- config.setInt("index", null, "maxLimit", 10000);
- }
-
- public static void createAllIndexes(Injector injector) {
- Collection<IndexDefinition<?, ?, ?>> indexDefs =
- injector.getInstance(Key.get(new TypeLiteral<Collection<IndexDefinition<?, ?, ?>>>() {}));
- for (IndexDefinition<?, ?, ?> indexDef : indexDefs) {
- indexDef.getIndexCollection().getSearchIndex().deleteAll();
- }
- }
-
- public static Config getConfig(ElasticVersion version) {
- ElasticContainer container = ElasticContainer.createAndStart(version);
- String indicesPrefix = UUID.randomUUID().toString();
- Config cfg = new Config();
- configure(cfg, container, indicesPrefix);
- return cfg;
- }
-
- private ElasticTestUtils() {
- // hide default constructor
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryAccountsTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryAccountsTest.java
deleted file mode 100644
index 48264906d4..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryAccountsTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.server.query.account.AbstractQueryAccountsTest;
-import com.google.gerrit.testing.ConfigSuite;
-import com.google.gerrit.testing.InMemoryModule;
-import com.google.gerrit.testing.IndexConfig;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.eclipse.jgit.lib.Config;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class ElasticV7QueryAccountsTest extends AbstractQueryAccountsTest {
- @ConfigSuite.Default
- public static Config defaultConfig() {
- return IndexConfig.createForElasticsearch();
- }
-
- private static ElasticContainer container;
-
- @BeforeClass
- public static void startIndexService() {
- if (container == null) {
- // Only start Elasticsearch once
- container = ElasticContainer.createAndStart(ElasticVersion.V7_8);
- }
- }
-
- @AfterClass
- public static void stopElasticsearchServer() {
- if (container != null) {
- container.stop();
- }
- }
-
- @Override
- protected void initAfterLifecycleStart() throws Exception {
- super.initAfterLifecycleStart();
- ElasticTestUtils.createAllIndexes(injector);
- }
-
- @Override
- protected Injector createInjector() {
- Config elasticsearchConfig = new Config(config);
- InMemoryModule.setDefaults(elasticsearchConfig);
- String indicesPrefix = testName.getSanitizedMethodName();
- ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
- return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryChangesTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryChangesTest.java
deleted file mode 100644
index d9a4d2ebc2..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryChangesTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-
-import com.google.gerrit.server.query.change.AbstractQueryChangesTest;
-import com.google.gerrit.testing.ConfigSuite;
-import com.google.gerrit.testing.GerritTestName;
-import com.google.gerrit.testing.InMemoryModule;
-import com.google.gerrit.testing.IndexConfig;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
-import org.apache.http.impl.nio.client.HttpAsyncClients;
-import org.eclipse.jgit.lib.Config;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-
-public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest {
- @ConfigSuite.Default
- public static Config defaultConfig() {
- return IndexConfig.createForElasticsearch();
- }
-
- private static ElasticContainer container;
- private static CloseableHttpAsyncClient client;
-
- @BeforeClass
- public static void startIndexService() {
- if (container == null) {
- // Only start Elasticsearch once
- container = ElasticContainer.createAndStart(ElasticVersion.V7_8);
- client = HttpAsyncClients.createDefault();
- client.start();
- }
- }
-
- @AfterClass
- public static void stopElasticsearchServer() {
- if (container != null) {
- container.stop();
- }
- }
-
- @Rule public final GerritTestName testName = new GerritTestName();
-
- @After
- public void closeIndex() throws Exception {
- // Close the index after each test to prevent exceeding Elasticsearch's
- // shard limit (see Issue 10120).
- client
- .execute(
- new HttpPost(
- String.format(
- "http://%s:%d/%s*/_close",
- container.getHttpHost().getHostName(),
- container.getHttpHost().getPort(),
- testName.getSanitizedMethodName())),
- HttpClientContext.create(),
- null)
- .get(5, MINUTES);
- }
-
- @Override
- protected void initAfterLifecycleStart() throws Exception {
- super.initAfterLifecycleStart();
- ElasticTestUtils.createAllIndexes(injector);
- }
-
- @Override
- protected Injector createInjector() {
- Config elasticsearchConfig = new Config(config);
- InMemoryModule.setDefaults(elasticsearchConfig);
- String indicesPrefix = testName.getSanitizedMethodName();
- ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
- return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryGroupsTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryGroupsTest.java
deleted file mode 100644
index 0fc96f8388..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryGroupsTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.server.query.group.AbstractQueryGroupsTest;
-import com.google.gerrit.testing.ConfigSuite;
-import com.google.gerrit.testing.InMemoryModule;
-import com.google.gerrit.testing.IndexConfig;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.eclipse.jgit.lib.Config;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class ElasticV7QueryGroupsTest extends AbstractQueryGroupsTest {
- @ConfigSuite.Default
- public static Config defaultConfig() {
- return IndexConfig.createForElasticsearch();
- }
-
- private static ElasticContainer container;
-
- @BeforeClass
- public static void startIndexService() {
- if (container == null) {
- // Only start Elasticsearch once
- container = ElasticContainer.createAndStart(ElasticVersion.V7_8);
- }
- }
-
- @AfterClass
- public static void stopElasticsearchServer() {
- if (container != null) {
- container.stop();
- }
- }
-
- @Override
- protected void initAfterLifecycleStart() throws Exception {
- super.initAfterLifecycleStart();
- ElasticTestUtils.createAllIndexes(injector);
- }
-
- @Override
- protected Injector createInjector() {
- Config elasticsearchConfig = new Config(config);
- InMemoryModule.setDefaults(elasticsearchConfig);
- String indicesPrefix = testName.getSanitizedMethodName();
- ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
- return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryProjectsTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryProjectsTest.java
deleted file mode 100644
index 1e56af9556..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticV7QueryProjectsTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import com.google.gerrit.server.query.project.AbstractQueryProjectsTest;
-import com.google.gerrit.testing.ConfigSuite;
-import com.google.gerrit.testing.InMemoryModule;
-import com.google.gerrit.testing.IndexConfig;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.eclipse.jgit.lib.Config;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class ElasticV7QueryProjectsTest extends AbstractQueryProjectsTest {
- @ConfigSuite.Default
- public static Config defaultConfig() {
- return IndexConfig.createForElasticsearch();
- }
-
- private static ElasticContainer container;
-
- @BeforeClass
- public static void startIndexService() {
- if (container == null) {
- // Only start Elasticsearch once
- container = ElasticContainer.createAndStart(ElasticVersion.V7_8);
- }
- }
-
- @AfterClass
- public static void stopElasticsearchServer() {
- if (container != null) {
- container.stop();
- }
- }
-
- @Override
- protected void initAfterLifecycleStart() throws Exception {
- super.initAfterLifecycleStart();
- ElasticTestUtils.createAllIndexes(injector);
- }
-
- @Override
- protected Injector createInjector() {
- Config elasticsearchConfig = new Config(config);
- InMemoryModule.setDefaults(elasticsearchConfig);
- String indicesPrefix = testName.getSanitizedMethodName();
- ElasticTestUtils.configure(elasticsearchConfig, container, indicesPrefix);
- return Guice.createInjector(new InMemoryModule(elasticsearchConfig));
- }
-}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticVersionTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticVersionTest.java
deleted file mode 100644
index 2ce3a2c118..0000000000
--- a/javatests/com/google/gerrit/elasticsearch/ElasticVersionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2018 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.elasticsearch;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.google.gerrit.testing.GerritJUnit.assertThrows;
-
-import org.junit.Test;
-
-public class ElasticVersionTest {
- @Test
- public void supportedVersion() throws Exception {
- assertThat(ElasticVersion.forVersion("7.6.0")).isEqualTo(ElasticVersion.V7_6);
- assertThat(ElasticVersion.forVersion("7.6.1")).isEqualTo(ElasticVersion.V7_6);
-
- assertThat(ElasticVersion.forVersion("7.7.0")).isEqualTo(ElasticVersion.V7_7);
- assertThat(ElasticVersion.forVersion("7.7.1")).isEqualTo(ElasticVersion.V7_7);
-
- assertThat(ElasticVersion.forVersion("7.8.0")).isEqualTo(ElasticVersion.V7_8);
- assertThat(ElasticVersion.forVersion("7.8.1")).isEqualTo(ElasticVersion.V7_8);
- }
-
- @Test
- public void unsupportedVersion() throws Exception {
- ElasticVersion.UnsupportedVersion thrown =
- assertThrows(
- ElasticVersion.UnsupportedVersion.class, () -> ElasticVersion.forVersion("4.0.0"));
- assertThat(thrown)
- .hasMessageThat()
- .contains(
- "Unsupported version: [4.0.0]. Supported versions: "
- + ElasticVersion.supportedVersions());
- }
-}
diff --git a/lib/LICENSE-elasticsearch b/lib/LICENSE-elasticsearch
deleted file mode 100644
index 23cae9e206..0000000000
--- a/lib/LICENSE-elasticsearch
+++ /dev/null
@@ -1,5 +0,0 @@
-Elasticsearch
-Copyright 2009-2015 Elasticsearch
-
-This product includes software developed by The Apache Software
-Foundation (http://www.apache.org/).
diff --git a/lib/elasticsearch-rest-client/BUILD b/lib/elasticsearch-rest-client/BUILD
deleted file mode 100644
index e323263beb..0000000000
--- a/lib/elasticsearch-rest-client/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-load("@rules_java//java:defs.bzl", "java_library")
-
-package(default_visibility = ["//visibility:public"])
-
-java_library(
- name = "elasticsearch-rest-client",
- data = ["//lib:LICENSE-elasticsearch"],
- exports = ["@elasticsearch-rest-client//jar"],
-)
diff --git a/lib/httpcomponents/BUILD b/lib/httpcomponents/BUILD
index 07d4bb9683..25e09c9cf4 100644
--- a/lib/httpcomponents/BUILD
+++ b/lib/httpcomponents/BUILD
@@ -25,20 +25,3 @@ java_library(
data = ["//lib:LICENSE-Apache2.0"],
exports = ["@httpcore//jar"],
)
-
-java_library(
- name = "httpasyncclient",
- data = ["//lib:LICENSE-Apache2.0"],
- visibility = [
- "//java/com/google/gerrit/elasticsearch:__pkg__",
- "//javatests/com/google/gerrit/elasticsearch:__pkg__",
- ],
- exports = ["@httpasyncclient//jar"],
-)
-
-java_library(
- name = "httpcore-nio",
- data = ["//lib:LICENSE-Apache2.0"],
- visibility = ["//java/com/google/gerrit/elasticsearch:__pkg__"],
- exports = ["@httpcore-nio//jar"],
-)
diff --git a/lib/jackson/BUILD b/lib/jackson/BUILD
index f11b96d876..76c239acf4 100644
--- a/lib/jackson/BUILD
+++ b/lib/jackson/BUILD
@@ -13,7 +13,6 @@ java_library(
data = ["//lib:LICENSE-Apache2.0"],
visibility = [
"//java/com/google/gerrit/acceptance:__pkg__",
- "//java/com/google/gerrit/elasticsearch:__pkg__",
"//plugins:__pkg__",
],
exports = ["@jackson-core//jar"],
diff --git a/lib/log/BUILD b/lib/log/BUILD
index 49667235fa..21c4d471c5 100644
--- a/lib/log/BUILD
+++ b/lib/log/BUILD
@@ -4,7 +4,6 @@ java_library(
name = "api",
data = ["//lib:LICENSE-slf4j"],
visibility = [
- "//javatests/com/google/gerrit/elasticsearch:__pkg__",
"//lib:__pkg__",
"//plugins:__pkg__",
],
diff --git a/lib/nongoogle_test.sh b/lib/nongoogle_test.sh
index 591e76e391..0066ca717e 100755
--- a/lib/nongoogle_test.sh
+++ b/lib/nongoogle_test.sh
@@ -26,8 +26,6 @@ guava
guice-assistedinject
guice-library
guice-servlet
-httpasyncclient
-httpcore-nio
j2objc
jackson-annotations
jackson-core
diff --git a/lib/testcontainers/BUILD b/lib/testcontainers/BUILD
index 693a386b40..e8c107c4d1 100644
--- a/lib/testcontainers/BUILD
+++ b/lib/testcontainers/BUILD
@@ -53,12 +53,3 @@ java_library(
"//lib/log:ext",
],
)
-
-java_library(
- name = "testcontainers-elasticsearch",
- testonly = True,
- data = ["//lib:LICENSE-testcontainers"],
- visibility = ["//visibility:public"],
- exports = ["@testcontainers-elasticsearch//jar"],
- runtime_deps = [":testcontainers"],
-)
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD
index 61ea4feeba..cd9f132828 100644
--- a/tools/eclipse/BUILD
+++ b/tools/eclipse/BUILD
@@ -9,7 +9,6 @@ load(
)
TEST_DEPS = [
- "//javatests/com/google/gerrit/elasticsearch:elasticsearch_test_utils",
"//javatests/com/google/gerrit/server:server_tests",
]
diff --git a/tools/nongoogle.bzl b/tools/nongoogle.bzl
index b1ebb5c879..38c8c2b73e 100644
--- a/tools/nongoogle.bzl
+++ b/tools/nongoogle.bzl
@@ -67,20 +67,6 @@ def declare_nongoogle_deps():
sha1 = "d22138ba75dee95e2123f0e53a9c514b2a766da9",
)
- # elasticsearch-rest-client explicitly depends on this version
- maven_jar(
- name = "httpasyncclient",
- artifact = "org.apache.httpcomponents:httpasyncclient:4.1.4",
- sha1 = "f3a3240681faae3fa46b573a4c7e50cec9db0d86",
- )
-
- # elasticsearch-rest-client explicitly depends on this version
- maven_jar(
- name = "httpcore-nio",
- artifact = "org.apache.httpcomponents:httpcore-nio:4.4.12",
- sha1 = "84cd29eca842f31db02987cfedea245af020198b",
- )
-
maven_jar(
name = "openid-consumer",
artifact = "org.openid4java:openid4java:1.0.0",
diff --git a/tools/release_noter/release_noter.py b/tools/release_noter/release_noter.py
index 73c1a0561d..167f68a4ef 100644
--- a/tools/release_noter/release_noter.py
+++ b/tools/release_noter/release_noter.py
@@ -172,7 +172,6 @@ class Components(Enum):
)
doc = Component("Documentation", {"document"})
jgit = Component("JGit", {"jgit"})
- elastic = Component("Elasticsearch", {"elastic"})
deps = Component("Other dependency", {"upgrade", "dependenc"})
otherwise = Component("Other core", {})