private static <T extends AbstractCommand> void logLaunchedCommand(AbstractCommand<T> command, ProcessBuilder processBuilder) { if (LOG.isInfoEnabled()) { LOG.info("Launch process[{}] from [{}]: {}", command.getProcessId(), command.getWorkDir().getAbsolutePath(), String.join(" ", processBuilder.command())); } }
private ProcessMonitor launchImpl(AbstractCommand<?> javaCommand) { commands.add(javaCommand); if (makeStartupFail == javaCommand.getProcessId()) { throw new IllegalStateException("cannot start " + javaCommand.getProcessId()); } TestProcess process = new TestProcess(javaCommand.getProcessId()); processes.put(javaCommand.getProcessId(), process); return process; }
ProcessId processId = command.getProcessId(); try { if (processId == ProcessId.ELASTICSEARCH) {
private static <T extends AbstractCommand> void logLaunchedCommand(AbstractCommand<T> command, ProcessBuilder processBuilder) { if (LOG.isInfoEnabled()) { LOG.info("Launch process[{}] from [{}]: {}", command.getProcessId(), command.getWorkDir().getAbsolutePath(), String.join(" ", processBuilder.command())); } }
public ProcessMonitor launch(AbstractCommand command) { EsInstallation fileSystem = command.getEsInstallation(); if (fileSystem != null) { cleanupOutdatedEsData(fileSystem); writeConfFiles(fileSystem); } Process process; if (command instanceof EsScriptCommand) { process = launchExternal((EsScriptCommand) command); } else if (command instanceof JavaCommand) { process = launchJava((JavaCommand) command); } else { throw new IllegalStateException("Unexpected type of command: " + command.getClass()); } ProcessId processId = command.getProcessId(); try { if (processId == ProcessId.ELASTICSEARCH) { return new EsProcessMonitor(process, processId, command.getEsInstallation(), new EsConnectorImpl()); } else { ProcessCommands commands = allProcessesCommands.createAfterClean(processId.getIpcIndex()); return new ProcessCommandsProcessMonitor(process, processId, commands); } } catch (Exception e) { // just in case if (process != null) { process.destroyForcibly(); } throw new IllegalStateException(format("Fail to launch monitor of process [%s]", processId.getKey()), e); } }