--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import java.util.Collection;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.process.systeminfo.SystemInfoUtils;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
+import org.sonar.server.health.Health;
+import org.sonar.server.telemetry.TelemetryDataLoader;
+
+import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
+
+public abstract class AbstractSystemInfoWriter implements SystemInfoWriter {
+ private static final String[] ORDERED_SECTION_NAMES = {
+ // standalone
+ "System", "Database", "Plugins",
+
+ // cluster
+ "Web JVM State", "Web Database Connection", "Web Logging", "Web JVM Properties",
+ "Compute Engine Tasks", "Compute Engine JVM State", "Compute Engine Database Connection", "Compute Engine Logging", "Compute Engine JVM Properties",
+ "Search State", "Search Indexes"};
+
+ private final TelemetryDataLoader telemetry;
+
+ AbstractSystemInfoWriter(TelemetryDataLoader telemetry) {
+ this.telemetry = telemetry;
+ }
+
+ protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
+ SystemInfoUtils
+ .order(sections, ORDERED_SECTION_NAMES)
+ .forEach(section -> writeSection(section, json));
+ }
+
+ private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) {
+ json.name(section.getName());
+ json.beginObject();
+ for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) {
+ writeAttribute(attribute, json);
+ }
+ json.endObject();
+ }
+
+ private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
+ switch (attribute.getValueCase()) {
+ case BOOLEAN_VALUE:
+ json.prop(attribute.getKey(), attribute.getBooleanValue());
+ break;
+ case LONG_VALUE:
+ json.prop(attribute.getKey(), attribute.getLongValue());
+ break;
+ case DOUBLE_VALUE:
+ json.prop(attribute.getKey(), attribute.getDoubleValue());
+ break;
+ case STRING_VALUE:
+ json.prop(attribute.getKey(), attribute.getStringValue());
+ break;
+ case VALUE_NOT_SET:
+ json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray();
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase());
+ }
+ }
+
+ protected void writeHealth(Health health, JsonWriter json) {
+ json.prop("Health", health.getStatus().name());
+ json.name("Health Causes").beginArray().values(health.getCauses()).endArray();
+ }
+
+ protected void writeTelemetry(JsonWriter json) {
+ json.name("Statistics");
+ writeTelemetryData(json, telemetry.load());
+ }
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import org.sonar.core.platform.Module;
-import org.sonar.server.platform.WebServer;
-
-public class ChangeLogLevelActionModule extends Module {
- private final WebServer webServer;
-
- public ChangeLogLevelActionModule(WebServer webServer) {
- this.webServer = webServer;
- }
-
- @Override
- protected void configureModule() {
- add(ChangeLogLevelAction.class);
- if (webServer.isStandalone()) {
- add(ChangeLogLevelStandaloneService.class);
- } else {
- add(ChangeLogLevelClusterService.class);
- }
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+import org.sonar.server.platform.WebServer;
+
+public class ChangeLogLevelServiceModule extends Module {
+ private final WebServer webServer;
+
+ public ChangeLogLevelServiceModule(WebServer webServer) {
+ this.webServer = webServer;
+ }
+
+ @Override
+ protected void configureModule() {
+ if (webServer.isStandalone()) {
+ add(ChangeLogLevelStandaloneService.class);
+ } else {
+ add(ChangeLogLevelClusterService.class);
+ }
+ }
+}
import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoader;
import org.sonar.server.telemetry.TelemetryDataLoader;
-public class ClusterSystemInfoWriter extends SystemInfoWriter {
+public class ClusterSystemInfoWriter extends AbstractSystemInfoWriter {
private final GlobalInfoLoader globalInfoLoader;
private final AppNodesInfoLoader appNodesInfoLoader;
private final SearchNodesInfoLoader searchNodesInfoLoader;
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import org.sonar.core.platform.Module;
-import org.sonar.server.health.AppNodeClusterCheck;
-import org.sonar.server.health.CeStatusNodeCheck;
-import org.sonar.server.health.DbConnectionNodeCheck;
-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;
-
-public class HealthActionModule extends Module {
- private final WebServer webServer;
-
- public HealthActionModule(WebServer webServer) {
- this.webServer = webServer;
- }
-
- @Override
- protected void configureModule() {
- // NodeHealthCheck implementations
- add(WebServerStatusNodeCheck.class,
- DbConnectionNodeCheck.class,
- CeStatusNodeCheck.class);
- if (webServer.isStandalone()) {
- add(EsStatusNodeCheck.class);
- } else {
- // ClusterHealthCheck implementations
- add(EsStatusClusterCheck.class,
- AppNodeClusterCheck.class);
- }
-
- add(HealthCheckerImpl.class,
- HealthActionSupport.class,
- HealthAction.class);
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+import org.sonar.server.health.AppNodeClusterCheck;
+import org.sonar.server.health.CeStatusNodeCheck;
+import org.sonar.server.health.DbConnectionNodeCheck;
+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;
+
+public class HealthCheckerModule extends Module {
+ private final WebServer webServer;
+
+ public HealthCheckerModule(WebServer webServer) {
+ this.webServer = webServer;
+ }
+
+ @Override
+ protected void configureModule() {
+ // NodeHealthCheck implementations
+ add(WebServerStatusNodeCheck.class,
+ DbConnectionNodeCheck.class,
+ CeStatusNodeCheck.class);
+ if (webServer.isStandalone()) {
+ add(EsStatusNodeCheck.class);
+ } else {
+ // ClusterHealthCheck implementations
+ add(EsStatusClusterCheck.class,
+ AppNodeClusterCheck.class);
+ }
+
+ add(HealthCheckerImpl.class);
+ }
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import org.sonar.core.platform.Module;
-import org.sonar.server.health.DbConnectionNodeCheck;
-import org.sonar.server.health.EsStatusNodeCheck;
-import org.sonar.server.health.HealthCheckerImpl;
-import org.sonar.server.health.WebServerSafemodeNodeCheck;
-
-public class SafeModeHealthActionModule extends Module {
- @Override
- protected void configureModule() {
- add(
- // NodeHealthCheck implementations
- WebServerSafemodeNodeCheck.class,
- DbConnectionNodeCheck.class,
- EsStatusNodeCheck.class,
-
- HealthCheckerImpl.class,
- HealthActionSupport.class,
- SafeModeHealthAction.class);
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+import org.sonar.server.health.DbConnectionNodeCheck;
+import org.sonar.server.health.EsStatusNodeCheck;
+import org.sonar.server.health.HealthCheckerImpl;
+import org.sonar.server.health.WebServerSafemodeNodeCheck;
+
+public class SafeModeHealthCheckerModule extends Module {
+ @Override
+ protected void configureModule() {
+ add(
+ // NodeHealthCheck implementations
+ WebServerSafemodeNodeCheck.class,
+ DbConnectionNodeCheck.class,
+ EsStatusNodeCheck.class,
+
+ HealthCheckerImpl.class);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+
+public class SafemodeSystemWsModule extends Module {
+ @Override
+ protected void configureModule() {
+ add(
+ StatusAction.class,
+ MigrateDbAction.class,
+ DbMigrationStatusAction.class,
+ HealthActionSupport.class,
+ SafeModeHealthAction.class,
+ SystemWs.class
+
+ );
+ }
+}
import static java.util.Arrays.stream;
-public class StandaloneSystemInfoWriter extends SystemInfoWriter {
+public class StandaloneSystemInfoWriter extends AbstractSystemInfoWriter {
private final CeHttpClient ceHttpClient;
private final HealthChecker healthChecker;
private final SystemInfoSection[] systemInfoSections;
*/
package org.sonar.server.platform.ws;
-import java.util.Collection;
import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.process.systeminfo.SystemInfoUtils;
-import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
-import org.sonar.server.health.Health;
-import org.sonar.server.telemetry.TelemetryDataLoader;
-import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
-
-public abstract class SystemInfoWriter {
- private static final String[] ORDERED_SECTION_NAMES = {
- // standalone
- "System", "Database", "Plugins",
-
- // cluster
- "Web JVM State", "Web Database Connection", "Web Logging", "Web JVM Properties",
- "Compute Engine Tasks", "Compute Engine JVM State", "Compute Engine Database Connection", "Compute Engine Logging", "Compute Engine JVM Properties",
- "Search State", "Search Indexes"};
-
- private final TelemetryDataLoader telemetry;
-
- SystemInfoWriter(TelemetryDataLoader telemetry) {
- this.telemetry = telemetry;
- }
-
- public abstract void write(JsonWriter json) throws Exception;
-
- protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
- SystemInfoUtils
- .order(sections, ORDERED_SECTION_NAMES)
- .forEach(section -> writeSection(section, json));
- }
-
- private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) {
- json.name(section.getName());
- json.beginObject();
- for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) {
- writeAttribute(attribute, json);
- }
- json.endObject();
- }
-
- private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
- switch (attribute.getValueCase()) {
- case BOOLEAN_VALUE:
- json.prop(attribute.getKey(), attribute.getBooleanValue());
- break;
- case LONG_VALUE:
- json.prop(attribute.getKey(), attribute.getLongValue());
- break;
- case DOUBLE_VALUE:
- json.prop(attribute.getKey(), attribute.getDoubleValue());
- break;
- case STRING_VALUE:
- json.prop(attribute.getKey(), attribute.getStringValue());
- break;
- case VALUE_NOT_SET:
- json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray();
- break;
- default:
- throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase());
- }
- }
-
- protected void writeHealth(Health health, JsonWriter json) {
- json.prop("Health", health.getStatus().name());
- json.name("Health Causes").beginArray().values(health.getCauses()).endArray();
- }
-
- protected void writeTelemetry(JsonWriter json) {
- json.name("Statistics");
- writeTelemetryData(json, telemetry.load());
- }
+public interface SystemInfoWriter {
+ void write(JsonWriter json) throws Exception;
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+import org.sonar.process.systeminfo.JvmPropertiesSection;
+import org.sonar.process.systeminfo.JvmStateSection;
+import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.monitoring.DbConnectionSection;
+import org.sonar.server.platform.monitoring.DbSection;
+import org.sonar.server.platform.monitoring.EsIndexesSection;
+import org.sonar.server.platform.monitoring.EsStateSection;
+import org.sonar.server.platform.monitoring.LoggingSection;
+import org.sonar.server.platform.monitoring.PluginsSection;
+import org.sonar.server.platform.monitoring.SettingsSection;
+import org.sonar.server.platform.monitoring.StandaloneSystemSection;
+import org.sonar.server.platform.monitoring.cluster.AppNodesInfoLoaderImpl;
+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.NodeSystemSection;
+import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
+import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl;
+
+public class SystemInfoWriterModule extends Module {
+ private final WebServer webServer;
+
+ public SystemInfoWriterModule(WebServer webServer) {
+ this.webServer = webServer;
+ }
+
+ @Override
+ protected void configureModule() {
+ boolean standalone = webServer.isStandalone();
+
+ add(
+ new JvmPropertiesSection("Web JVM Properties"),
+ new JvmStateSection("Web JVM State"),
+ DbSection.class,
+ DbConnectionSection.class,
+ EsIndexesSection.class,
+ LoggingSection.class,
+ PluginsSection.class,
+ SettingsSection.class
+
+ );
+ if (standalone) {
+ add(
+ EsStateSection.class,
+ StandaloneSystemSection.class,
+ StandaloneSystemInfoWriter.class
+
+ );
+ } else {
+ add(
+ CeQueueGlobalSection.class,
+ EsClusterStateSection.class,
+ GlobalSystemSection.class,
+ NodeSystemSection.class,
+
+ ProcessInfoProvider.class,
+ GlobalInfoLoader.class,
+ AppNodesInfoLoaderImpl.class,
+ SearchNodesInfoLoaderImpl.class,
+ ClusterSystemInfoWriter.class
+
+ );
+ }
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.sonar.core.platform.Module;
+
+public class SystemWsModule extends Module {
+
+ @Override
+ protected void configureModule() {
+ add(
+ ChangeLogLevelAction.class,
+ DbMigrationStatusAction.class,
+ HealthActionSupport.class,
+ HealthAction.class,
+ InfoAction.class,
+ LogsAction.class,
+ MigrateDbAction.class,
+ PingAction.class,
+ RestartAction.class,
+ StatusAction.class,
+ UpgradesAction.class,
+ SystemWs.class
+
+ );
+ }
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import org.sonar.api.config.Configuration;
-import org.sonar.core.platform.Module;
-import org.sonar.process.systeminfo.JvmPropertiesSection;
-import org.sonar.process.systeminfo.JvmStateSection;
-import org.sonar.server.platform.WebServer;
-import org.sonar.server.platform.monitoring.DbConnectionSection;
-import org.sonar.server.platform.monitoring.DbSection;
-import org.sonar.server.platform.monitoring.EsIndexesSection;
-import org.sonar.server.platform.monitoring.EsStateSection;
-import org.sonar.server.platform.monitoring.LoggingSection;
-import org.sonar.server.platform.monitoring.PluginsSection;
-import org.sonar.server.platform.monitoring.SettingsSection;
-import org.sonar.server.platform.monitoring.StandaloneSystemSection;
-import org.sonar.server.platform.monitoring.cluster.AppNodesInfoLoaderImpl;
-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.NodeSystemSection;
-import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
-import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl;
-
-public class WebSystemInfoModule extends Module {
- private final WebServer webServer;
-
- public WebSystemInfoModule(WebServer webServer) {
- this.webServer = webServer;
- }
-
- @Override
- protected void configureModule() {
- boolean standalone = webServer.isStandalone();
-
- add(
- new JvmPropertiesSection("Web JVM Properties"),
- new JvmStateSection("Web JVM State"),
- DbSection.class,
- DbConnectionSection.class,
- EsIndexesSection.class,
- LoggingSection.class,
- PluginsSection.class,
- SettingsSection.class,
- InfoAction.class
-
- );
- if (standalone) {
- add(
- EsStateSection.class,
- StandaloneSystemSection.class,
- StandaloneSystemInfoWriter.class
-
- );
- } else {
- add(
- CeQueueGlobalSection.class,
- EsClusterStateSection.class,
- GlobalSystemSection.class,
- NodeSystemSection.class,
-
- ProcessInfoProvider.class,
- GlobalInfoLoader.class,
- AppNodesInfoLoaderImpl.class,
- SearchNodesInfoLoaderImpl.class,
- ClusterSystemInfoWriter.class
-
- );
- }
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import java.util.Collection;
-import org.junit.Test;
-import org.picocontainer.ComponentAdapter;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.platform.WebServer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
-
-public class ChangeLogLevelActionModuleTest {
- private WebServer webServer = mock(WebServer.class);
- private ChangeLogLevelActionModule underTest = new ChangeLogLevelActionModule(webServer);
-
- @Test
- public void provide_returns_ChangeLogLevelClusterService_if_cluster_not_on_SonarCloud() {
- when(webServer.isStandalone()).thenReturn(false);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
- assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2)
- .extracting(ComponentAdapter::getComponentKey)
- .contains(ChangeLogLevelClusterService.class, ChangeLogLevelAction.class)
- .doesNotContain(ChangeLogLevelStandaloneService.class);
- }
-
- @Test
- public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- verifyInStandaloneSQ(container);
- }
-
- private void verifyInStandaloneSQ(ComponentContainer container) {
- Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
- assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2)
- .extracting(ComponentAdapter::getComponentKey)
- .contains(ChangeLogLevelStandaloneService.class, ChangeLogLevelAction.class)
- .doesNotContain(ChangeLogLevelClusterService.class);
- }
-
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import java.util.Collection;
+import org.junit.Test;
+import org.picocontainer.ComponentAdapter;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.platform.WebServer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class ChangeLogLevelServiceModuleTest {
+ private WebServer webServer = mock(WebServer.class);
+ private ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(webServer);
+
+ @Test
+ public void provide_returns_ChangeLogLevelClusterService_if_cluster_not_on_SonarCloud() {
+ when(webServer.isStandalone()).thenReturn(false);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
+ assertThat(adapters)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 1)
+ .extracting(ComponentAdapter::getComponentKey)
+ .contains(ChangeLogLevelClusterService.class)
+ .doesNotContain(ChangeLogLevelStandaloneService.class);
+ }
+
+ @Test
+ public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone() {
+ when(webServer.isStandalone()).thenReturn(true);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ verifyInStandaloneSQ(container);
+ }
+
+ private void verifyInStandaloneSQ(ComponentContainer container) {
+ Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
+ assertThat(adapters)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 1)
+ .extracting(ComponentAdapter::getComponentKey)
+ .contains(ChangeLogLevelStandaloneService.class)
+ .doesNotContain(ChangeLogLevelClusterService.class);
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Random;
-import java.util.stream.Collectors;
-import org.junit.Test;
-import org.picocontainer.ComponentAdapter;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.health.AppNodeClusterCheck;
-import org.sonar.server.health.CeStatusNodeCheck;
-import org.sonar.server.health.ClusterHealthCheck;
-import org.sonar.server.health.DbConnectionNodeCheck;
-import org.sonar.server.health.EsStatusClusterCheck;
-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.server.platform.WebServer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class HealthActionModuleTest {
- private WebServer webServer = mock(WebServer.class);
- private HealthActionModule underTest = new HealthActionModule(webServer);
-
- @Test
- public void verify_action_and_HealthChecker() {
- boolean standalone = new Random().nextBoolean();
- when(webServer.isStandalone()).thenReturn(standalone);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- assertThat(classesAddedToContainer(container))
- .describedAs("Verifying action and HealthChecker with standalone=%s", standalone)
- .contains(HealthCheckerImpl.class)
- .contains(HealthActionSupport.class)
- .contains(HealthAction.class)
- .doesNotContain(SafeModeHealthAction.class);
- }
-
- @Test
- public void verify_installed_NodeHealthChecks_implementations_when_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
- assertThat(checks)
- .hasSize(4)
- .contains(WebServerStatusNodeCheck.class)
- .contains(DbConnectionNodeCheck.class)
- .contains(EsStatusNodeCheck.class)
- .contains(CeStatusNodeCheck.class);
- }
-
- @Test
- public void verify_installed_NodeHealthChecks_implementations_when_clustered() {
- when(webServer.isStandalone()).thenReturn(false);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
- assertThat(checks)
- .hasSize(3)
- .contains(WebServerStatusNodeCheck.class)
- .contains(DbConnectionNodeCheck.class)
- .contains(CeStatusNodeCheck.class)
- .doesNotContain(EsStatusNodeCheck.class);
- }
-
- @Test
- public void verify_installed_ClusterHealthChecks_implementations_in_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- List<Class<?>> checks = classesAddedToContainer(container).stream().filter(ClusterHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
- assertThat(checks).isEmpty();
- }
-
- @Test
- public void verify_installed_ClusterHealthChecks_implementations_in_clustering() {
- when(webServer.isStandalone()).thenReturn(false);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- List<Class<?>> checks = classesAddedToContainer(container).stream().filter(ClusterHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
- assertThat(checks)
- .hasSize(2)
- .contains(EsStatusClusterCheck.class)
- .contains(AppNodeClusterCheck.class);
- }
-
- private List<Class<?>> classesAddedToContainer(ComponentContainer container) {
- Collection<ComponentAdapter<?>> componentAdapters = container.getPicoContainer().getComponentAdapters();
- return componentAdapters.stream().map(ComponentAdapter::getComponentImplementation).collect(Collectors.toList());
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+import java.util.stream.Collectors;
+import org.junit.Test;
+import org.picocontainer.ComponentAdapter;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.health.AppNodeClusterCheck;
+import org.sonar.server.health.CeStatusNodeCheck;
+import org.sonar.server.health.ClusterHealthCheck;
+import org.sonar.server.health.DbConnectionNodeCheck;
+import org.sonar.server.health.EsStatusClusterCheck;
+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.server.platform.WebServer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HealthCheckerModuleTest {
+ private WebServer webServer = mock(WebServer.class);
+ private HealthCheckerModule underTest = new HealthCheckerModule(webServer);
+
+ @Test
+ public void verify_HealthChecker() {
+ boolean standalone = new Random().nextBoolean();
+ when(webServer.isStandalone()).thenReturn(standalone);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ assertThat(classesAddedToContainer(container))
+ .describedAs("Verifying action and HealthChecker with standalone=%s", standalone)
+ .contains(HealthCheckerImpl.class)
+ .doesNotContain(HealthActionSupport.class)
+ .doesNotContain(HealthAction.class)
+ .doesNotContain(SafeModeHealthAction.class);
+ }
+
+ @Test
+ public void verify_installed_NodeHealthChecks_implementations_when_standalone() {
+ when(webServer.isStandalone()).thenReturn(true);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
+ assertThat(checks)
+ .hasSize(4)
+ .contains(WebServerStatusNodeCheck.class)
+ .contains(DbConnectionNodeCheck.class)
+ .contains(EsStatusNodeCheck.class)
+ .contains(CeStatusNodeCheck.class);
+ }
+
+ @Test
+ public void verify_installed_NodeHealthChecks_implementations_when_clustered() {
+ when(webServer.isStandalone()).thenReturn(false);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
+ assertThat(checks)
+ .hasSize(3)
+ .contains(WebServerStatusNodeCheck.class)
+ .contains(DbConnectionNodeCheck.class)
+ .contains(CeStatusNodeCheck.class)
+ .doesNotContain(EsStatusNodeCheck.class);
+ }
+
+ @Test
+ public void verify_installed_ClusterHealthChecks_implementations_in_standalone() {
+ when(webServer.isStandalone()).thenReturn(true);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ List<Class<?>> checks = classesAddedToContainer(container).stream().filter(ClusterHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
+ assertThat(checks).isEmpty();
+ }
+
+ @Test
+ public void verify_installed_ClusterHealthChecks_implementations_in_clustering() {
+ when(webServer.isStandalone()).thenReturn(false);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ List<Class<?>> checks = classesAddedToContainer(container).stream().filter(ClusterHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
+ assertThat(checks)
+ .hasSize(2)
+ .contains(EsStatusClusterCheck.class)
+ .contains(AppNodeClusterCheck.class);
+ }
+
+ private List<Class<?>> classesAddedToContainer(ComponentContainer container) {
+ Collection<ComponentAdapter<?>> componentAdapters = container.getPicoContainer().getComponentAdapters();
+ return componentAdapters.stream().map(ComponentAdapter::getComponentImplementation).collect(Collectors.toList());
+ }
+}
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private SystemInfoWriter jsonWriter = new SystemInfoWriter(null) {
+ private SystemInfoWriter jsonWriter = new AbstractSystemInfoWriter(null) {
@Override
public void write(JsonWriter json) {
json.prop("key", "value");
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.Test;
-import org.picocontainer.ComponentAdapter;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.health.DbConnectionNodeCheck;
-import org.sonar.server.health.EsStatusNodeCheck;
-import org.sonar.server.health.HealthCheckerImpl;
-import org.sonar.server.health.NodeHealthCheck;
-import org.sonar.server.health.WebServerSafemodeNodeCheck;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SafeModeHealthActionModuleTest {
- private SafeModeHealthActionModule underTest = new SafeModeHealthActionModule();
-
- @Test
- public void verify_action_and_HealthChecker() {
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- assertThat(classesAddedToContainer(container))
- .contains(HealthCheckerImpl.class)
- .contains(HealthActionSupport.class)
- .contains(SafeModeHealthAction.class)
- .doesNotContain(HealthAction.class);
- }
-
- @Test
- public void verify_installed_HealthChecks_implementations() {
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
- assertThat(checks)
- .hasSize(3)
- .contains(WebServerSafemodeNodeCheck.class)
- .contains(DbConnectionNodeCheck.class)
- .contains(EsStatusNodeCheck.class);
- }
-
- private List<Class<?>> classesAddedToContainer(ComponentContainer container) {
- Collection<ComponentAdapter<?>> componentAdapters = container.getPicoContainer().getComponentAdapters();
- return componentAdapters.stream().map(ComponentAdapter::getComponentImplementation).collect(Collectors.toList());
- }
-
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.Test;
+import org.picocontainer.ComponentAdapter;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.health.DbConnectionNodeCheck;
+import org.sonar.server.health.EsStatusNodeCheck;
+import org.sonar.server.health.HealthCheckerImpl;
+import org.sonar.server.health.NodeHealthCheck;
+import org.sonar.server.health.WebServerSafemodeNodeCheck;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SafeModeHealthCheckerModuleTest {
+ private SafeModeHealthCheckerModule underTest = new SafeModeHealthCheckerModule();
+
+ @Test
+ public void verify_HealthChecker() {
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ assertThat(classesAddedToContainer(container))
+ .contains(HealthCheckerImpl.class)
+ .doesNotContain(HealthActionSupport.class)
+ .doesNotContain(SafeModeHealthAction.class)
+ .doesNotContain(HealthAction.class);
+ }
+
+ @Test
+ public void verify_installed_HealthChecks_implementations() {
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ List<Class<?>> checks = classesAddedToContainer(container).stream().filter(NodeHealthCheck.class::isAssignableFrom).collect(Collectors.toList());
+ assertThat(checks)
+ .hasSize(3)
+ .contains(WebServerSafemodeNodeCheck.class)
+ .contains(DbConnectionNodeCheck.class)
+ .contains(EsStatusNodeCheck.class);
+ }
+
+ private List<Class<?>> classesAddedToContainer(ComponentContainer container) {
+ Collection<ComponentAdapter<?>> componentAdapters = container.getPicoContainer().getComponentAdapters();
+ return componentAdapters.stream().map(ComponentAdapter::getComponentImplementation).collect(Collectors.toList());
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class SafemodeSystemWsModuleTest {
+ @Test
+ public void verify_count_of_added_components() {
+ ComponentContainer container = new ComponentContainer();
+ new SafemodeSystemWsModule().configure(container);
+ assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 6);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import java.util.Collection;
+import org.junit.Test;
+import org.picocontainer.ComponentAdapter;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.server.platform.WebServer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class SystemInfoWriterModuleTest {
+ private WebServer webServer = mock(WebServer.class);
+ private SystemInfoWriterModule underTest = new SystemInfoWriterModule(webServer);
+
+ @Test
+ public void verify_system_info_configuration_in_cluster_mode() {
+ when(webServer.isStandalone()).thenReturn(false);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
+ assertThat(adapters)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 17);
+ }
+
+ @Test
+ public void verify_system_info_configuration_in_standalone_mode() {
+ when(webServer.isStandalone()).thenReturn(true);
+ ComponentContainer container = new ComponentContainer();
+
+ underTest.configure(container);
+
+ verifyConfigurationStandaloneSQ(container);
+ }
+
+ public void verifyConfigurationStandaloneSQ(ComponentContainer container) {
+ Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
+ assertThat(adapters)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 11);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class SystemWsModuleTest {
+ @Test
+ public void verify_count_of_added_components() {
+ ComponentContainer container = new ComponentContainer();
+ new SystemWsModule().configure(container);
+ assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
+ }
+
+
+}
public void define() {
RestartAction action1 = new RestartAction(mock(UserSession.class), mock(ProcessCommandWrapper.class),
mock(RestartFlagHolder.class), mock(WebServer.class));
- InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(SystemInfoWriter.class));
+ InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(AbstractSystemInfoWriter.class));
SystemWs ws = new SystemWs(action1, action2);
WebService.Context context = new WebService.Context();
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.ws;
-
-import java.util.Collection;
-import org.junit.Test;
-import org.picocontainer.ComponentAdapter;
-import org.sonar.core.platform.ComponentContainer;
-import org.sonar.server.platform.WebServer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
-
-public class WebSystemInfoModuleTest {
- private WebServer webServer = mock(WebServer.class);
- private WebSystemInfoModule underTest = new WebSystemInfoModule(webServer);
-
- @Test
- public void verify_system_info_configuration_in_cluster_mode() {
- when(webServer.isStandalone()).thenReturn(false);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
- assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 18);
- }
-
- @Test
- public void verify_system_info_configuration_in_standalone_mode() {
- when(webServer.isStandalone()).thenReturn(true);
- ComponentContainer container = new ComponentContainer();
-
- underTest.configure(container);
-
- verifyConfigurationStandaloneSQ(container);
- }
-
- public void verifyConfigurationStandaloneSQ(ComponentContainer container) {
- Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
- assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
- }
-
-}
import org.sonar.server.platform.web.WebServiceFilter;
import org.sonar.server.platform.web.WebServiceReroutingFilter;
import org.sonar.server.platform.web.requestid.HttpRequestIdModule;
-import org.sonar.server.platform.ws.ChangeLogLevelActionModule;
-import org.sonar.server.platform.ws.DbMigrationStatusAction;
-import org.sonar.server.platform.ws.HealthActionModule;
+import org.sonar.server.platform.ws.ChangeLogLevelServiceModule;
+import org.sonar.server.platform.ws.HealthCheckerModule;
import org.sonar.server.platform.ws.L10nWs;
-import org.sonar.server.platform.ws.LogsAction;
-import org.sonar.server.platform.ws.MigrateDbAction;
-import org.sonar.server.platform.ws.PingAction;
-import org.sonar.server.platform.ws.RestartAction;
import org.sonar.server.platform.ws.ServerWs;
-import org.sonar.server.platform.ws.StatusAction;
-import org.sonar.server.platform.ws.SystemWs;
-import org.sonar.server.platform.ws.UpgradesAction;
-import org.sonar.server.platform.ws.WebSystemInfoModule;
+import org.sonar.server.platform.ws.SystemWsModule;
+import org.sonar.server.platform.ws.SystemInfoWriterModule;
import org.sonar.server.plugins.PluginDownloader;
import org.sonar.server.plugins.PluginUninstaller;
import org.sonar.server.plugins.ServerExtensionInstaller;
// System
ServerLogging.class,
- RestartAction.class,
- PingAction.class,
- UpgradesAction.class,
- StatusAction.class,
- MigrateDbAction.class,
- LogsAction.class,
- ChangeLogLevelActionModule.class,
- DbMigrationStatusAction.class,
- HealthActionModule.class,
- SystemWs.class,
+ ChangeLogLevelServiceModule.class,
+ HealthCheckerModule.class,
+ SystemWsModule.class,
// Plugins WS
PluginUpdateAggregator.class,
);
// system info
- add(WebSystemInfoModule.class);
+ add(SystemInfoWriterModule.class);
addAll(level4AddedComponents);
}
import org.sonar.server.platform.db.migration.MigrationEngineModule;
import org.sonar.server.platform.db.migration.NoopDatabaseMigrationImpl;
import org.sonar.server.platform.web.WebServiceFilter;
-import org.sonar.server.platform.ws.DbMigrationStatusAction;
import org.sonar.server.platform.ws.IndexAction;
import org.sonar.server.platform.ws.L10nWs;
-import org.sonar.server.platform.ws.MigrateDbAction;
-import org.sonar.server.platform.ws.SafeModeHealthActionModule;
-import org.sonar.server.platform.ws.StatusAction;
-import org.sonar.server.platform.ws.SystemWs;
+import org.sonar.server.platform.ws.SafeModeHealthCheckerModule;
+import org.sonar.server.platform.ws.SafemodeSystemWsModule;
import org.sonar.server.ws.WebServiceEngine;
import org.sonar.server.ws.ws.WebServicesWsModule;
IndexAction.class,
// Server WS
- StatusAction.class,
- MigrateDbAction.class,
- DbMigrationStatusAction.class,
- SafeModeHealthActionModule.class,
- SystemWs.class,
+ SafeModeHealthCheckerModule.class,
+ SafemodeSystemWsModule.class,
// Listing WS
WebServicesWsModule.class,