You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PlatformLevel2.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.platform.platformlevel;
  21. import org.sonar.api.utils.Durations;
  22. import org.sonar.core.extension.CoreExtensionsInstaller;
  23. import org.sonar.core.platform.ComponentContainer;
  24. import org.sonar.core.platform.PluginClassloaderFactory;
  25. import org.sonar.core.platform.PluginLoader;
  26. import org.sonar.server.es.MigrationEsClientImpl;
  27. import org.sonar.server.l18n.ServerI18n;
  28. import org.sonar.server.platform.DatabaseServerCompatibility;
  29. import org.sonar.server.platform.DefaultServerUpgradeStatus;
  30. import org.sonar.server.platform.OfficialDistribution;
  31. import org.sonar.server.platform.StartupMetadataProvider;
  32. import org.sonar.server.platform.WebCoreExtensionsInstaller;
  33. import org.sonar.server.platform.db.CheckDatabaseCharsetAtStartup;
  34. import org.sonar.server.platform.db.migration.DatabaseMigrationExecutorServiceImpl;
  35. import org.sonar.server.platform.db.migration.DatabaseMigrationStateImpl;
  36. import org.sonar.server.platform.db.migration.MigrationConfigurationModule;
  37. import org.sonar.server.platform.db.migration.charset.DatabaseCharsetChecker;
  38. import org.sonar.server.platform.db.migration.history.MigrationHistoryTable;
  39. import org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl;
  40. import org.sonar.server.platform.db.migration.version.DatabaseVersion;
  41. import org.sonar.server.platform.web.WebPagesCache;
  42. import org.sonar.server.plugins.InstalledPluginReferentialFactory;
  43. import org.sonar.server.plugins.PluginFileSystem;
  44. import org.sonar.server.plugins.ServerPluginJarExploder;
  45. import org.sonar.server.plugins.ServerPluginRepository;
  46. import org.sonar.server.plugins.WebServerExtensionInstaller;
  47. import static org.sonar.core.extension.CoreExtensionsInstaller.noAdditionalSideFilter;
  48. import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel;
  49. public class PlatformLevel2 extends PlatformLevel {
  50. public PlatformLevel2(PlatformLevel parent) {
  51. super("level2", parent);
  52. }
  53. @Override
  54. protected void configureLevel() {
  55. add(
  56. MigrationConfigurationModule.class,
  57. DatabaseVersion.class,
  58. DatabaseServerCompatibility.class,
  59. MigrationEsClientImpl.class,
  60. new StartupMetadataProvider(),
  61. DefaultServerUpgradeStatus.class,
  62. Durations.class,
  63. // index.html cache
  64. WebPagesCache.class,
  65. // plugins
  66. ServerPluginRepository.class,
  67. ServerPluginJarExploder.class,
  68. PluginLoader.class,
  69. PluginFileSystem.class,
  70. PluginClassloaderFactory.class,
  71. InstalledPluginReferentialFactory.class,
  72. WebServerExtensionInstaller.class,
  73. // depends on plugins
  74. ServerI18n.class,
  75. OfficialDistribution.class);
  76. // Migration state must be kept at level2 to survive moving in and then out of safe mode
  77. // ExecutorService must be kept at level2 because stopping it when stopping safe mode level causes error making SQ fail
  78. add(
  79. MigrationHistoryTableImpl.class,
  80. DatabaseMigrationStateImpl.class,
  81. DatabaseMigrationExecutorServiceImpl.class);
  82. addIfStartupLeader(
  83. DatabaseCharsetChecker.class,
  84. CheckDatabaseCharsetAtStartup.class);
  85. }
  86. @Override
  87. public PlatformLevel start() {
  88. // ensuring the HistoryTable exists must be the first thing done when this level is started
  89. getOptional(MigrationHistoryTable.class).ifPresent(MigrationHistoryTable::start);
  90. ComponentContainer container = getContainer();
  91. CoreExtensionsInstaller coreExtensionsInstaller = get(WebCoreExtensionsInstaller.class);
  92. coreExtensionsInstaller.install(container, hasPlatformLevel(2), noAdditionalSideFilter());
  93. return super.start();
  94. }
  95. }