Merge "Fix JavaDoc of AcceptsDelete"
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 2737f58..4c1766f 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -3009,41 +3009,13 @@
+
Not set by default.
-[[elasticsearch.requestCompression]]elasticsearch.requestCompression::
+[[elasticsearch.maxRetryTimeout]]elasticsearch.maxRetryTimeout::
+
-Enable request compression.
-+
-Defaults to `false`.
-
-[[elasticsearch.connectionTimeout]]elasticsearch.connectionTimeout::
-+
-How long should Gerrit waits for connection.
+Sets the maximum timeout to honor in case of multiple retries of the same request.
+
The value is in the usual time-unit format like `1 m`, `5 m`.
+
-Defaults to `5 m`
-
-[[elasticsearch.maxConnectionIdleTime]]elasticsearch.maxConnectionIdleTime::
-+
-How long connection can stay in idle.
-+
-The value is in the usual time-unit format like `1 m`, `5 m`.
-+
-Defaults to `5 m`
-
-[[elasticsearch.maxTotalConnection]]elasticsearch.maxTotalConnection::
-+
-How many connections can be spawned simultaneously.
-+
-Defaults to `1`
-
-[[elasticsearch.maxReadTimeout]]elasticsearch.maxReadTimeout::
-+
-Timeout for read operations.
-+
-The value is in the usual time-unit format like `1 m`, `5 m`.
-+
-Defaults to `5 m`
+Defaults to `30000 ms`.
==== Elasticsearch server(s) configuration
@@ -3058,7 +3030,7 @@
[[elasticsearch.name.hostname]]elasticsearch.name.hostname::
+
Elasticsearch server hostname.
-
++
Defaults to `localhost`.
[[elasticsearch.name.port]]elasticsearch.name.port::
diff --git a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java b/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
index 20c3427..0148bf1 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
@@ -37,15 +37,11 @@
private static final String DEFAULT_PROTOCOL = "http";
private final Config cfg;
+ private final List<HttpHost> hosts;
- final List<HttpHost> hosts;
final String username;
final String password;
- final boolean requestCompression;
- final long connectionTimeout;
- final long maxConnectionIdleTime;
- final int maxTotalConnection;
- final int readTimeout;
+ final int maxRetryTimeout;
final String prefix;
@Inject
@@ -53,15 +49,9 @@
this.cfg = cfg;
this.username = cfg.getString("elasticsearch", null, "username");
this.password = cfg.getString("elasticsearch", null, "password");
- this.requestCompression = cfg.getBoolean("elasticsearch", null, "requestCompression", false);
- this.connectionTimeout =
- cfg.getTimeUnit("elasticsearch", null, "connectionTimeout", 3000, TimeUnit.MILLISECONDS);
- this.maxConnectionIdleTime =
- cfg.getTimeUnit(
- "elasticsearch", null, "maxConnectionIdleTime", 3000, TimeUnit.MILLISECONDS);
- this.maxTotalConnection = cfg.getInt("elasticsearch", null, "maxTotalConnection", 1);
- this.readTimeout =
- (int) cfg.getTimeUnit("elasticsearch", null, "readTimeout", 3000, TimeUnit.MICROSECONDS);
+ this.maxRetryTimeout =
+ (int)
+ cfg.getTimeUnit("elasticsearch", null, "maxRetryTimeout", 30000, TimeUnit.MILLISECONDS);
this.prefix = Strings.nullToEmpty(cfg.getString("elasticsearch", null, "prefix"));
Set<String> subsections = cfg.getSubsections("elasticsearch");
@@ -88,6 +78,10 @@
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);
}
diff --git a/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java b/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java
index e318d61..db59257 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticRestClientProvider.java
@@ -22,8 +22,6 @@
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.io.IOException;
-import java.util.List;
-import org.apache.http.HttpHost;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
@@ -39,18 +37,14 @@
class ElasticRestClientProvider implements Provider<RestClient>, LifecycleListener {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private final List<HttpHost> hosts;
- private final String username;
- private final String password;
+ private final ElasticConfiguration cfg;
private RestClient client;
private ElasticQueryAdapter adapter;
@Inject
ElasticRestClientProvider(ElasticConfiguration cfg) {
- hosts = cfg.hosts;
- username = cfg.username;
- password = cfg.password;
+ this.cfg = cfg;
}
public static LifecycleModule module() {
@@ -132,12 +126,15 @@
}
private RestClient build() {
- RestClientBuilder builder = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()]));
+ RestClientBuilder builder = RestClient.builder(cfg.getHosts());
+ builder.setMaxRetryTimeoutMillis(cfg.maxRetryTimeout);
setConfiguredCredentialsIfAny(builder);
return builder.build();
}
private void setConfiguredCredentialsIfAny(RestClientBuilder builder) {
+ String username = cfg.username;
+ String password = cfg.password;
if (username != null && password != null) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
diff --git a/java/com/google/gerrit/server/notedb/CommentJsonMigrator.java b/java/com/google/gerrit/server/notedb/CommentJsonMigrator.java
index 44cf02fb..9a9a211 100644
--- a/java/com/google/gerrit/server/notedb/CommentJsonMigrator.java
+++ b/java/com/google/gerrit/server/notedb/CommentJsonMigrator.java
@@ -66,7 +66,7 @@
Project.NameKey project, Repository repo, RevWalk rw, ObjectInserter ins, BatchRefUpdate bru)
throws IOException {
boolean ok = true;
- for (Ref ref : repo.getRefDatabase().getRefs(RefNames.REFS_CHANGES).values()) {
+ for (Ref ref : repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_CHANGES)) {
Change.Id changeId = Change.Id.fromRef(ref.getName());
if (changeId == null || !ref.getName().equals(RefNames.changeMetaRef(changeId))) {
continue;
@@ -84,7 +84,7 @@
BatchRefUpdate bru)
throws IOException {
boolean ok = true;
- for (Ref ref : allUsersRepo.getRefDatabase().getRefs(RefNames.REFS_DRAFT_COMMENTS).values()) {
+ for (Ref ref : allUsersRepo.getRefDatabase().getRefsByPrefix(RefNames.REFS_DRAFT_COMMENTS)) {
Change.Id changeId = Change.Id.fromAllUsersRef(ref.getName());
if (changeId == null) {
continue;