aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2022-12-21 09:15:42 +0100
committersonartech <sonartech@sonarsource.com>2022-12-23 20:02:51 +0000
commitc3f0febf8d6c2e1baa376e28c212c6feb9f30525 (patch)
tree7637ba7ef02af9b02beb8e7daa1f089f56123301
parent6bf8a78f319ad666cb31d2100910dd34e5fcaf13 (diff)
downloadsonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.tar.gz
sonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.zip
SONAR-14128 Renamed WebServer to NodeInformation
-rw-r--r--server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java12
-rw-r--r--server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java12
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java4
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java10
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java22
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultNodeInformation.java (renamed from server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServerImpl.java)6
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/platform/NodeInformation.java (renamed from server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServer.java)2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultNodeInformationTest.java (renamed from server/sonar-server-common/src/test/java/org/sonar/server/platform/WebServerImplTest.java)16
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java16
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ClusterVerification.java11
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/platform/SystemInfoWriterModule.java10
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/platform/serverid/ServerIdManager.java12
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ClusterVerificationTest.java18
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/SystemInfoWriterModuleTest.java8
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java24
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java14
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java42
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java18
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java12
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java8
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java4
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevel2Test.java10
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevelTest.java11
35 files changed, 204 insertions, 206 deletions
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
index b8dc9456d7a..811b41814dc 100644
--- a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
+++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
@@ -49,7 +49,7 @@ import org.sonar.db.ce.CeTaskCharacteristicDto;
import org.sonar.db.ce.DeleteIf;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.user.UserDto;
-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;
@@ -69,13 +69,13 @@ public class CeQueueImpl implements CeQueue {
private final System2 system2;
private final DbClient dbClient;
private final UuidFactory uuidFactory;
- protected final WebServer webServer;
+ protected final NodeInformation nodeInformation;
- public CeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory, WebServer webServer) {
+ public CeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory, NodeInformation nodeInformation) {
this.system2 = system2;
this.dbClient = dbClient;
this.uuidFactory = uuidFactory;
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
}
@Override
@@ -246,7 +246,7 @@ public class CeQueueImpl implements CeQueue {
private void cancelImpl(DbSession dbSession, CeQueueDto q) {
CeActivityDto activityDto = new CeActivityDto(q);
- activityDto.setNodeName(webServer.getNodeName().orElse(null));
+ activityDto.setNodeName(nodeInformation.getNodeName().orElse(null));
activityDto.setStatus(CeActivityDto.Status.CANCELED);
remove(dbSession, q, activityDto);
}
@@ -255,7 +255,7 @@ public class CeQueueImpl implements CeQueue {
public void fail(DbSession dbSession, CeQueueDto task, @Nullable String errorType, @Nullable String errorMessage) {
checkState(IN_PROGRESS.equals(task.getStatus()), "Task is not in-progress and can't be marked as failed [uuid=%s]", task.getUuid());
CeActivityDto activityDto = new CeActivityDto(task);
- activityDto.setNodeName(webServer.getNodeName().orElse(null));
+ activityDto.setNodeName(nodeInformation.getNodeName().orElse(null));
activityDto.setStatus(CeActivityDto.Status.FAILED);
activityDto.setErrorType(errorType);
activityDto.setErrorMessage(errorMessage);
diff --git a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
index 548bf5da50b..121c60d07c4 100644
--- a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
+++ b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java
@@ -43,7 +43,7 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserTesting;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static com.google.common.collect.ImmutableList.of;
import static java.util.Arrays.asList;
@@ -72,9 +72,9 @@ public class CeQueueImplTest {
private UuidFactory uuidFactory = new SequenceUuidFactory();
- private WebServer nodeInformationProvider = mock(WebServer.class);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
- private CeQueue underTest = new CeQueueImpl(system2, db.getDbClient(), uuidFactory, nodeInformationProvider);
+ private CeQueue underTest = new CeQueueImpl(system2, db.getDbClient(), uuidFactory, nodeInformation);
@Test
public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() {
@@ -395,7 +395,7 @@ public class CeQueueImplTest {
@Test
public void cancel_pending_whenNodeNameProvided_setItInCeActivity() {
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.of(NODE_NAME));
+ when(nodeInformation.getNodeName()).thenReturn(Optional.of(NODE_NAME));
CeTask task = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeQueueDto queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();
@@ -408,7 +408,7 @@ public class CeQueueImplTest {
@Test
public void cancel_pending_whenNodeNameNOtProvided_setNulInCeActivity() {
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.empty());
+ when(nodeInformation.getNodeName()).thenReturn(Optional.empty());
CeTask task = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeQueueDto queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();
@@ -521,7 +521,7 @@ public class CeQueueImplTest {
@Test
public void fail_in_progress_task_whenNodeNameProvided_setsItInCeActivityDto() {
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.of(NODE_NAME));
+ when(nodeInformation.getNodeName()).thenReturn(Optional.of(NODE_NAME));
CeTask task = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeQueueDto queueDto = db.getDbClient().ceQueueDao().tryToPeek(db.getSession(), task.getUuid(), WORKER_UUID).get();
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index c6e84e7209c..847bc10c2dc 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -114,6 +114,7 @@ import org.sonar.server.metric.UnanalyzedLanguageMetrics;
import org.sonar.server.notification.DefaultNotificationManager;
import org.sonar.server.notification.NotificationService;
import org.sonar.server.notification.email.EmailNotificationChannel;
+import org.sonar.server.platform.DefaultNodeInformation;
import org.sonar.server.platform.OfficialDistribution;
import org.sonar.server.platform.ServerFileSystemImpl;
import org.sonar.server.platform.ServerImpl;
@@ -121,7 +122,6 @@ import org.sonar.server.platform.ServerLifecycleNotifier;
import org.sonar.server.platform.StartupMetadataProvider;
import org.sonar.server.platform.TempFolderProvider;
import org.sonar.server.platform.UrlSettings;
-import org.sonar.server.platform.WebServerImpl;
import org.sonar.server.platform.db.migration.MigrationConfigurationModule;
import org.sonar.server.platform.db.migration.version.DatabaseVersion;
import org.sonar.server.platform.monitoring.DbSection;
@@ -281,7 +281,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
CeProcessLogging.class,
UuidFactoryImpl.INSTANCE,
NetworkUtilsImpl.INSTANCE,
- WebServerImpl.class,
+ DefaultNodeInformation.class,
LogbackHelper.class,
DefaultDatabase.class,
MyBatis.class,
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
index a95a102f4a5..ae2ec86afcf 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
@@ -47,7 +47,7 @@ import org.sonar.db.ce.CeQueueDao;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskCharacteristicDto;
import org.sonar.db.component.ComponentDto;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
@@ -66,8 +66,8 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
private final NextPendingTaskPicker nextPendingTaskPicker;
public InternalCeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory, CEQueueStatus queueStatus,
- ComputeEngineStatus computeEngineStatus, NextPendingTaskPicker nextPendingTaskPicker, WebServer webServer) {
- super(system2, dbClient, uuidFactory, webServer);
+ ComputeEngineStatus computeEngineStatus, NextPendingTaskPicker nextPendingTaskPicker, NodeInformation nodeInformation) {
+ super(system2, dbClient, uuidFactory, nodeInformation);
this.dbClient = dbClient;
this.queueStatus = queueStatus;
this.computeEngineStatus = computeEngineStatus;
@@ -114,7 +114,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
CeQueueDto queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, task.getUuid())
.orElseThrow(() -> new IllegalStateException("Task does not exist anymore: " + task));
CeActivityDto activityDto = new CeActivityDto(queueDto);
- activityDto.setNodeName(webServer.getNodeName().orElse(null));
+ activityDto.setNodeName(nodeInformation.getNodeName().orElse(null));
activityDto.setStatus(status);
executionTimeInMs = updateExecutionFields(activityDto);
updateTaskResult(activityDto, taskResult);
@@ -178,7 +178,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
List<CeQueueDto> wornOutTasks = dbClient.ceQueueDao().selectWornout(dbSession);
wornOutTasks.forEach(queueDto -> {
CeActivityDto activityDto = new CeActivityDto(queueDto);
- activityDto.setNodeName(webServer.getNodeName().orElse(null));
+ activityDto.setNodeName(nodeInformation.getNodeName().orElse(null));
activityDto.setStatus(CeActivityDto.Status.CANCELED);
updateExecutionFields(activityDto);
remove(dbSession, queueDto, activityDto);
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
index 445b29ec849..3bd87906698 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java
@@ -48,7 +48,7 @@ import org.sonar.db.ce.CeTaskTypes;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.user.UserDto;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyMap;
@@ -83,15 +83,15 @@ public class InternalCeQueueImplTest {
private ComputeEngineStatus computeEngineStatus = mock(ComputeEngineStatus.class);
private Configuration config = mock(Configuration.class);
private NextPendingTaskPicker nextPendingTaskPicker = new NextPendingTaskPicker(config, db.getDbClient());
- private WebServer nodeInformationProvider = mock(WebServer.class);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
private InternalCeQueue underTest = new InternalCeQueueImpl(system2, db.getDbClient(), uuidFactory, queueStatus,
- computeEngineStatus, nextPendingTaskPicker, nodeInformationProvider);
+ computeEngineStatus, nextPendingTaskPicker, nodeInformation);
@Before
public void setUp() {
when(config.getBoolean(any())).thenReturn(Optional.of(false));
when(computeEngineStatus.getStatus()).thenReturn(STARTED);
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.of(NODE_NAME));
+ when(nodeInformation.getNodeName()).thenReturn(Optional.of(NODE_NAME));
}
@Test
@@ -215,8 +215,8 @@ public class InternalCeQueueImplTest {
}
@Test
- public void remove_sets_nodeName_in_CeActivity_when_nodeInformationProvider_defines_node_name() {
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.of(NODE_NAME));
+ public void remove_sets_nodeName_in_CeActivity_when_nodeInformation_defines_node_name() {
+ when(nodeInformation.getNodeName()).thenReturn(Optional.of(NODE_NAME));
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
Optional<CeTask> peek = underTest.peek(WORKER_UUID_2, true);
@@ -228,8 +228,8 @@ public class InternalCeQueueImplTest {
}
@Test
- public void remove_do_not_set_nodeName_in_CeActivity_when_nodeInformationProvider_does_not_define_node_name() {
- when(nodeInformationProvider.getNodeName()).thenReturn(Optional.empty());
+ public void remove_do_not_set_nodeName_in_CeActivity_when_nodeInformation_does_not_define_node_name() {
+ when(nodeInformation.getNodeName()).thenReturn(Optional.empty());
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
Optional<CeTask> peek = underTest.peek(WORKER_UUID_2, true);
@@ -278,7 +278,7 @@ public class InternalCeQueueImplTest {
db.getDbClient().ceQueueDao().deleteByUuid(db.getSession(), task.getUuid());
db.commit();
- InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatus, null, null, nodeInformationProvider);
+ InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatus, null, null, nodeInformation);
try {
underTest.remove(task, CeActivityDto.Status.SUCCESS, null, null);
@@ -295,7 +295,7 @@ public class InternalCeQueueImplTest {
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
db.getDbClient().ceQueueDao().deleteByUuid(db.getSession(), task.getUuid());
db.commit();
- InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null, nodeInformationProvider);
+ InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null, nodeInformation);
try {
underTest.remove(task, CeActivityDto.Status.FAILED, null, null);
@@ -313,7 +313,7 @@ public class InternalCeQueueImplTest {
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
db.executeUpdateSql("update ce_queue set status = 'PENDING', started_at = 123 where uuid = '" + task.getUuid() + "'");
db.commit();
- InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null, nodeInformationProvider);
+ InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null, nodeInformation);
underTest.cancelWornOuts();
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServerImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultNodeInformation.java
index 07f37975002..4ebbb98d890 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServerImpl.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/DefaultNodeInformation.java
@@ -27,18 +27,18 @@ import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_NAME;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_WEB_STARTUP_LEADER;
-public class WebServerImpl implements WebServer {
+public class DefaultNodeInformation implements NodeInformation {
private final boolean clusterEnabled;
private final boolean startupLeader;
private final String nodeName;
- public WebServerImpl(Configuration config) {
+ public DefaultNodeInformation(Configuration config) {
this.clusterEnabled = config.getBoolean(CLUSTER_ENABLED.getKey()).orElse(false);
if (this.clusterEnabled) {
this.startupLeader = config.getBoolean(CLUSTER_WEB_STARTUP_LEADER.getKey()).orElse(false);
this.nodeName = config.get(CLUSTER_NODE_NAME.getKey()).orElse(CLUSTER_NODE_NAME.getDefaultValue());
- Loggers.get(WebServerImpl.class).info("Cluster enabled (startup {})", startupLeader ? "leader" : "follower");
+ Loggers.get(DefaultNodeInformation.class).info("Cluster enabled (startup {})", startupLeader ? "leader" : "follower");
} else {
this.startupLeader = true;
this.nodeName = null;
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServer.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/NodeInformation.java
index 97b7ffee737..3ea80d301e8 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/WebServer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/NodeInformation.java
@@ -25,7 +25,7 @@ import org.sonar.api.server.ServerSide;
@ComputeEngineSide
@ServerSide
-public interface WebServer {
+public interface NodeInformation {
/**
* Node is standalone when property {@link org.sonar.process.ProcessProperties.Property#CLUSTER_ENABLED} is {@code false} or
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java
index 19e714c9a28..f9eb25e4afb 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/StartupMetadataProvider.java
@@ -39,8 +39,8 @@ import static org.sonar.api.CoreProperties.SERVER_STARTTIME;
@ServerSide
public class StartupMetadataProvider {
@Bean("StartupMetadata")
- public StartupMetadata provide(System2 system, SonarRuntime runtime, WebServer webServer, DbClient dbClient) {
- if (runtime.getSonarQubeSide() == SonarQubeSide.SERVER && webServer.isStartupLeader()) {
+ public StartupMetadata provide(System2 system, SonarRuntime runtime, NodeInformation nodeInformation, DbClient dbClient) {
+ if (runtime.getSonarQubeSide() == SonarQubeSide.SERVER && nodeInformation.isStartupLeader()) {
return generate(system);
} else {
return load(dbClient);
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/WebServerImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultNodeInformationTest.java
index 9b1998a1236..bc8a98dc9ed 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/WebServerImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/DefaultNodeInformationTest.java
@@ -24,14 +24,14 @@ import org.sonar.api.config.internal.MapSettings;
import static org.assertj.core.api.Assertions.assertThat;
-public class WebServerImplTest {
+public class DefaultNodeInformationTest {
private MapSettings settings = new MapSettings();
@Test
public void cluster_is_disabled_by_default() {
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.isStandalone()).isTrue();
assertThat(underTest.isStartupLeader()).isTrue();
@@ -42,7 +42,7 @@ public class WebServerImplTest {
settings.setProperty("sonar.cluster.enabled", "true");
settings.setProperty("sonar.cluster.web.startupLeader", "true");
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.isStandalone()).isFalse();
assertThat(underTest.isStartupLeader()).isTrue();
@@ -52,7 +52,7 @@ public class WebServerImplTest {
public void node_is_startup_follower_by_default_in_cluster() {
settings.setProperty("sonar.cluster.enabled", "true");
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.isStandalone()).isFalse();
assertThat(underTest.isStartupLeader()).isFalse();
@@ -63,7 +63,7 @@ public class WebServerImplTest {
settings.setProperty("sonar.cluster.enabled", "true");
settings.setProperty("sonar.cluster.web.startupLeader", "false");
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.isStandalone()).isFalse();
assertThat(underTest.isStartupLeader()).isFalse();
@@ -74,7 +74,7 @@ public class WebServerImplTest {
settings.setProperty("sonar.cluster.enabled", "false");
settings.setProperty("sonar.cluster.node.name", "nameIgnored");
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.getNodeName()).isEmpty();
}
@@ -84,7 +84,7 @@ public class WebServerImplTest {
settings.setProperty("sonar.cluster.enabled", "true");
settings.removeProperty("sonar.cluster.node.name");
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.getNodeName()).isNotEmpty();
String nodeNameFirstCallToGetNodeName = underTest.getNodeName().get();
@@ -99,7 +99,7 @@ public class WebServerImplTest {
settings.setProperty("sonar.cluster.enabled", "true");
settings.setProperty("sonar.cluster.node.name", nodeName);
- WebServerImpl underTest = new WebServerImpl(settings.asConfig());
+ DefaultNodeInformation underTest = new DefaultNodeInformation(settings.asConfig());
assertThat(underTest.getNodeName()).isNotEmpty();
assertThat(underTest.getNodeName().get()).startsWith(nodeName);
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java
index 1b1eb7f902a..ae8bc202d2b 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java
@@ -46,15 +46,15 @@ public class StartupMetadataProviderTest {
private final StartupMetadataProvider underTest = new StartupMetadataProvider();
private final System2 system = mock(System2.class);
- private final WebServer webServer = mock(WebServer.class);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
@Test
public void generate_SERVER_STARTIME_but_do_not_persist_it_if_server_is_startup_leader() {
when(system.now()).thenReturn(A_DATE);
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER, SonarEdition.COMMUNITY);
- when(webServer.isStartupLeader()).thenReturn(true);
+ when(nodeInformation.isStartupLeader()).thenReturn(true);
- StartupMetadata metadata = underTest.provide(system, runtime, webServer, dbTester.getDbClient());
+ StartupMetadata metadata = underTest.provide(system, runtime, nodeInformation, dbTester.getDbClient());
assertThat(metadata.getStartedAt()).isEqualTo(A_DATE);
assertNotPersistedProperty(CoreProperties.SERVER_STARTTIME);
@@ -63,7 +63,7 @@ public class StartupMetadataProviderTest {
@Test
public void load_from_database_if_server_is_startup_follower() {
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER, SonarEdition.COMMUNITY);
- when(webServer.isStartupLeader()).thenReturn(false);
+ when(nodeInformation.isStartupLeader()).thenReturn(false);
testLoadingFromDatabase(runtime, false);
}
@@ -85,9 +85,9 @@ public class StartupMetadataProviderTest {
@Test
public void fail_to_load_from_database_if_properties_are_not_persisted() {
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY);
- when(webServer.isStartupLeader()).thenReturn(false);
+ when(nodeInformation.isStartupLeader()).thenReturn(false);
- assertThatThrownBy(() -> underTest.provide(system, runtime, webServer, dbTester.getDbClient()))
+ assertThatThrownBy(() -> underTest.provide(system, runtime, nodeInformation, dbTester.getDbClient()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Property sonar.core.startTime is missing in database");
}
@@ -95,9 +95,9 @@ public class StartupMetadataProviderTest {
private void testLoadingFromDatabase(SonarRuntime runtime, boolean isStartupLeader) {
dbTester.properties().insertProperty(new PropertyDto().setKey(CoreProperties.SERVER_STARTTIME).setValue(formatDateTime(A_DATE)),
null, null,null, null);
- when(webServer.isStartupLeader()).thenReturn(isStartupLeader);
+ when(nodeInformation.isStartupLeader()).thenReturn(isStartupLeader);
- StartupMetadata metadata = underTest.provide(system, runtime, webServer, dbTester.getDbClient());
+ StartupMetadata metadata = underTest.provide(system, runtime, nodeInformation, dbTester.getDbClient());
assertThat(metadata.getStartedAt()).isEqualTo(A_DATE);
// still in database
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();
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
index 44b24091b9f..f3841d4bcac 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
@@ -25,7 +25,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.process.cluster.health.NodeHealth;
import org.sonar.process.cluster.health.SharedHealthState;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.springframework.beans.factory.annotation.Autowired;
import static com.google.common.base.Preconditions.checkState;
@@ -36,7 +36,7 @@ import static com.google.common.collect.ImmutableList.copyOf;
* available in the container.
*/
public class HealthCheckerImpl implements HealthChecker {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final List<NodeHealthCheck> nodeHealthChecks;
private final List<ClusterHealthCheck> clusterHealthChecks;
@CheckForNull
@@ -46,17 +46,17 @@ public class HealthCheckerImpl implements HealthChecker {
* Constructor used by the ioc container in standalone mode and in safe mode.
*/
@Autowired(required = false)
- public HealthCheckerImpl(WebServer webServer, NodeHealthCheck[] nodeHealthChecks) {
- this(webServer, nodeHealthChecks, new ClusterHealthCheck[0], null);
+ public HealthCheckerImpl(NodeInformation nodeInformation, NodeHealthCheck[] nodeHealthChecks) {
+ this(nodeInformation, nodeHealthChecks, new ClusterHealthCheck[0], null);
}
/**
* Constructor used by the ioc container in cluster mode.
*/
@Autowired(required = false)
- public HealthCheckerImpl(WebServer webServer, NodeHealthCheck[] nodeHealthChecks, ClusterHealthCheck[] clusterHealthChecks,
+ public HealthCheckerImpl(NodeInformation nodeInformation, NodeHealthCheck[] nodeHealthChecks, ClusterHealthCheck[] clusterHealthChecks,
@Nullable SharedHealthState sharedHealthState) {
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
this.nodeHealthChecks = copyOf(nodeHealthChecks);
this.clusterHealthChecks = copyOf(clusterHealthChecks);
this.sharedHealthState = sharedHealthState;
@@ -71,7 +71,7 @@ public class HealthCheckerImpl implements HealthChecker {
@Override
public ClusterHealth checkCluster() {
- checkState(!webServer.isStandalone(), "Clustering is not enabled");
+ checkState(!nodeInformation.isStandalone(), "Clustering is not enabled");
checkState(sharedHealthState != null, "HealthState instance can't be null when clustering is enabled");
Set<NodeHealth> nodeHealths = sharedHealthState.readAll();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
index c50d3fd62d3..a7401d18886 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
@@ -20,18 +20,18 @@
package org.sonar.server.platform.ws;
import org.sonar.core.platform.Module;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
public class ChangeLogLevelServiceModule extends Module {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
- public ChangeLogLevelServiceModule(WebServer webServer) {
- this.webServer = webServer;
+ public ChangeLogLevelServiceModule(NodeInformation nodeInformation) {
+ this.nodeInformation = nodeInformation;
}
@Override
protected void configureModule() {
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
add(ChangeLogLevelStandaloneService.class);
} else {
add(ChangeLogLevelClusterService.class);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
index 42a2211a559..394fa418ce0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
@@ -23,19 +23,19 @@ import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.user.SystemPasscode;
import org.sonar.server.user.UserSession;
import org.sonar.server.ws.WsUtils;
public class HealthAction implements SystemWsAction {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final HealthActionSupport support;
private final SystemPasscode systemPasscode;
private final UserSession userSession;
- public HealthAction(WebServer webServer, HealthActionSupport support, SystemPasscode systemPasscode, UserSession userSession) {
- this.webServer = webServer;
+ public HealthAction(NodeInformation nodeInformation, HealthActionSupport support, SystemPasscode systemPasscode, UserSession userSession) {
+ this.nodeInformation = nodeInformation;
this.support = support;
this.systemPasscode = systemPasscode;
this.userSession = userSession;
@@ -52,7 +52,7 @@ public class HealthAction implements SystemWsAction {
throw new ForbiddenException("Insufficient privileges");
}
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
WsUtils.writeProtobuf(support.checkNodeHealth(), request, response);
} else {
WsUtils.writeProtobuf(support.checkClusterHealth(), request, response);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
index 61c3248eb65..f5646eaa6cf 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
@@ -27,13 +27,13 @@ import org.sonar.server.health.EsStatusClusterCheck;
import org.sonar.server.health.EsStatusNodeCheck;
import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.WebServerStatusNodeCheck;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
public class HealthCheckerModule extends Module {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
- public HealthCheckerModule(WebServer webServer) {
- this.webServer = webServer;
+ public HealthCheckerModule(NodeInformation nodeInformation) {
+ this.nodeInformation = nodeInformation;
}
@Override
@@ -42,7 +42,7 @@ public class HealthCheckerModule extends Module {
add(WebServerStatusNodeCheck.class,
DbConnectionNodeCheck.class,
CeStatusNodeCheck.class);
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
add(EsStatusNodeCheck.class);
} else {
// ClusterHealthCheck implementations
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
index de87d55c6c3..951cfe022d1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
@@ -26,7 +26,7 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.user.UserSession;
/**
@@ -39,14 +39,14 @@ public class RestartAction implements SystemWsAction {
private final UserSession userSession;
private final ProcessCommandWrapper processCommandWrapper;
private final RestartFlagHolder restartFlagHolder;
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
public RestartAction(UserSession userSession, ProcessCommandWrapper processCommandWrapper, RestartFlagHolder restartFlagHolder,
- WebServer webServer) {
+ NodeInformation nodeInformation) {
this.userSession = userSession;
this.processCommandWrapper = processCommandWrapper;
this.restartFlagHolder = restartFlagHolder;
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
}
@Override
@@ -61,7 +61,7 @@ public class RestartAction implements SystemWsAction {
@Override
public void handle(Request request, Response response) {
- if (!webServer.isStandalone()) {
+ if (!nodeInformation.isStandalone()) {
throw new IllegalArgumentException("Restart not allowed for cluster nodes");
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
index fd59388942d..bbe34987ba0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
@@ -39,7 +39,7 @@ import org.sonar.db.DbSession;
import org.sonar.db.dialect.H2;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.VersionFormatter;
import org.sonar.server.ui.WebAnalyticsLoader;
@@ -69,7 +69,7 @@ public class GlobalAction implements NavigationWsAction, Startable {
private final Configuration config;
private final ResourceTypes resourceTypes;
private final Server server;
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final DbClient dbClient;
private final UserSession userSession;
private final PlatformEditionProvider editionProvider;
@@ -78,14 +78,14 @@ public class GlobalAction implements NavigationWsAction, Startable {
private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier;
public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server,
- WebServer webServer, DbClient dbClient, UserSession userSession, PlatformEditionProvider editionProvider,
+ NodeInformation nodeInformation, DbClient dbClient, UserSession userSession, PlatformEditionProvider editionProvider,
WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier) {
this.pageRepository = pageRepository;
this.config = config;
this.resourceTypes = resourceTypes;
this.server = server;
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
this.dbClient = dbClient;
this.userSession = userSession;
this.editionProvider = editionProvider;
@@ -129,7 +129,7 @@ public class GlobalAction implements NavigationWsAction, Startable {
writeInstanceUsesDefaultAdminCredentials(json);
editionProvider.get().ifPresent(e -> json.prop("edition", e.name().toLowerCase(Locale.ENGLISH)));
writeNeedIssueSync(json);
- json.prop("standalone", webServer.isStandalone());
+ json.prop("standalone", nodeInformation.isStandalone());
writeWebAnalytics(json);
json.endObject();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
index 5255dd6d7f7..fa51c868275 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
@@ -29,7 +29,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.component.ComponentDto;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -45,7 +45,7 @@ public class ExportSubmitterImplTest {
public DbTester db = DbTester.create(system2);
private final DbClient dbClient = db.getDbClient();
- private final CeQueue ceQueue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(WebServer.class));
+ private final CeQueue ceQueue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(NodeInformation.class));
private final ExportSubmitterImpl underTest = new ExportSubmitterImpl(ceQueue, dbClient);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
index 6086a1219b6..16de1288fb0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
@@ -36,7 +36,7 @@ import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskTypes;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
@@ -53,7 +53,7 @@ public class CancelActionTest {
public DbTester db = DbTester.create();
private System2 system2 = new TestSystem2();
- private CeQueue queue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(WebServer.class));
+ private CeQueue queue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(NodeInformation.class));
private CancelAction underTest = new CancelAction(userSession, db.getDbClient(), queue);
private WsActionTester tester = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
index 127163463ce..fd1572b0229 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
@@ -32,7 +32,7 @@ import org.junit.Test;
import org.sonar.process.cluster.health.NodeDetails;
import org.sonar.process.cluster.health.NodeHealth;
import org.sonar.process.cluster.health.SharedHealthState;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,13 +49,13 @@ import static org.sonar.server.health.Health.Status.YELLOW;
public class HealthCheckerImplTest {
- private final WebServer webServer = mock(WebServer.class);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
private final SharedHealthState sharedHealthState = mock(SharedHealthState.class);
private final Random random = new Random();
@Test
public void check_returns_green_status_without_any_cause_when_there_is_no_NodeHealthCheck() {
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0]);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0]);
assertThat(underTest.checkNode()).isEqualTo(Health.GREEN);
}
@@ -109,15 +109,15 @@ public class HealthCheckerImplTest {
.toArray(NodeHealthCheck[]::new);
String[] expected = Arrays.stream(nodeHealthChecks).map(NodeHealthCheck::check).flatMap(s -> s.getCauses().stream()).toArray(String[]::new);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, nodeHealthChecks);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, nodeHealthChecks);
assertThat(underTest.checkNode().getCauses()).containsOnly(expected);
}
@Test
public void checkCluster_fails_with_ISE_in_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ when(nodeInformation.isStandalone()).thenReturn(true);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
assertThatThrownBy(() -> underTest.checkCluster())
.isInstanceOf(IllegalStateException.class)
@@ -126,8 +126,8 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_fails_with_ISE_in_clustering_and_HealthState_is_null() {
- when(webServer.isStandalone()).thenReturn(false);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], null);
+ when(nodeInformation.isStandalone()).thenReturn(false);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], null);
assertThatThrownBy(() -> underTest.checkCluster())
.isInstanceOf(IllegalStateException.class)
@@ -136,15 +136,15 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_GREEN_when_there_is_no_ClusterHealthCheck() {
- when(webServer.isStandalone()).thenReturn(false);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ when(nodeInformation.isStandalone()).thenReturn(false);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
assertThat(underTest.checkCluster().getHealth()).isEqualTo(Health.GREEN);
}
@Test
public void checkCluster_returns_GREEN_status_if_only_GREEN_statuses_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = IntStream.range(1, 1 + random.nextInt(20)).mapToObj(i -> GREEN).collect(Collectors.toList());
HealthCheckerImpl underTest = newClusterHealthCheckerImpl(statuses.stream());
@@ -155,7 +155,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_YELLOW_status_if_only_GREEN_and_at_least_one_YELLOW_statuses_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = new ArrayList<>();
Stream.concat(
IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> YELLOW), // at least 1 YELLOW
@@ -170,7 +170,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_RED_status_if_at_least_one_RED_status_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = new ArrayList<>();
Stream.of(
IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> RED), // at least 1 RED
@@ -188,7 +188,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_causes_of_all_ClusterHealthChecks_whichever_their_status() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<String[]> causesGroups = IntStream.range(0, 1 + random.nextInt(20))
.mapToObj(s -> IntStream.range(0, random.nextInt(3)).mapToObj(i -> randomAlphanumeric(3)).toArray(String[]::new))
.collect(Collectors.toList());
@@ -198,14 +198,14 @@ public class HealthCheckerImplTest {
.toArray(ClusterHealthCheck[]::new);
String[] expectedCauses = causesGroups.stream().flatMap(Arrays::stream).toArray(String[]::new);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);
assertThat(underTest.checkCluster().getHealth().getCauses()).containsOnly(expectedCauses);
}
@Test
public void checkCluster_passes_set_of_NodeHealth_returns_by_HealthState_to_all_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ClusterHealthCheck[] mockedClusterHealthChecks = IntStream.range(0, 1 + random.nextInt(3))
.mapToObj(i -> mock(ClusterHealthCheck.class))
.toArray(ClusterHealthCheck[]::new);
@@ -215,7 +215,7 @@ public class HealthCheckerImplTest {
when(mockedClusterHealthCheck.check(same(nodeHealths))).thenReturn(Health.GREEN);
}
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], mockedClusterHealthChecks, sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], mockedClusterHealthChecks, sharedHealthState);
underTest.checkCluster();
for (ClusterHealthCheck mockedClusterHealthCheck : mockedClusterHealthChecks) {
@@ -225,11 +225,11 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_NodeHealths_returned_by_HealthState() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
Set<NodeHealth> nodeHealths = IntStream.range(0, 1 + random.nextInt(4)).mapToObj(i -> randomNodeHealth()).collect(Collectors.toSet());
when(sharedHealthState.readAll()).thenReturn(nodeHealths);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
ClusterHealth clusterHealth = underTest.checkCluster();
assertThat(clusterHealth.getNodes()).isEqualTo(nodeHealths);
@@ -251,14 +251,14 @@ public class HealthCheckerImplTest {
private HealthCheckerImpl newNodeHealthCheckerImpl(Stream<Health.Status> statuses) {
Stream<HardcodedHealthNodeCheck> staticHealthCheckStream = statuses.map(HardcodedHealthNodeCheck::new);
return new HealthCheckerImpl(
- webServer,
+ nodeInformation,
staticHealthCheckStream.map(NodeHealthCheck.class::cast).toArray(NodeHealthCheck[]::new));
}
private HealthCheckerImpl newClusterHealthCheckerImpl(Stream<Health.Status> statuses) {
Stream<HardcodedHealthClusterCheck> staticHealthCheckStream = statuses.map(HardcodedHealthClusterCheck::new);
return new HealthCheckerImpl(
- webServer,
+ nodeInformation,
new NodeHealthCheck[0],
staticHealthCheckStream.map(ClusterHealthCheck.class::cast).toArray(ClusterHealthCheck[]::new),
sharedHealthState);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
index 21c00a6a403..65183c73d1c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
@@ -21,19 +21,19 @@ package org.sonar.server.platform.ws;
import org.junit.Test;
import org.sonar.core.platform.ListContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ChangeLogLevelServiceModuleTest {
- private final WebServer webServer = mock(WebServer.class);
- private final ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(webServer);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
+ private final ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(nodeInformation);
@Test
public void provide_returns_ChangeLogLevelClusterService() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -43,7 +43,7 @@ public class ChangeLogLevelServiceModuleTest {
@Test
public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
index 76d47596723..4de9869a6f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
@@ -38,7 +38,7 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.health.ClusterHealth;
import org.sonar.server.health.Health;
import org.sonar.server.health.HealthChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.SystemPasscode;
import org.sonar.server.ws.TestRequest;
@@ -69,9 +69,9 @@ public class HealthActionTest {
private final Random random = new Random();
private HealthChecker healthChecker = mock(HealthChecker.class);
- private WebServer webServer = mock(WebServer.class);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
private SystemPasscode systemPasscode = mock(SystemPasscode.class);
- private WsActionTester underTest = new WsActionTester(new HealthAction(webServer, new HealthActionSupport(healthChecker), systemPasscode, userSessionRule));
+ private WsActionTester underTest = new WsActionTester(new HealthAction(nodeInformation, new HealthActionSupport(healthChecker), systemPasscode, userSessionRule));
@Test
public void verify_definition() {
@@ -134,7 +134,7 @@ public class HealthActionTest {
@Test
public void verify_response_example() {
authenticateWithRandomMethod();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
long time = parseDateTime("2015-08-13T23:34:59+0200").getTime();
when(healthChecker.checkCluster())
.thenReturn(
@@ -183,7 +183,7 @@ public class HealthActionTest {
IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause);
Health health = builder.build();
when(healthChecker.checkNode()).thenReturn(health);
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
TestRequest request = underTest.newRequest();
System.HealthResponse healthResponse = request.executeProtobuf(System.HealthResponse.class);
@@ -199,7 +199,7 @@ public class HealthActionTest {
Health.Builder healthBuilder = Health.builder()
.setStatus(randomStatus);
Arrays.stream(causes).forEach(healthBuilder::addCause);
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(healthBuilder.build(), emptySet()));
System.HealthResponse clusterHealthResponse = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
@@ -213,7 +213,7 @@ public class HealthActionTest {
public void response_contains_information_of_nodes_when_clustered() {
authenticateWithRandomMethod();
NodeHealth nodeHealth = randomNodeHealth();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(GREEN, singleton(nodeHealth)));
System.HealthResponse response = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
@@ -255,7 +255,7 @@ public class HealthActionTest {
String[] expected = nodeHealths.stream().map(s -> formatDateTime(new Date(s.getDetails().getStartedAt()))).toArray(String[]::new);
Collections.shuffle(nodeHealths);
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(GREEN, new HashSet<>(nodeHealths)));
System.HealthResponse response = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
index b91322ca303..f20785d7454 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import org.junit.Test;
+import org.sonar.core.platform.ListContainer;
import org.sonar.server.health.AppNodeClusterCheck;
import org.sonar.server.health.CeStatusNodeCheck;
import org.sonar.server.health.ClusterHealthCheck;
@@ -32,21 +33,20 @@ import org.sonar.server.health.EsStatusNodeCheck;
import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.NodeHealthCheck;
import org.sonar.server.health.WebServerStatusNodeCheck;
-import org.sonar.core.platform.ListContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class HealthCheckerModuleTest {
- private final WebServer webServer = mock(WebServer.class);
- private final HealthCheckerModule underTest = new HealthCheckerModule(webServer);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
+ private final HealthCheckerModule underTest = new HealthCheckerModule(nodeInformation);
@Test
public void verify_HealthChecker() {
boolean standalone = new Random().nextBoolean();
- when(webServer.isStandalone()).thenReturn(standalone);
+ when(nodeInformation.isStandalone()).thenReturn(standalone);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -61,7 +61,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_NodeHealthChecks_implementations_when_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -75,7 +75,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_NodeHealthChecks_implementations_when_clustered() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -89,7 +89,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_ClusterHealthChecks_implementations_in_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -103,7 +103,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_ClusterHealthChecks_implementations_in_clustering() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
index c06798ff59b..5d63f8a6ae9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
@@ -28,7 +28,7 @@ import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
@@ -45,15 +45,15 @@ public class RestartActionTest {
private ProcessCommandWrapper processCommandWrapper = mock(ProcessCommandWrapper.class);
private RestartFlagHolder restartFlagHolder = mock(RestartFlagHolder.class);
- private WebServer webServer = mock(WebServer.class);
- private RestartAction sut = new RestartAction(userSessionRule, processCommandWrapper, restartFlagHolder, webServer);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
+ private RestartAction sut = new RestartAction(userSessionRule, processCommandWrapper, restartFlagHolder, nodeInformation);
private InOrder inOrder = Mockito.inOrder(restartFlagHolder, processCommandWrapper);
private WsActionTester actionTester = new WsActionTester(sut);
@Test
public void request_fails_in_production_mode_with_ForbiddenException_when_user_is_not_logged_in() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
assertThatThrownBy(() -> actionTester.newRequest().execute())
.isInstanceOf(ForbiddenException.class);
@@ -61,7 +61,7 @@ public class RestartActionTest {
@Test
public void request_fails_in_production_mode_with_ForbiddenException_when_user_is_not_system_administrator() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
userSessionRule.logIn().setNonSystemAdministrator();
assertThatThrownBy(() -> actionTester.newRequest().execute())
@@ -70,7 +70,7 @@ public class RestartActionTest {
@Test
public void request_fails_in_cluster_mode_with_IllegalArgumentException() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
assertThatThrownBy(() -> actionTester.newRequest().execute())
.isInstanceOf(IllegalArgumentException.class)
@@ -79,7 +79,7 @@ public class RestartActionTest {
@Test
public void calls_ProcessCommandWrapper_requestForSQRestart_in_production_mode() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
userSessionRule.logIn().setSystemAdministrator();
actionTester.newRequest().execute();
@@ -90,7 +90,7 @@ public class RestartActionTest {
@Test
public void logs_login_of_authenticated_user_requesting_the_restart_in_production_mode() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
String login = "BigBother";
userSessionRule.logIn(login).setSystemAdministrator();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
index 4fa843fd22f..182adb66d1e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
@@ -23,8 +23,8 @@ import org.junit.Test;
import org.sonar.api.server.ws.WebService;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.platform.SystemInfoWriter;
-import org.sonar.server.platform.WebServer;
import org.sonar.server.tester.AnonymousMockUserSession;
import org.sonar.server.user.UserSession;
@@ -36,7 +36,7 @@ public class SystemWsTest {
@Test
public void define() {
RestartAction action1 = new RestartAction(mock(UserSession.class), mock(ProcessCommandWrapper.class),
- mock(RestartFlagHolder.class), mock(WebServer.class));
+ mock(RestartFlagHolder.class), mock(NodeInformation.class));
InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(SystemInfoWriter.class));
SystemWs ws = new SystemWs(action1, action2);
WebService.Context context = new WebService.Context();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
index bdcb1b773b9..f0c048ab946 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
@@ -39,7 +39,7 @@ import org.sonar.db.dialect.H2;
import org.sonar.db.dialect.PostgreSql;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.WebAnalyticsLoader;
@@ -61,7 +61,7 @@ public class GlobalActionTest {
private final MapSettings settings = new MapSettings();
private final Server server = mock(Server.class);
- private final WebServer webServer = mock(WebServer.class);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
private final DbClient dbClient = mock(DbClient.class, RETURNS_DEEP_STUBS);
private final IssueIndexSyncProgressChecker indexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
private final BranchFeatureRule branchFeature = new BranchFeatureRule();
@@ -244,7 +244,7 @@ public class GlobalActionTest {
public void standalone_flag() {
init();
userSession.logIn().setSystemAdministrator();
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
assertJson(call()).isSimilarTo("{\"standalone\":true}");
}
@@ -253,7 +253,7 @@ public class GlobalActionTest {
public void not_standalone_flag() {
init();
userSession.logIn().setSystemAdministrator();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
assertJson(call()).isSimilarTo("{\"standalone\":false}");
}
@@ -280,7 +280,7 @@ public class GlobalActionTest {
});
when(server.getVersion()).thenReturn("6.2");
when(dbClient.getDatabase().getDialect()).thenReturn(new PostgreSql());
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
String result = call();
@@ -343,7 +343,7 @@ public class GlobalActionTest {
}});
pageRepository.start();
GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server,
- webServer, dbClient, userSession, editionProvider, webAnalyticsLoader,
+ nodeInformation, dbClient, userSession, editionProvider, webAnalyticsLoader,
indexSyncProgressChecker, defaultAdminCredentialsVerifier);
ws = new WsActionTester(wsAction);
wsAction.start();
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
index 74eafc913bf..c41f47f34ed 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel.java
@@ -23,7 +23,7 @@ import java.util.Collection;
import java.util.Optional;
import javax.annotation.Nullable;
import org.sonar.core.platform.SpringComponentContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -144,10 +144,10 @@ public abstract class PlatformLevel {
return addIfStandalone;
}
- protected WebServer getWebServer() {
+ protected NodeInformation getWebServer() {
return Optional.ofNullable(parent)
- .flatMap(p -> p.getOptional(WebServer.class))
- .or(() -> getOptional(WebServer.class))
+ .flatMap(p -> p.getOptional(NodeInformation.class))
+ .or(() -> getOptional(NodeInformation.class))
.orElseThrow(() -> new IllegalStateException("WebServer not available in the container"));
}
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
index 9bbc457e8dd..1a350ccc8dc 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
@@ -51,6 +51,7 @@ import org.sonar.server.es.EsModule;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
import org.sonar.server.permission.index.WebAuthorizationTypeSupport;
+import org.sonar.server.platform.DefaultNodeInformation;
import org.sonar.server.platform.DockerSupportImpl;
import org.sonar.server.platform.LogServerVersion;
import org.sonar.server.platform.Platform;
@@ -58,7 +59,6 @@ import org.sonar.server.platform.ServerFileSystemImpl;
import org.sonar.server.platform.TempFolderProvider;
import org.sonar.server.platform.UrlSettings;
import org.sonar.server.platform.WebCoreExtensionsInstaller;
-import org.sonar.server.platform.WebServerImpl;
import org.sonar.server.platform.db.EmbeddedDatabaseFactory;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.setting.ThreadLocalSettings;
@@ -148,7 +148,7 @@ public class PlatformLevel1 extends PlatformLevel {
addAll(CorePropertyDefinitions.all());
// cluster
- add(WebServerImpl.class);
+ add(DefaultNodeInformation.class);
}
private void addExtraRootComponents() {
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevel2Test.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevel2Test.java
index 2b4344647da..24e40737207 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevel2Test.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevel2Test.java
@@ -26,7 +26,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.core.platform.SpringComponentContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.platform.db.migration.charset.DatabaseCharsetChecker;
import org.sonar.server.plugins.ServerPluginRepository;
@@ -60,12 +60,12 @@ public class PlatformLevel2Test {
var parentContainer = mock(SpringComponentContainer.class);
var container = mock(SpringComponentContainer.class);
var platform = mock(PlatformLevel.class);
- var webserver = mock(WebServer.class);
+ var webserver = mock(NodeInformation.class);
when(parentContainer.createChild()).thenReturn(container);
when(platform.getContainer()).thenReturn(parentContainer);
when(parentContainer.getOptionalComponentByType(any())).thenReturn(Optional.empty());
- when(container.getOptionalComponentByType(WebServer.class)).thenReturn(Optional.of(webserver));
+ when(container.getOptionalComponentByType(NodeInformation.class)).thenReturn(Optional.of(webserver));
when(webserver.isStartupLeader()).thenReturn(true);
PlatformLevel2 underTest = new PlatformLevel2(platform);
@@ -81,12 +81,12 @@ public class PlatformLevel2Test {
var parentContainer = mock(SpringComponentContainer.class);
var container = mock(SpringComponentContainer.class);
var platform = mock(PlatformLevel.class);
- var webserver = mock(WebServer.class);
+ var webserver = mock(NodeInformation.class);
when(parentContainer.createChild()).thenReturn(container);
when(platform.getContainer()).thenReturn(parentContainer);
when(parentContainer.getOptionalComponentByType(any())).thenReturn(Optional.empty());
- when(container.getOptionalComponentByType(WebServer.class)).thenReturn(Optional.of(webserver));
+ when(container.getOptionalComponentByType(NodeInformation.class)).thenReturn(Optional.of(webserver));
when(webserver.isStartupLeader()).thenReturn(false);
PlatformLevel2 underTest = new PlatformLevel2(platform);
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevelTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevelTest.java
index 3908150d902..a1a4b8e38d1 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevelTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/platformlevel/PlatformLevelTest.java
@@ -24,12 +24,11 @@ import java.util.stream.IntStream;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
-import static org.mockito.Mockito.mock;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
public class PlatformLevelTest {
@@ -61,7 +60,7 @@ public class PlatformLevelTest {
@Test
public void addIfStartupLeader_always_returns_the_same_instance() {
- underTest.add(mock(WebServer.class));
+ underTest.add(mock(NodeInformation.class));
PlatformLevel.AddIfStartupLeader addIfStartupLeader = underTest.addIfStartupLeader();
IntStream.range(0, 1 + new Random().nextInt(4)).forEach(i -> assertThat(underTest.addIfStartupLeader()).isSameAs(addIfStartupLeader));
@@ -76,7 +75,7 @@ public class PlatformLevelTest {
@Test
public void addIfCluster_always_returns_the_same_instance() {
- underTest.add(mock(WebServer.class));
+ underTest.add(mock(NodeInformation.class));
PlatformLevel.AddIfCluster addIfCluster = underTest.addIfCluster();
IntStream.range(0, 1 + new Random().nextInt(4)).forEach(i -> assertThat(underTest.addIfCluster()).isSameAs(addIfCluster));
@@ -91,7 +90,7 @@ public class PlatformLevelTest {
@Test
public void addIfStandalone_always_returns_the_same_instance() {
- underTest.add(mock(WebServer.class));
+ underTest.add(mock(NodeInformation.class));
PlatformLevel.AddIfCluster addIfCluster = underTest.addIfCluster();
IntStream.range(0, 1 + new Random().nextInt(4)).forEach(i -> assertThat(underTest.addIfCluster()).isSameAs(addIfCluster));