summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2020-03-19 12:43:33 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2020-03-19 12:43:33 +0900
commit8eb05d340163ff19dedbd0786190145aea037425 (patch)
tree4d69438efbe80aec0dbeadb5515ca4d17a1356b6
parent829662754b29e804ec7362e3c8bc8cffe876d82d (diff)
parent584cc95214dec158c371969652d31095f3349591 (diff)
Merge branch 'stable-3.0' into stable-3.1
* stable-3.0: Set version to 2.16.18-SNAPSHOT Set version to 2.16.17 Schema_151: Attempt to add created_on column if it doesn't exist Update documentation links of 'numberOfShards' and 'numberOfReplicas' Support 'max_result_window' config for Elasticsearch indexes Add Zuul config Fix a typo in gr-file-list.js: dynmic -> dynamic Support displaying dynamic headers in gr-file-list Support displaying dynamic content and summary cells in gr-file-list Add headers to gr-file-list Add Zuul config Document dependency from account deactivator to autoUpdateAccountActiveStatus Introduce NamedFluentLogger Change-Id: I4eaf94df9b512fb7b36db4ac4741b32b001e21b5
-rw-r--r--Documentation/config-gerrit.txt16
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticConfiguration.java6
-rw-r--r--java/com/google/gerrit/elasticsearch/ElasticSetting.java2
-rw-r--r--java/com/google/gerrit/server/account/AccountDeactivator.java10
-rw-r--r--java/com/google/gerrit/util/logging/BUILD1
-rw-r--r--java/com/google/gerrit/util/logging/NamedFluentLogger.java84
-rw-r--r--plugins/BUILD1
7 files changed, 115 insertions, 5 deletions
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 41480a5cc4..a1ed6e1496 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -3021,7 +3021,7 @@ 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/getting-started-concepts.html#getting-started-shards-and-replicas[
+link:https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#_static_index_settings[
Elasticsearch documentation] for details.
+
Defaults to 5 for Elasticsearch versions 5 and 6, and to 1 starting with Elasticsearch 7.
@@ -3029,11 +3029,19 @@ Defaults to 5 for Elasticsearch versions 5 and 6, and to 1 starting with Elastic
[[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/getting-started-concepts.html#getting-started-shards-and-replicas[
+link:https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#dynamic-index-settings[
Elasticsearch documentation] 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] for details.
++
+Defaults to 10000.
+
==== Elasticsearch Security
When security is enabled in Elasticsearch, the username and password must be provided.
@@ -4904,6 +4912,10 @@ account deactivations.
The link:#schedule-configuration-interval[interval] for running
account deactivations.
+Note that the task will only be scheduled if the
+link:#autoUpdateAccountActiveStatus[auth.autoUpdateAccountActiveStatus]
+is set to true.
+
link:#schedule-configuration-examples[Schedule examples] can be found
in the link:#schedule-configuration[Schedule Configuration] section.
diff --git a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java b/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
index cbe9bc73d0..35c33cb9b4 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticConfiguration.java
@@ -40,10 +40,13 @@ class ElasticConfiguration {
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 DEFAULT_PORT = "9200";
static final String DEFAULT_USERNAME = "elastic";
static final int DEFAULT_NUMBER_OF_SHARDS = 0;
static final int DEFAULT_NUMBER_OF_REPLICAS = 1;
+ static final int DEFAULT_MAX_RESULT_WINDOW = 10000;
private final Config cfg;
private final List<HttpHost> hosts;
@@ -52,6 +55,7 @@ class ElasticConfiguration {
final String password;
final int numberOfShards;
final int numberOfReplicas;
+ final int maxResultWindow;
final String prefix;
@Inject
@@ -68,6 +72,8 @@ class ElasticConfiguration {
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.hosts = new ArrayList<>();
for (String server : cfg.getStringList(SECTION_ELASTICSEARCH, null, KEY_SERVER)) {
try {
diff --git a/java/com/google/gerrit/elasticsearch/ElasticSetting.java b/java/com/google/gerrit/elasticsearch/ElasticSetting.java
index 14e462342d..e016efb94e 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticSetting.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticSetting.java
@@ -35,6 +35,7 @@ class ElasticSetting {
properties.analysis = fields.build();
properties.numberOfShards = config.getNumberOfShards(adapter);
properties.numberOfReplicas = config.numberOfReplicas;
+ properties.maxResultWindow = config.maxResultWindow;
return properties;
}
@@ -75,6 +76,7 @@ class ElasticSetting {
Map<String, FieldProperties> analysis;
Integer numberOfShards;
Integer numberOfReplicas;
+ Integer maxResultWindow;
}
static class FieldProperties {
diff --git a/java/com/google/gerrit/server/account/AccountDeactivator.java b/java/com/google/gerrit/server/account/AccountDeactivator.java
index 3465459102..b12e585131 100644
--- a/java/com/google/gerrit/server/account/AccountDeactivator.java
+++ b/java/com/google/gerrit/server/account/AccountDeactivator.java
@@ -57,10 +57,14 @@ public class AccountDeactivator implements Runnable {
@Override
public void start() {
- if (!supportAutomaticAccountActivityUpdate) {
- return;
+ if (schedule.isPresent()) {
+ if (supportAutomaticAccountActivityUpdate) {
+ queue.scheduleAtFixedRate(deactivator, schedule.get());
+ } else {
+ logger.atWarning().log(
+ "Not scheduling AccountDeactivator because auth.autoUpdateAccountActiveStatus is false");
+ }
}
- schedule.ifPresent(s -> queue.scheduleAtFixedRate(deactivator, s));
}
@Override
diff --git a/java/com/google/gerrit/util/logging/BUILD b/java/com/google/gerrit/util/logging/BUILD
index b8db49bdc6..ee598a436f 100644
--- a/java/com/google/gerrit/util/logging/BUILD
+++ b/java/com/google/gerrit/util/logging/BUILD
@@ -8,6 +8,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//lib:gson",
+ "//lib/flogger:api",
"//lib/log:log4j",
],
)
diff --git a/java/com/google/gerrit/util/logging/NamedFluentLogger.java b/java/com/google/gerrit/util/logging/NamedFluentLogger.java
new file mode 100644
index 0000000000..04fc18df74
--- /dev/null
+++ b/java/com/google/gerrit/util/logging/NamedFluentLogger.java
@@ -0,0 +1,84 @@
+// Copyright (C) 2020 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.util.logging;
+
+import com.google.common.flogger.AbstractLogger;
+import com.google.common.flogger.LogContext;
+import com.google.common.flogger.LoggingApi;
+import com.google.common.flogger.backend.LoggerBackend;
+import com.google.common.flogger.backend.Platform;
+import com.google.common.flogger.parser.DefaultPrintfMessageParser;
+import com.google.common.flogger.parser.MessageParser;
+import java.util.logging.Level;
+
+/**
+ * FluentLogger.forEnclosingClass() searches for caller class name and passes it as String to
+ * constructor FluentLogger.FluentLogger(LoggerBackend) (which is package protected).
+ *
+ * <p>This allows to create NamedFluentLogger with given name so that dedicated configuration can be
+ * specified by a custom appender in the log4j.properties file. An example of this is the logger
+ * used by the replication queue in the replication plugin, and gerrit's Garbage Collection log.
+ */
+public class NamedFluentLogger extends AbstractLogger<NamedFluentLogger.Api> {
+ /** Copied from FluentLogger */
+ public interface Api extends LoggingApi<Api> {}
+
+ /** Copied from FluentLogger */
+ private static final class NoOp extends LoggingApi.NoOp<Api> implements Api {}
+
+ private static final NoOp NO_OP = new NoOp();
+
+ public static NamedFluentLogger forName(String name) {
+ return new NamedFluentLogger(Platform.getBackend(name));
+ }
+
+ private NamedFluentLogger(LoggerBackend backend) {
+ super(backend);
+ }
+
+ @Override
+ public Api at(Level level) {
+ boolean isLoggable = isLoggable(level);
+ boolean isForced = Platform.shouldForceLogging(getName(), level, isLoggable);
+ return (isLoggable || isForced) ? new Context(level, isForced) : NO_OP;
+ }
+
+ /** Copied from FluentLogger */
+ private final class Context extends LogContext<NamedFluentLogger, Api> implements Api {
+ private Context(Level level, boolean isForced) {
+ super(level, isForced);
+ }
+
+ @Override
+ protected NamedFluentLogger getLogger() {
+ return NamedFluentLogger.this;
+ }
+
+ @Override
+ protected Api api() {
+ return this;
+ }
+
+ @Override
+ protected Api noOp() {
+ return NO_OP;
+ }
+
+ @Override
+ protected MessageParser getMessageParser() {
+ return DefaultPrintfMessageParser.getInstance();
+ }
+ }
+}
diff --git a/plugins/BUILD b/plugins/BUILD
index 8d9682fadf..5f9c1426e2 100644
--- a/plugins/BUILD
+++ b/plugins/BUILD
@@ -54,6 +54,7 @@ EXPORTS = [
"//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/util/cli",
"//java/com/google/gerrit/util/http",
+ "//java/com/google/gerrit/util/logging",
"//lib/antlr:java-runtime",
"//lib/auto:auto-value-annotations",
"//lib/commons:compress",