SonarQube6.2源码解析(四)
生活随笔
收集整理的這篇文章主要介紹了
SonarQube6.2源码解析(四)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
sonar ce 的啟動過程
調(diào)用的類ComputeEngineImpl->ComputeEngine:
/** SonarQube* Copyright (C) 2009-2016 SonarSource SA* mailto:contact 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.ce;import org.sonar.ce.container.ComputeEngineContainer; import org.sonar.process.Props;import static com.google.common.base.Preconditions.checkState;public class ComputeEngineImpl implements ComputeEngine {private final Props props;private final ComputeEngineContainer computeEngineContainer;private Status status = Status.INIT;public ComputeEngineImpl(Props props, ComputeEngineContainer computeEngineContainer) {this.props = props;this.computeEngineContainer = computeEngineContainer;}@Overridepublic void startup() {checkState(this.status == Status.INIT, "startup() can not be called multiple times");try {this.status = Status.STARTING;this.computeEngineContainer.start(props);} finally {this.status = Status.STARTED;}}@Overridepublic void shutdown() {checkStateAsShutdown(this.status);try {this.status = Status.STOPPING;this.computeEngineContainer.stop();} finally {this.status = Status.STOPPED;}}private static void checkStateAsShutdown(Status currentStatus) {checkState(currentStatus.ordinal() >= Status.STARTED.ordinal(), "shutdown() must not be called before startup()");checkState(currentStatus.ordinal() <= Status.STOPPING.ordinal(), "shutdown() can not be called multiple times");}private enum Status {INIT, STARTING, STARTED, STOPPING, STOPPED} }調(diào)用ComputeEngineContainerImpl->ComputeEngineContainer
public class ComputeEngineContainerImpl implements ComputeEngineContainer {@CheckForNullprivate ComponentContainer level1;@CheckForNullprivate ComponentContainer level4;@Overridepublic ComputeEngineContainer start(Props props) {this.level1 = new ComponentContainer();this.level1.add(props.rawProperties()).add(level1Components()).add(toArray(CorePropertyDefinitions.all())).add(toArray(ClusterProperties.definitions()));configureFromModules(this.level1);this.level1.startComponents();ComponentContainer level2 = this.level1.createChild();level2.add(level2Components());configureFromModules(level2);level2.startComponents();ComponentContainer level3 = level2.createChild();level3.add(level3Components());configureFromModules(level3);level3.startComponents();this.level4 = level3.createChild();this.level4.add(level4Components());configureFromModules(this.level4);ServerExtensionInstaller extensionInstaller = this.level4.getComponentByType(ServerExtensionInstaller.class);extensionInstaller.installExtensions(this.level4);this.level4.startComponents();startupTasks();return this;}private void startupTasks() {ComponentContainer startupLevel = this.level4.createChild();startupLevel.add(startupComponents());startupLevel.startComponents();// done in PlatformLevelStartupServerLifecycleNotifier serverLifecycleNotifier = startupLevel.getComponentByType(ServerLifecycleNotifier.class);if (serverLifecycleNotifier != null) {serverLifecycleNotifier.notifyStart();}startupLevel.stopComponents();}@Overridepublic ComputeEngineContainer stop() {this.level1.stopComponents();return this;}@VisibleForTestingprotected ComponentContainer getComponentContainer() {return level4;}private static Object[] level1Components() {Version apiVersion = ApiVersion.load(System2.INSTANCE);return new Object[] {ThreadLocalSettings.class,new SonarQubeVersion(apiVersion),SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.COMPUTE_ENGINE),CeProcessLogging.class,UuidFactoryImpl.INSTANCE,ClusterImpl.class,LogbackHelper.class,DefaultDatabase.class,DatabaseChecker.class,// must instantiate deprecated class in 5.2 and only this one (and not its replacement)// to avoid having two SqlSessionFactory instancesorg.sonar.core.persistence.MyBatis.class,DatabaseServerCompatibility.class,DatabaseVersion.class,PurgeProfiler.class,ServerFileSystemImpl.class,new TempFolderProvider(),System2.INSTANCE,// user sessionCeUserSession.class,// DBDaoModule.class,ReadOnlyPropertiesDao.class,DbClient.class,// ElasticsearchEsSearchModule.class,// rules/qprofilesRuleIndex.class,ActiveRuleIndex.class,// issuesIssueIndex.class,new OkHttpClientProvider()};}private static Object[] level2Components() {return new Object[] {DatabaseSettingLoader.class,DatabaseSettingsEnabler.class,UrlSettings.class,// add ReadOnlyPropertiesDao at level2 again so that it shadows PropertiesDaoReadOnlyPropertiesDao.class,DefaultServerUpgradeStatus.class,// pluginsPluginClassloaderFactory.class,CePluginJarExploder.class,PluginLoader.class,CePluginRepository.class,InstalledPluginReferentialFactory.class,ComputeEngineExtensionInstaller.class,// depends on pluginsDefaultI18n.class, // used by RuleI18nManagerRuleI18nManager.class, // used by DebtRulesXMLImporterDurations.class, // used in Web Services and DebtCalculator};}private static Object[] level3Components() {return new Object[] {new StartupMetadataProvider(),ServerIdManager.class,UriReader.class,ServerImpl.class,DefaultOrganizationProviderImpl.class};}private static Object[] level4Components() {return new Object[] {ResourceTypes.class,DefaultResourceTypes.get(),Periods.class, // used by JRuby and EvaluationResultTextConverterImpl// quality profileActiveRuleIndexer.class,XMLProfileParser.class,XMLProfileSerializer.class,AnnotationProfileParser.class,Rules.QProfiles.class,QProfileLookup.class,QProfileProjectOperations.class,// ruleRuleIndexer.class,AnnotationRuleParser.class,XMLRuleParser.class,DefaultRuleFinder.class,DeprecatedRulesDefinitionLoader.class,CommonRuleDefinitionsImpl.class,RuleDefinitionsLoader.class,RulesDefinitionXmlLoader.class,// languagesLanguages.class, // used by CommonRuleDefinitionsImpl// measureCoreCustomMetrics.class,DefaultMetricFinder.class,// usersDeprecatedUserFinder.class,DefaultUserFinder.class,UserIndexer.class,UserIndex.class,// permissionsPermissionTemplateService.class,PermissionUpdater.class,UserPermissionChanger.class,GroupPermissionChanger.class,// componentsComponentFinder.class, // used in ComponentServiceComponentService.class, // used in ReportSubmitterNewAlerts.class,NewAlerts.newMetadata(),ComponentCleanerService.class,ProjectMeasuresIndexer.class,// viewsViewIndexer.class,ViewIndex.class,// issuesIssueIndexer.class,PermissionIndexer.class,IssueUpdater.class, // used in Web Services and CE's DebtCalculatorFunctionExecutor.class, // used by IssueWorkflowIssueWorkflow.class, // used in Web Services and CE's DebtCalculatorNewIssuesEmailTemplate.class,MyNewIssuesEmailTemplate.class,IssueChangesEmailTemplate.class,AlertsEmailTemplate.class,ChangesOnMyIssueNotificationDispatcher.class,ChangesOnMyIssueNotificationDispatcher.newMetadata(),NewIssuesNotificationDispatcher.class,NewIssuesNotificationDispatcher.newMetadata(),MyNewIssuesNotificationDispatcher.class,MyNewIssuesNotificationDispatcher.newMetadata(),DoNotFixNotificationDispatcher.class,DoNotFixNotificationDispatcher.newMetadata(),NewIssuesNotificationFactory.class, // used by SendIssueNotificationsStepEmailNotificationChannel.class,// technical debtDebtModelPluginRepository.class,DebtRulesXMLImporter.class,// NotificationsEmailSettings.class,NotificationService.class,NotificationCenter.class,DefaultNotificationManager.class,// TestsTestIndexer.class,// SystemServerLogging.class,// privileged pluginsPrivilegedPluginsBootstraper.class,PrivilegedPluginsStopper.class,// Compute engine (must be after Views and Developer Cockpit)CeConfigurationModule.class,CeQueueModule.class,CeHttpModule.class,CeTaskCommonsModule.class,ProjectAnalysisTaskModule.class,CeTaskProcessorModule.class,InternalPropertiesImpl.class,ProjectSettingsFactory.class,};}private static Object[] startupComponents() {return new Object[] {LogServerId.class,ServerLifecycleNotifier.class,PurgeCeActivities.class,};}private static Object[] toArray(List<?> list) {return list.toArray(new Object[list.size()]);}private static void configureFromModules(ComponentContainer container) {List<Module> modules = container.getComponentsByType(Module.class);for (Module module : modules) {module.configure(container);}} }start方法調(diào)用startTask方法總結(jié)
以上是生活随笔為你收集整理的SonarQube6.2源码解析(四)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OPPO Reno10 / Pro 系列
- 下一篇: 对于sonar展示的问题数的研究