Browse Source

SONAR-8798 rename JavaCommandFactory to CommandFactory

tags/6.6-RC1
Sébastien Lesaint 7 years ago
parent
commit
6a92224cad

+ 8
- 8
server/sonar-process-monitor/src/main/java/org/sonar/application/SchedulerImpl.java View File

@@ -30,8 +30,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.application.config.AppSettings;
import org.sonar.application.config.ClusterSettings;
import org.sonar.application.process.CommandFactory;
import org.sonar.application.process.JavaCommand;
import org.sonar.application.process.JavaCommandFactory;
import org.sonar.application.process.ProcessLauncher;
import org.sonar.application.process.Lifecycle;
import org.sonar.application.process.ProcessEventListener;
@@ -45,7 +45,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi

private final AppSettings settings;
private final AppReloader appReloader;
private final JavaCommandFactory javaCommandFactory;
private final CommandFactory commandFactory;
private final ProcessLauncher processLauncher;
private final AppState appState;
private final NodeLifecycle nodeLifecycle = new NodeLifecycle();
@@ -60,12 +60,12 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
private RestarterThread restarterThread;
private long processWatcherDelayMs = SQProcess.DEFAULT_WATCHER_DELAY_MS;

public SchedulerImpl(AppSettings settings, AppReloader appReloader, JavaCommandFactory javaCommandFactory,
public SchedulerImpl(AppSettings settings, AppReloader appReloader, CommandFactory commandFactory,
ProcessLauncher processLauncher,
AppState appState) {
this.settings = settings;
this.appReloader = appReloader;
this.javaCommandFactory = javaCommandFactory;
this.commandFactory = commandFactory;
this.processLauncher = processLauncher;
this.appState = appState;
this.appState.addListener(this);
@@ -105,7 +105,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
private void tryToStartEs() {
SQProcess process = processesById.get(ProcessId.ELASTICSEARCH);
if (process != null) {
tryToStartProcess(process, javaCommandFactory::createEsCommand);
tryToStartProcess(process, commandFactory::createEsCommand);
}
}

@@ -115,9 +115,9 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
return;
}
if (appState.isOperational(ProcessId.WEB_SERVER, false)) {
tryToStartProcess(process, () -> javaCommandFactory.createWebCommand(false));
tryToStartProcess(process, () -> commandFactory.createWebCommand(false));
} else if (appState.tryToLockWebLeader()) {
tryToStartProcess(process, () -> javaCommandFactory.createWebCommand(true));
tryToStartProcess(process, () -> commandFactory.createWebCommand(true));
} else {
Optional<String> leader = appState.getLeaderHostName();
if (leader.isPresent()) {
@@ -131,7 +131,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
private void tryToStartCe() {
SQProcess process = processesById.get(ProcessId.COMPUTE_ENGINE);
if (process != null && appState.isOperational(ProcessId.WEB_SERVER, false) && isEsClientStartable()) {
tryToStartProcess(process, javaCommandFactory::createCeCommand);
tryToStartProcess(process, commandFactory::createCeCommand);
}
}


server/sonar-process-monitor/src/main/java/org/sonar/application/process/JavaCommandFactory.java → server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactory.java View File

@@ -19,7 +19,7 @@
*/
package org.sonar.application.process;

public interface JavaCommandFactory {
public interface CommandFactory {

JavaCommand createEsCommand();


server/sonar-process-monitor/src/main/java/org/sonar/application/process/JavaCommandFactoryImpl.java → server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java View File

@@ -28,7 +28,7 @@ import java.util.Optional;

import static org.sonar.process.ProcessProperties.*;

public class JavaCommandFactoryImpl implements JavaCommandFactory {
public class CommandFactoryImpl implements CommandFactory {
/**
* Properties about proxy that must be set as system properties
*/
@@ -44,7 +44,7 @@ public class JavaCommandFactoryImpl implements JavaCommandFactory {

private final AppSettings settings;

public JavaCommandFactoryImpl(AppSettings settings) {
public CommandFactoryImpl(AppSettings settings) {
this.settings = settings;
}


+ 1
- 1
server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java View File

@@ -88,7 +88,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
commands.add(buildJavaPath());
commands.addAll(javaCommand.getJavaOptions());
// TODO warning - does it work if temp dir contains a whitespace ?
// TODO move to JavaCommandFactory ?
// TODO move to CommandFactory ?
commands.add(format("-Djava.io.tmpdir=%s", tempDir.getAbsolutePath()));
commands.addAll(buildClasspath(javaCommand));
commands.add(javaCommand.getClassName());

+ 3
- 3
server/sonar-process-monitor/src/test/java/org/sonar/application/SchedulerImplTest.java View File

@@ -35,8 +35,8 @@ import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.mockito.Mockito;
import org.sonar.application.config.TestAppSettings;
import org.sonar.application.process.CommandFactory;
import org.sonar.application.process.JavaCommand;
import org.sonar.application.process.JavaCommandFactory;
import org.sonar.application.process.ProcessLauncher;
import org.sonar.application.process.ProcessMonitor;
import org.sonar.process.ProcessId;
@@ -66,7 +66,7 @@ public class SchedulerImplTest {

private AppReloader appReloader = mock(AppReloader.class);
private TestAppSettings settings = new TestAppSettings();
private TestJavaCommandFactory javaCommandFactory = new TestJavaCommandFactory();
private TestCommandFactory javaCommandFactory = new TestCommandFactory();
private TestProcessLauncher processLauncher = new TestProcessLauncher();
private TestAppState appState = new TestAppState();
private List<ProcessId> orderedStops = synchronizedList(new ArrayList<>());
@@ -305,7 +305,7 @@ public class SchedulerImplTest {
}
}

private static class TestJavaCommandFactory implements JavaCommandFactory {
private static class TestCommandFactory implements CommandFactory {
@Override
public JavaCommand createEsCommand() {
return ES_COMMAND;

+ 4
- 4
sonar-application/src/main/java/org/sonar/application/App.java View File

@@ -23,8 +23,8 @@ import java.io.IOException;
import org.sonar.application.config.AppSettings;
import org.sonar.application.config.AppSettingsLoader;
import org.sonar.application.config.AppSettingsLoaderImpl;
import org.sonar.application.process.JavaCommandFactory;
import org.sonar.application.process.JavaCommandFactoryImpl;
import org.sonar.application.process.CommandFactory;
import org.sonar.application.process.CommandFactoryImpl;
import org.sonar.application.process.ProcessLauncher;
import org.sonar.application.process.ProcessLauncherImpl;
import org.sonar.application.process.StopRequestWatcher;
@@ -49,11 +49,11 @@ public class App {
try (AppState appState = new AppStateFactory(settings).create()) {
appState.registerSonarQubeVersion(getSonarqubeVersion());
AppReloader appReloader = new AppReloaderImpl(settingsLoader, fileSystem, appState, logging);
JavaCommandFactory javaCommandFactory = new JavaCommandFactoryImpl(settings);
CommandFactory commandFactory = new CommandFactoryImpl(settings);
fileSystem.reset();

try (ProcessLauncher processLauncher = new ProcessLauncherImpl(fileSystem.getTempDir())) {
Scheduler scheduler = new SchedulerImpl(settings, appReloader, javaCommandFactory, processLauncher, appState);
Scheduler scheduler = new SchedulerImpl(settings, appReloader, commandFactory, processLauncher, appState);

// intercepts CTRL-C
Runtime.getRuntime().addShutdownHook(new ShutdownHook(scheduler));

Loading…
Cancel
Save