use of org.sonar.core.extension.ServiceLoaderWrapper in project sonarqube by SonarSource.
the class CommandFactoryImplTest method newFactory.
private CommandFactoryImpl newFactory(Properties userProps, System2 system2) {
Properties p = new Properties();
p.setProperty("sonar.path.home", homeDir.getAbsolutePath());
p.setProperty("sonar.path.temp", tempDir.getAbsolutePath());
p.setProperty("sonar.path.logs", logsDir.getAbsolutePath());
p.putAll(userProps);
Props props = new Props(p);
ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class);
when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of());
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
return new CommandFactoryImpl(props, tempDir, system2);
}
use of org.sonar.core.extension.ServiceLoaderWrapper in project sonarqube by SonarSource.
the class EsSettingsTest method minProps.
private Props minProps(boolean cluster, @Nullable String host, @Nullable String port) throws IOException {
File homeDir = temp.newFolder();
Props props = new Props(new Properties());
ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class);
when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of());
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
props.set(PATH_HOME.getKey(), homeDir.getAbsolutePath());
props.set(Property.CLUSTER_ENABLED.getKey(), Boolean.toString(cluster));
if (cluster) {
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_ES_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_ES_PORT.getKey(), p));
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_SEARCH_PORT.getKey(), p));
ofNullable(port).ifPresent(h -> props.set(CLUSTER_ES_HOSTS.getKey(), h));
} else {
ofNullable(host).ifPresent(h -> props.set(SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(SEARCH_PORT.getKey(), p));
}
return props;
}
use of org.sonar.core.extension.ServiceLoaderWrapper in project sonarqube by SonarSource.
the class App method start.
public void start(String[] cliArguments) {
AppSettingsLoader settingsLoader = new AppSettingsLoaderImpl(System2.INSTANCE, cliArguments, new ServiceLoaderWrapper());
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());
appState.registerClusterName(settings.getProps().nonNullValue(CLUSTER_NAME.getKey()));
AppReloader appReloader = new AppReloaderImpl(settingsLoader, fileSystem, appState, logging);
fileSystem.reset();
CommandFactory commandFactory = new CommandFactoryImpl(settings.getProps(), fileSystem.getTempDir(), System2.INSTANCE);
try (ProcessLauncher processLauncher = new ProcessLauncherImpl(fileSystem.getTempDir())) {
Scheduler scheduler = new SchedulerImpl(settings, appReloader, commandFactory, processLauncher, appState);
scheduler.schedule();
stopRequestWatcher = StopRequestWatcherImpl.create(settings, scheduler, fileSystem);
hardStopRequestWatcher = HardStopRequestWatcherImpl.create(scheduler, fileSystem);
// intercepts CTRL-C
Runtime.getRuntime().addShutdownHook(new ShutdownHook(scheduler));
stopRequestWatcher.startWatching();
hardStopRequestWatcher.startWatching();
scheduler.awaitTermination();
hardStopRequestWatcher.stopWatching();
}
} catch (Exception e) {
Loggers.get(App.class).error("Startup failure", e);
}
systemExit.exit(0);
}
Aggregations