Search in sources :

Example 1 with AppSettings

use of org.sonar.application.config.AppSettings in project sonarqube by SonarSource.

the class AppReloaderImpl method reload.

@Override
public void reload(AppSettings settings) throws IOException {
    if (ClusterSettings.isClusterEnabled(settings)) {
        throw new IllegalStateException("Restart is not possible with cluster mode");
    }
    AppSettings reloaded = settingsLoader.load();
    ensureUnchangedConfiguration(settings.getProps(), reloaded.getProps());
    settings.reload(reloaded.getProps());
    fileSystem.reset();
    logging.configure();
    appState.reset();
}
Also used : AppSettings(org.sonar.application.config.AppSettings)

Example 2 with AppSettings

use of org.sonar.application.config.AppSettings in project sonarqube by SonarSource.

the class AppReloaderImplTest method reload_configuration_then_reset_all.

@Test
public void reload_configuration_then_reset_all() throws IOException {
    AppSettings settings = new TestAppSettings().set("foo", "bar");
    AppSettings newSettings = new TestAppSettings().set("foo", "newBar").set("newProp", "newVal");
    when(settingsLoader.load()).thenReturn(newSettings);
    underTest.reload(settings);
    assertThat(settings.getProps().rawProperties()).contains(entry("foo", "newBar")).contains(entry("newProp", "newVal"));
    verify(logging).configure();
    verify(state).reset();
    verify(fs).reset();
}
Also used : AppSettings(org.sonar.application.config.AppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings) Test(org.junit.Test)

Example 3 with AppSettings

use of org.sonar.application.config.AppSettings in project sonarqube by SonarSource.

the class AppReloaderImplTest method verifyFailureIfPropertyValueChanged.

private void verifyFailureIfPropertyValueChanged(String propertyKey) throws IOException {
    AppSettings settings = new TestAppSettings().set(propertyKey, "val1");
    AppSettings newSettings = new TestAppSettings().set(propertyKey, "val2");
    when(settingsLoader.load()).thenReturn(newSettings);
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Property [" + propertyKey + "] cannot be changed on restart: [val1] => [val2]");
    underTest.reload(settings);
    verifyZeroInteractions(logging);
    verifyZeroInteractions(state);
    verifyZeroInteractions(fs);
}
Also used : AppSettings(org.sonar.application.config.AppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings)

Example 4 with AppSettings

use of org.sonar.application.config.AppSettings in project sonarqube by SonarSource.

the class AppReloaderImplTest method throw_ISE_if_cluster_is_enabled.

@Test
public void throw_ISE_if_cluster_is_enabled() throws IOException {
    AppSettings settings = new TestAppSettings().set(ProcessProperties.CLUSTER_ENABLED, "true");
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Restart is not possible with cluster mode");
    underTest.reload(settings);
    verifyZeroInteractions(logging);
    verifyZeroInteractions(state);
    verifyZeroInteractions(fs);
}
Also used : AppSettings(org.sonar.application.config.AppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings) TestAppSettings(org.sonar.application.config.TestAppSettings) Test(org.junit.Test)

Example 5 with AppSettings

use of org.sonar.application.config.AppSettings in project sonarqube by SonarSource.

the class App method start.

public void start(String[] cliArguments) throws IOException {
    AppSettingsLoader settingsLoader = new AppSettingsLoaderImpl(cliArguments);
    AppSettings settings = settingsLoader.load();
    // order is important - logging must be configured before any other components (AppFileSystem, ...)
    AppLogging logging = new AppLogging(settings);
    logging.configure();
    AppFileSystem fileSystem = new AppFileSystem(settings);
    try (AppState appState = new AppStateFactory(settings).create()) {
        appState.registerSonarQubeVersion(getSonarqubeVersion());
        AppReloader appReloader = new AppReloaderImpl(settingsLoader, fileSystem, appState, logging);
        JavaCommandFactory javaCommandFactory = new JavaCommandFactoryImpl(settings);
        fileSystem.reset();
        try (JavaProcessLauncher javaProcessLauncher = new JavaProcessLauncherImpl(fileSystem.getTempDir())) {
            Scheduler scheduler = new SchedulerImpl(settings, appReloader, javaCommandFactory, javaProcessLauncher, appState);
            // intercepts CTRL-C
            Runtime.getRuntime().addShutdownHook(new ShutdownHook(scheduler));
            scheduler.schedule();
            stopRequestWatcher = StopRequestWatcherImpl.create(settings, scheduler, fileSystem);
            stopRequestWatcher.startWatching();
            scheduler.awaitTermination();
            stopRequestWatcher.stopWatching();
        }
        systemExit.exit(0);
    }
}
Also used : JavaCommandFactoryImpl(org.sonar.application.process.JavaCommandFactoryImpl) AppSettings(org.sonar.application.config.AppSettings) AppSettingsLoader(org.sonar.application.config.AppSettingsLoader) JavaProcessLauncherImpl(org.sonar.application.process.JavaProcessLauncherImpl) AppSettingsLoaderImpl(org.sonar.application.config.AppSettingsLoaderImpl) JavaProcessLauncher(org.sonar.application.process.JavaProcessLauncher) JavaCommandFactory(org.sonar.application.process.JavaCommandFactory)

Aggregations

AppSettings (org.sonar.application.config.AppSettings)5 TestAppSettings (org.sonar.application.config.TestAppSettings)3 Test (org.junit.Test)2 AppSettingsLoader (org.sonar.application.config.AppSettingsLoader)1 AppSettingsLoaderImpl (org.sonar.application.config.AppSettingsLoaderImpl)1 JavaCommandFactory (org.sonar.application.process.JavaCommandFactory)1 JavaCommandFactoryImpl (org.sonar.application.process.JavaCommandFactoryImpl)1 JavaProcessLauncher (org.sonar.application.process.JavaProcessLauncher)1 JavaProcessLauncherImpl (org.sonar.application.process.JavaProcessLauncherImpl)1