diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2022-12-21 09:15:42 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-12-23 20:02:51 +0000 |
commit | c3f0febf8d6c2e1baa376e28c212c6feb9f30525 (patch) | |
tree | 7637ba7ef02af9b02beb8e7daa1f089f56123301 /server/sonar-webserver-core | |
parent | 6bf8a78f319ad666cb31d2100910dd34e5fcaf13 (diff) | |
download | sonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.tar.gz sonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.zip |
SONAR-14128 Renamed WebServer to NodeInformation
Diffstat (limited to 'server/sonar-webserver-core')
6 files changed, 41 insertions, 42 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ClusterVerification.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ClusterVerification.java index 25a8e4c1ce0..5816db58f6b 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ClusterVerification.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ClusterVerification.java @@ -19,27 +19,26 @@ */ package org.sonar.server.platform; +import javax.annotation.Nullable; +import javax.inject.Inject; import org.sonar.api.Startable; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.MessageException; -import javax.annotation.Nullable; -import javax.inject.Inject; - @ServerSide public class ClusterVerification implements Startable { - private final WebServer server; + private final NodeInformation server; @Nullable private final ClusterFeature feature; @Inject - public ClusterVerification(WebServer server, @Nullable ClusterFeature feature) { + public ClusterVerification(NodeInformation server, @Nullable ClusterFeature feature) { this.server = server; this.feature = feature; } - public ClusterVerification(WebServer server) { + public ClusterVerification(NodeInformation server) { this(server, null); } diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/SystemInfoWriterModule.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/SystemInfoWriterModule.java index fa73319f0bd..062e6037e14 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/SystemInfoWriterModule.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/SystemInfoWriterModule.java @@ -37,21 +37,21 @@ import org.sonar.server.platform.monitoring.cluster.CeQueueGlobalSection; import org.sonar.server.platform.monitoring.cluster.EsClusterStateSection; import org.sonar.server.platform.monitoring.cluster.GlobalInfoLoader; import org.sonar.server.platform.monitoring.cluster.GlobalSystemSection; -import org.sonar.server.platform.monitoring.cluster.ServerPushSection; import org.sonar.server.platform.monitoring.cluster.NodeSystemSection; import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider; import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl; +import org.sonar.server.platform.monitoring.cluster.ServerPushSection; public class SystemInfoWriterModule extends Module { - private final WebServer webServer; + private final NodeInformation nodeInformation; - public SystemInfoWriterModule(WebServer webServer) { - this.webServer = webServer; + public SystemInfoWriterModule(NodeInformation nodeInformation) { + this.nodeInformation = nodeInformation; } @Override protected void configureModule() { - boolean standalone = webServer.isStandalone(); + boolean standalone = nodeInformation.isStandalone(); add( new JvmPropertiesSection("Web JVM Properties"), diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/serverid/ServerIdManager.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/serverid/ServerIdManager.java index 3f017c59115..2497bac7d61 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/serverid/ServerIdManager.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/serverid/ServerIdManager.java @@ -29,7 +29,7 @@ import org.sonar.core.platform.ServerId; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.property.PropertyDto; -import org.sonar.server.platform.WebServer; +import org.sonar.server.platform.NodeInformation; import org.sonar.server.property.InternalProperties; import static com.google.common.base.Preconditions.checkState; @@ -45,21 +45,21 @@ public class ServerIdManager implements Startable { private final ServerIdFactory serverIdFactory; private final DbClient dbClient; private final SonarRuntime runtime; - private final WebServer webServer; + private final NodeInformation nodeInformation; - public ServerIdManager(ServerIdChecksum serverIdChecksum, ServerIdFactory serverIdFactory, - DbClient dbClient, SonarRuntime runtime, WebServer webServer) { + public ServerIdManager(ServerIdChecksum serverIdChecksum, ServerIdFactory serverIdFactory, DbClient dbClient, SonarRuntime runtime, + NodeInformation nodeInformation) { this.serverIdChecksum = serverIdChecksum; this.serverIdFactory = serverIdFactory; this.dbClient = dbClient; this.runtime = runtime; - this.webServer = webServer; + this.nodeInformation = nodeInformation; } @Override public void start() { try (DbSession dbSession = dbClient.openSession(false)) { - if (runtime.getSonarQubeSide() == SonarQubeSide.SERVER && webServer.isStartupLeader()) { + if (runtime.getSonarQubeSide() == SonarQubeSide.SERVER && nodeInformation.isStartupLeader()) { Optional<String> checksum = dbClient.internalPropertiesDao().selectByKey(dbSession, SERVER_ID_CHECKSUM); ServerId serverId = readCurrentServerId(dbSession) diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ClusterVerificationTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ClusterVerificationTest.java index 7b1f287dabd..ccbb09d519c 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ClusterVerificationTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ClusterVerificationTest.java @@ -31,14 +31,14 @@ public class ClusterVerificationTest { private static final String ERROR_MESSAGE = "Cluster mode can't be enabled. Please install the Data Center Edition. More details at https://redirect.sonarsource.com/editions/datacenter.html."; - private WebServer webServer = mock(WebServer.class); + private NodeInformation nodeInformation = mock(NodeInformation.class); private ClusterFeature feature = mock(ClusterFeature.class); @Test public void throw_MessageException_if_cluster_is_enabled_but_HA_plugin_is_not_installed() { - when(webServer.isStandalone()).thenReturn(false); + when(nodeInformation.isStandalone()).thenReturn(false); - ClusterVerification underTest = new ClusterVerification(webServer); + ClusterVerification underTest = new ClusterVerification(nodeInformation); assertThatThrownBy(underTest::start) .isInstanceOf(MessageException.class) @@ -47,9 +47,9 @@ public class ClusterVerificationTest { @Test public void throw_MessageException_if_cluster_is_enabled_but_HA_feature_is_not_enabled() { - when(webServer.isStandalone()).thenReturn(false); + when(nodeInformation.isStandalone()).thenReturn(false); when(feature.isEnabled()).thenReturn(false); - ClusterVerification underTest = new ClusterVerification(webServer, feature); + ClusterVerification underTest = new ClusterVerification(nodeInformation, feature); assertThatThrownBy(underTest::start) .isInstanceOf(MessageException.class) @@ -58,9 +58,9 @@ public class ClusterVerificationTest { @Test public void do_not_fail_if_cluster_is_enabled_and_HA_feature_is_enabled() { - when(webServer.isStandalone()).thenReturn(false); + when(nodeInformation.isStandalone()).thenReturn(false); when(feature.isEnabled()).thenReturn(true); - ClusterVerification underTest = new ClusterVerification(webServer, feature); + ClusterVerification underTest = new ClusterVerification(nodeInformation, feature); // no failure underTest.start(); @@ -69,9 +69,9 @@ public class ClusterVerificationTest { @Test public void do_not_fail_if_cluster_is_disabled() { - when(webServer.isStandalone()).thenReturn(true); + when(nodeInformation.isStandalone()).thenReturn(true); - ClusterVerification underTest = new ClusterVerification(webServer); + ClusterVerification underTest = new ClusterVerification(nodeInformation); // no failure underTest.start(); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/SystemInfoWriterModuleTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/SystemInfoWriterModuleTest.java index d8b1f404e93..366873c7b3c 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/SystemInfoWriterModuleTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/SystemInfoWriterModuleTest.java @@ -27,12 +27,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class SystemInfoWriterModuleTest { - private final WebServer webServer = mock(WebServer.class); - private final SystemInfoWriterModule underTest = new SystemInfoWriterModule(webServer); + private final NodeInformation nodeInformation = mock(NodeInformation.class); + private final SystemInfoWriterModule underTest = new SystemInfoWriterModule(nodeInformation); @Test public void verify_system_info_configuration_in_cluster_mode() { - when(webServer.isStandalone()).thenReturn(false); + when(nodeInformation.isStandalone()).thenReturn(false); ListContainer container = new ListContainer(); underTest.configure(container); assertThat(container.getAddedObjects()).hasSize(21); @@ -40,7 +40,7 @@ public class SystemInfoWriterModuleTest { @Test public void verify_system_info_configuration_in_standalone_mode() { - when(webServer.isStandalone()).thenReturn(true); + when(nodeInformation.isStandalone()).thenReturn(true); ListContainer container = new ListContainer(); underTest.configure(container); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java index 78b85cd5d63..4fcf306e5da 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java @@ -36,7 +36,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.property.PropertyDto; -import org.sonar.server.platform.WebServer; +import org.sonar.server.platform.NodeInformation; import org.sonar.server.property.InternalProperties; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; @@ -66,7 +66,7 @@ public class ServerIdManagerTest { private final ServerIdFactory serverIdFactory = mock(ServerIdFactory.class); private final DbClient dbClient = dbTester.getDbClient(); private final DbSession dbSession = dbTester.getSession(); - private final WebServer webServer = mock(WebServer.class); + private final NodeInformation nodeInformation = mock(NodeInformation.class); private ServerIdManager underTest; @After @@ -80,7 +80,7 @@ public class ServerIdManagerTest { public void web_leader_persists_new_server_id_if_missing() { mockCreateNewServerId(); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(true); + when(nodeInformation.isStartupLeader()).thenReturn(true); test(SERVER); @@ -93,7 +93,7 @@ public class ServerIdManagerTest { insertServerId(""); mockCreateNewServerId(); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(true); + when(nodeInformation.isStartupLeader()).thenReturn(true); test(SERVER); @@ -106,7 +106,7 @@ public class ServerIdManagerTest { insertServerId(WITH_DATABASE_ID_SERVER_ID); insertChecksum(CHECKSUM_1); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(true); + when(nodeInformation.isStartupLeader()).thenReturn(true); test(SERVER); @@ -121,7 +121,7 @@ public class ServerIdManagerTest { mockChecksumOf(currentServerId, "matches_WITH_DATABASE_ID_SERVER_ID"); mockCreateNewServerIdFrom(currentServerId); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(true); + when(nodeInformation.isStartupLeader()).thenReturn(true); test(SERVER); @@ -133,7 +133,7 @@ public class ServerIdManagerTest { public void web_leader_generates_missing_checksum_for_current_serverId_with_databaseId() { insertServerId(WITH_DATABASE_ID_SERVER_ID); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(true); + when(nodeInformation.isStartupLeader()).thenReturn(true); test(SERVER); @@ -145,7 +145,7 @@ public class ServerIdManagerTest { insertServerId(WITH_DATABASE_ID_SERVER_ID); insertChecksum(CHECKSUM_1); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(false); + when(nodeInformation.isStartupLeader()).thenReturn(false); test(SERVER); @@ -155,7 +155,7 @@ public class ServerIdManagerTest { @Test public void web_follower_fails_if_server_id_is_missing() { - when(webServer.isStartupLeader()).thenReturn(false); + when(nodeInformation.isStartupLeader()).thenReturn(false); expectMissingServerIdException(() -> test(SERVER)); } @@ -163,7 +163,7 @@ public class ServerIdManagerTest { @Test public void web_follower_fails_if_server_id_is_empty() { insertServerId(""); - when(webServer.isStartupLeader()).thenReturn(false); + when(nodeInformation.isStartupLeader()).thenReturn(false); expectEmptyServerIdException(() -> test(SERVER)); } @@ -174,7 +174,7 @@ public class ServerIdManagerTest { insertServerId(WITH_DATABASE_ID_SERVER_ID); insertChecksum(dbChecksum); mockChecksumOf(WITH_DATABASE_ID_SERVER_ID, CHECKSUM_1); - when(webServer.isStartupLeader()).thenReturn(false); + when(nodeInformation.isStartupLeader()).thenReturn(false); try { test(SERVER); @@ -286,7 +286,7 @@ public class ServerIdManagerTest { private void test(SonarQubeSide side) { underTest = new ServerIdManager(serverIdChecksum, serverIdFactory, dbClient, SonarRuntimeImpl - .forSonarQube(Version.create(6, 7), side, SonarEdition.COMMUNITY), webServer); + .forSonarQube(Version.create(6, 7), side, SonarEdition.COMMUNITY), nodeInformation); underTest.start(); } } |