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();
}
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();
}
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);
}
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);
}
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);
}
}
Aggregations