diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-08-28 15:26:54 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-13 15:50:47 +0200 |
commit | b92dfb667ce7ee17ce692ae33d2e5acfe19a2831 (patch) | |
tree | 7e3161aa408145770bcd5792729d5f876808000e | |
parent | a27b49327ffe7e55a5ec9c94d3c2a30b0c8e7433 (diff) | |
download | sonarqube-b92dfb667ce7ee17ce692ae33d2e5acfe19a2831.tar.gz sonarqube-b92dfb667ce7ee17ce692ae33d2e5acfe19a2831.zip |
SONAR-9755 rename HealthCheck to NodeHealthCheck
17 files changed, 72 insertions, 72 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/CeStatusCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/CeStatusNodeCheck.java index 1d457f416fd..7fa5c2cf4a3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/CeStatusCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/CeStatusNodeCheck.java @@ -23,7 +23,7 @@ import org.sonar.server.app.ProcessCommandWrapper; import static org.sonar.server.health.Health.newHealthCheckBuilder; -public class CeStatusCheck implements HealthCheck { +public class CeStatusNodeCheck implements NodeHealthCheck { private static final Health RED_HEALTH = newHealthCheckBuilder() .setStatus(Health.Status.RED) .addCause("Compute Engine is not operational") @@ -31,7 +31,7 @@ public class CeStatusCheck implements HealthCheck { private final ProcessCommandWrapper processCommandWrapper; - public CeStatusCheck(ProcessCommandWrapper processCommandWrapper) { + public CeStatusNodeCheck(ProcessCommandWrapper processCommandWrapper) { this.processCommandWrapper = processCommandWrapper; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/DbConnectionCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/DbConnectionNodeCheck.java index 7d43d29f0ae..671e96e1993 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/DbConnectionCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/DbConnectionNodeCheck.java @@ -30,13 +30,13 @@ import static org.sonar.server.health.Health.newHealthCheckBuilder; /** * Checks Web Server can connect to the Database. */ -public class DbConnectionCheck implements HealthCheck { - private static final Logger LOGGER = Loggers.get(DbConnectionCheck.class); +public class DbConnectionNodeCheck implements NodeHealthCheck { + private static final Logger LOGGER = Loggers.get(DbConnectionNodeCheck.class); private static final Health RED_HEALTH = newHealthCheckBuilder().setStatus(Health.Status.RED).addCause("Can't connect to DB").build(); private final DbClient dbClient; - public DbConnectionCheck(DbClient dbClient) { + public DbConnectionNodeCheck(DbClient dbClient) { this.dbClient = dbClient; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/EsStatusCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/EsStatusNodeCheck.java index cdf086082c9..34d190de136 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/EsStatusCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/EsStatusNodeCheck.java @@ -27,7 +27,7 @@ import static org.sonar.server.health.Health.newHealthCheckBuilder; /** * Checks the ElasticSearch cluster status. */ -public class EsStatusCheck implements HealthCheck { +public class EsStatusNodeCheck implements NodeHealthCheck { private static final Health YELLOW_HEALTH = newHealthCheckBuilder() .setStatus(Health.Status.YELLOW) .addCause("Elasticsearch status is YELLOW") @@ -39,7 +39,7 @@ public class EsStatusCheck implements HealthCheck { private final EsClient esClient; - public EsStatusCheck(EsClient esClient) { + public EsStatusNodeCheck(EsClient esClient) { this.esClient = esClient; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java index f10e890d277..0904003062e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheckerImpl.java @@ -27,19 +27,19 @@ import java.util.stream.Stream; import static org.sonar.server.health.Health.newHealthCheckBuilder; /** - * Implementation of {@link HealthChecker} that executes implementations of {@link HealthCheck} in the container + * Implementation of {@link HealthChecker} that executes implementations of {@link NodeHealthCheck} in the container * and aggregates their results. */ public class HealthCheckerImpl implements HealthChecker { - private final List<HealthCheck> healthChecks; + private final List<NodeHealthCheck> nodeHealthChecks; - public HealthCheckerImpl(HealthCheck... healthChecks) { - this.healthChecks = Arrays.asList(healthChecks); + public HealthCheckerImpl(NodeHealthCheck... nodeHealthChecks) { + this.nodeHealthChecks = Arrays.asList(nodeHealthChecks); } @Override public Health checkNode() { - return healthChecks.stream().map(HealthCheck::check) + return nodeHealthChecks.stream().map(NodeHealthCheck::check) .reduce(Health.GREEN, HealthReducer.INSTANCE); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthCheck.java index f52f9225003..79e1b21bd63 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/HealthCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/NodeHealthCheck.java @@ -19,6 +19,6 @@ */ package org.sonar.server.health; -public interface HealthCheck { +public interface NodeHealthCheck { Health check(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/WebServerSafemodeCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/WebServerSafemodeNodeCheck.java index 09a1cdc2e46..4e35b52d1bf 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/WebServerSafemodeCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/WebServerSafemodeNodeCheck.java @@ -25,7 +25,7 @@ import static org.sonar.server.health.Health.newHealthCheckBuilder; * Checks the running status of the WebServer when the WebServer is in safemode. * Obviously, it statically returns a red health status. */ -public class WebServerSafemodeCheck implements HealthCheck { +public class WebServerSafemodeNodeCheck implements NodeHealthCheck { private static final Health RED_HEALTH = newHealthCheckBuilder() .setStatus(Health.Status.RED) diff --git a/server/sonar-server/src/main/java/org/sonar/server/health/WebServerStatusCheck.java b/server/sonar-server/src/main/java/org/sonar/server/health/WebServerStatusNodeCheck.java index 2146a315d4d..b542629c0f9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/health/WebServerStatusCheck.java +++ b/server/sonar-server/src/main/java/org/sonar/server/health/WebServerStatusNodeCheck.java @@ -29,7 +29,7 @@ import static org.sonar.server.health.Health.newHealthCheckBuilder; /** * Checks the running status of the WebServer when it is not anymore in safemode. */ -public class WebServerStatusCheck implements HealthCheck { +public class WebServerStatusNodeCheck implements NodeHealthCheck { private static final EnumSet<DatabaseMigrationState.Status> VALID_DATABASEMIGRATION_STATUSES = EnumSet.of( DatabaseMigrationState.Status.NONE, DatabaseMigrationState.Status.SUCCEEDED); @@ -37,7 +37,7 @@ public class WebServerStatusCheck implements HealthCheck { private final Platform platform; private final RestartFlagHolder restartFlagHolder; - public WebServerStatusCheck(DatabaseMigrationState migrationState, Platform platform, RestartFlagHolder restartFlagHolder) { + public WebServerStatusNodeCheck(DatabaseMigrationState migrationState, Platform platform, RestartFlagHolder restartFlagHolder) { this.migrationState = migrationState; this.platform = platform; this.restartFlagHolder = restartFlagHolder; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java index 8c9144b4407..2dad8eaf37f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java @@ -20,21 +20,21 @@ package org.sonar.server.platform.ws; import org.sonar.core.platform.Module; -import org.sonar.server.health.CeStatusCheck; -import org.sonar.server.health.DbConnectionCheck; -import org.sonar.server.health.EsStatusCheck; +import org.sonar.server.health.CeStatusNodeCheck; +import org.sonar.server.health.DbConnectionNodeCheck; +import org.sonar.server.health.EsStatusNodeCheck; import org.sonar.server.health.HealthCheckerImpl; -import org.sonar.server.health.WebServerStatusCheck; +import org.sonar.server.health.WebServerStatusNodeCheck; public class HealthActionModule extends Module { @Override protected void configureModule() { add( - // HealthCheck implementations - WebServerStatusCheck.class, - DbConnectionCheck.class, - EsStatusCheck.class, - CeStatusCheck.class, + // NodeHealthCheck implementations + WebServerStatusNodeCheck.class, + DbConnectionNodeCheck.class, + EsStatusNodeCheck.class, + CeStatusNodeCheck.class, HealthCheckerImpl.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java index 5a950a02fbb..364fb802eba 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java @@ -20,19 +20,19 @@ package org.sonar.server.platform.ws; import org.sonar.core.platform.Module; -import org.sonar.server.health.DbConnectionCheck; -import org.sonar.server.health.EsStatusCheck; +import org.sonar.server.health.DbConnectionNodeCheck; +import org.sonar.server.health.EsStatusNodeCheck; import org.sonar.server.health.HealthCheckerImpl; -import org.sonar.server.health.WebServerSafemodeCheck; +import org.sonar.server.health.WebServerSafemodeNodeCheck; public class SafeModeHealthActionModule extends Module { @Override protected void configureModule() { add( - // HealthCheck implementations - WebServerSafemodeCheck.class, - DbConnectionCheck.class, - EsStatusCheck.class, + // NodeHealthCheck implementations + WebServerSafemodeNodeCheck.class, + DbConnectionNodeCheck.class, + EsStatusNodeCheck.class, HealthCheckerImpl.class, HealthAction.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/CeStatusCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/CeStatusNodeCheckTest.java index 6de6f017331..1c83f05a7c4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/CeStatusCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/CeStatusNodeCheckTest.java @@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class CeStatusCheckTest { +public class CeStatusNodeCheckTest { private ProcessCommandWrapper processCommandWrapper = mock(ProcessCommandWrapper.class); - private CeStatusCheck underTest = new CeStatusCheck(processCommandWrapper); + private CeStatusNodeCheck underTest = new CeStatusNodeCheck(processCommandWrapper); @Test public void check_returns_GREEN_status_without_cause_if_ce_is_operational() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/DbConnectionCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/DbConnectionNodeCheckTest.java index 41b8c3acd51..fc87a374dd7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/DbConnectionCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/DbConnectionNodeCheckTest.java @@ -30,12 +30,12 @@ import static org.mockito.Matchers.anyBoolean; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class DbConnectionCheckTest { +public class DbConnectionNodeCheckTest { private DbClient dbClient = mock(DbClient.class); private DbSession dbSession = mock(DbSession.class); private IsAliveMapper isAliveMapper = mock(IsAliveMapper.class); - private DbConnectionCheck underTest = new DbConnectionCheck(dbClient); + private DbConnectionNodeCheck underTest = new DbConnectionNodeCheck(dbClient); @Before public void wireMocks() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusNodeCheckTest.java index 0f8f0183843..465ea1427b3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/EsStatusNodeCheckTest.java @@ -25,12 +25,12 @@ import org.sonar.server.es.EsTester; import static org.assertj.core.api.Assertions.assertThat; -public class EsStatusCheckTest { +public class EsStatusNodeCheckTest { @Rule public EsTester esTester = new EsTester(); - private EsStatusCheck underTest = new EsStatusCheck(esTester.client()); + private EsStatusNodeCheck underTest = new EsStatusNodeCheck(esTester.client()); @Test public void check_returns_GREEN_without_cause_if_ES_cluster_status_is_GREEN() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java index e206098d74e..b97df9224c2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java @@ -89,30 +89,30 @@ public class HealthCheckerImplTest { @Test public void checkNode_returns_causes_of_all_HealthChecks_whichever_their_status() { - HealthCheck[] healthChecks = IntStream.range(0, 1 + random.nextInt(20)) - .mapToObj(s -> new StaticHealthCheck(IntStream.range(0, random.nextInt(3)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).toArray(String[]::new))) - .map(HealthCheck.class::cast) - .toArray(HealthCheck[]::new); - String[] expected = Arrays.stream(healthChecks).map(HealthCheck::check).flatMap(s -> s.getCauses().stream()).toArray(String[]::new); + NodeHealthCheck[] nodeHealthChecks = IntStream.range(0, 1 + random.nextInt(20)) + .mapToObj(s -> new HardcodedHealthNodeCheck(IntStream.range(0, random.nextInt(3)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).toArray(String[]::new))) + .map(NodeHealthCheck.class::cast) + .toArray(NodeHealthCheck[]::new); + String[] expected = Arrays.stream(nodeHealthChecks).map(NodeHealthCheck::check).flatMap(s -> s.getCauses().stream()).toArray(String[]::new); - HealthCheckerImpl underTest = new HealthCheckerImpl(healthChecks); + HealthCheckerImpl underTest = new HealthCheckerImpl(nodeHealthChecks); assertThat(underTest.checkNode().getCauses()).containsOnly(expected); } private HealthCheckerImpl newHealthCheckerImpl(Stream<Health.Status> statuses) { - Stream<StaticHealthCheck> staticHealthCheckStream = statuses.map(StaticHealthCheck::new); - return new HealthCheckerImpl(staticHealthCheckStream.map(HealthCheck.class::cast).toArray(HealthCheck[]::new)); + Stream<HardcodedHealthNodeCheck> staticHealthCheckStream = statuses.map(HardcodedHealthNodeCheck::new); + return new HealthCheckerImpl(staticHealthCheckStream.map(NodeHealthCheck.class::cast).toArray(NodeHealthCheck[]::new)); } - private class StaticHealthCheck implements HealthCheck { + private class HardcodedHealthNodeCheck implements NodeHealthCheck { private final Health health; - public StaticHealthCheck(Health.Status status) { + public HardcodedHealthNodeCheck(Health.Status status) { this.health = Health.newHealthCheckBuilder().setStatus(status).build(); } - public StaticHealthCheck(String... causes) { + public HardcodedHealthNodeCheck(String... causes) { Health.Builder builder = Health.newHealthCheckBuilder().setStatus(Health.Status.values()[random.nextInt(3)]); Stream.of(causes).forEach(builder::addCause); this.health = builder.build(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/WebServerSafemodeCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/WebServerSafemodeNodeCheckTest.java index 255ed328bc6..b448ac0197e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/WebServerSafemodeCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/WebServerSafemodeNodeCheckTest.java @@ -23,8 +23,8 @@ import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -public class WebServerSafemodeCheckTest { - private WebServerSafemodeCheck underTest = new WebServerSafemodeCheck(); +public class WebServerSafemodeNodeCheckTest { + private WebServerSafemodeNodeCheck underTest = new WebServerSafemodeNodeCheck(); @Test public void always_returns_RED_status_with_cause() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/health/WebServerStatusCheckTest.java b/server/sonar-server/src/test/java/org/sonar/server/health/WebServerStatusNodeCheckTest.java index 8047c5ce3d9..317a1885673 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/health/WebServerStatusCheckTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/health/WebServerStatusNodeCheckTest.java @@ -30,14 +30,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class WebServerStatusCheckTest { +public class WebServerStatusNodeCheckTest { private final DatabaseMigrationState migrationState = mock(DatabaseMigrationState.class); private final Platform platform = mock(Platform.class); private final RestartFlagHolder restartFlagHolder = mock(RestartFlagHolder.class); private final Random random = new Random(); - private WebServerStatusCheck underTest = new WebServerStatusCheck(migrationState, platform, restartFlagHolder); + private WebServerStatusNodeCheck underTest = new WebServerStatusNodeCheck(migrationState, platform, restartFlagHolder); @Test public void returns_RED_status_with_cause_if_platform_status_is_not_UP() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java index 25489794d54..f4bc59280d4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java @@ -25,12 +25,12 @@ import java.util.stream.Collectors; import org.junit.Test; import org.picocontainer.ComponentAdapter; import org.sonar.core.platform.ComponentContainer; -import org.sonar.server.health.CeStatusCheck; -import org.sonar.server.health.DbConnectionCheck; -import org.sonar.server.health.EsStatusCheck; -import org.sonar.server.health.HealthCheck; +import org.sonar.server.health.CeStatusNodeCheck; +import org.sonar.server.health.DbConnectionNodeCheck; +import org.sonar.server.health.EsStatusNodeCheck; import org.sonar.server.health.HealthCheckerImpl; -import org.sonar.server.health.WebServerStatusCheck; +import org.sonar.server.health.NodeHealthCheck; +import org.sonar.server.health.WebServerStatusNodeCheck; import static org.assertj.core.api.Assertions.assertThat; @@ -49,18 +49,18 @@ public class HealthActionModuleTest { } @Test - public void verify_installed_HealthChecks_implementations() { + public void verify_installed_NodeHealthChecks_implementations() { ComponentContainer container = new ComponentContainer(); underTest.configure(container); - List<Class<?>> checks = classesAddedToContainer(container).stream().filter(HealthCheck.class::isAssignableFrom).collect(Collectors.toList()); + List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList()); assertThat(checks) .hasSize(4) - .contains(WebServerStatusCheck.class) - .contains(DbConnectionCheck.class) - .contains(EsStatusCheck.class) - .contains(CeStatusCheck.class); + .contains(WebServerStatusNodeCheck.class) + .contains(DbConnectionNodeCheck.class) + .contains(EsStatusNodeCheck.class) + .contains(CeStatusNodeCheck.class); } private List<Class<?>> classesAddedToContainer(ComponentContainer container) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java index a6e9f01e112..896e35ed0a7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java @@ -25,11 +25,11 @@ import java.util.stream.Collectors; import org.junit.Test; import org.picocontainer.ComponentAdapter; import org.sonar.core.platform.ComponentContainer; -import org.sonar.server.health.DbConnectionCheck; -import org.sonar.server.health.EsStatusCheck; -import org.sonar.server.health.HealthCheck; +import org.sonar.server.health.DbConnectionNodeCheck; +import org.sonar.server.health.EsStatusNodeCheck; import org.sonar.server.health.HealthCheckerImpl; -import org.sonar.server.health.WebServerSafemodeCheck; +import org.sonar.server.health.NodeHealthCheck; +import org.sonar.server.health.WebServerSafemodeNodeCheck; import static org.assertj.core.api.Assertions.assertThat; @@ -53,12 +53,12 @@ public class SafeModeHealthActionModuleTest { underTest.configure(container); - List<Class<?>> checks = classesAddedToContainer(container).stream().filter(HealthCheck.class::isAssignableFrom).collect(Collectors.toList()); + List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList()); assertThat(checks) .hasSize(3) - .contains(WebServerSafemodeCheck.class) - .contains(DbConnectionCheck.class) - .contains(EsStatusCheck.class); + .contains(WebServerSafemodeNodeCheck.class) + .contains(DbConnectionNodeCheck.class) + .contains(EsStatusNodeCheck.class); } private List<Class<?>> classesAddedToContainer(ComponentContainer container) { |