Merge branch 'stable-3.1' into stable-3.2 * stable-3.1: Remove the terms slave and master Respect container.replica option for Gerrit replica Format with google-java-format 1.7 Change-Id: Ic8271d79467caeda0d58926bc6209204e8eba8ee
diff --git a/README.md b/README.md index e5ad599..af7fc3f 100644 --- a/README.md +++ b/README.md
@@ -25,9 +25,9 @@ ## How to install Copy the healthcheck.jar into the Gerrit's /plugins directory and wait for the plugin to be automatically loaded. -The healthcheck plugin is compatible with both Gerrit master and slave setups. The only difference to bear in mind -is that some checks may not be successful on slaves (e.g. query changes) because the associated subsystem is switched -off. +The healthcheck plugin is compatible with both primary Gerrit setups and Gerrit replicas. The only difference to bear +in mind is that some checks may not be successful on replicas (e.g. query changes) because the associated subsystem is +switched off. ## How to use
diff --git a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HttpModule.java index c62a261..5217dff 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HttpModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/healthcheck/HttpModule.java
@@ -16,24 +16,23 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.httpd.AllRequestFilter; -import com.google.gerrit.server.config.GerritServerConfig; +import com.google.gerrit.server.config.GerritIsReplica; import com.google.inject.Inject; import com.google.inject.Scopes; import com.google.inject.servlet.ServletModule; import com.googlesource.gerrit.plugins.healthcheck.filter.HealthCheckStatusFilter; -import org.eclipse.jgit.lib.Config; public class HttpModule extends ServletModule { - private boolean isSlave; + private boolean isReplica; @Inject - public HttpModule(@GerritServerConfig Config gerritConfig) { - isSlave = gerritConfig.getBoolean("container", "slave", false); + public HttpModule(@GerritIsReplica boolean isReplica) { + this.isReplica = isReplica; } @Override protected void configureServlets() { - if (isSlave) { + if (isReplica) { DynamicSet.bind(binder(), AllRequestFilter.class) .to(HealthCheckStatusFilter.class) .in(Scopes.SINGLETON);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/DeadlockCheckTest.java b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/DeadlockCheckTest.java index 01a1147..d53a1d8 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/healthcheck/DeadlockCheckTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/healthcheck/DeadlockCheckTest.java
@@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; import static com.googlesource.gerrit.plugins.healthcheck.HealthCheckConfig.DEFAULT_CONFIG; -import static com.googlesource.gerrit.plugins.healthcheck.check.HealthCheckNames.DEADLOCK; import com.codahale.metrics.Gauge; import com.codahale.metrics.MetricRegistry; @@ -71,7 +70,6 @@ assertThat(check.run().result).isEqualTo(Result.FAILED); } - private Injector testInjector(AbstractModule testModule) { return Guice.createInjector(new HealthCheckModule(), testModule); }