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
This commit is contained in:
David Pursehouse 2020-03-19 12:43:33 +09:00
commit 8eb05d3401
7 changed files with 115 additions and 5 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -8,6 +8,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//lib:gson",
"//lib/flogger:api",
"//lib/log:log4j",
],
)

View File

@ -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();
}
}
}

View File

@ -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",