public static boolean isNUMAOnce(SupportConfig support, Platform platform) { if (platform == Platform.Linux) { try { ProcessControl process = ProcessControl .fromCommandLine(support, asList("grep", "NUMA=y", "/boot/config-`uname -r`"), true); Reader reader = process.getReader(); String content = Readers.readAll(reader); process.stop(); boolean isNUMA = !content.isEmpty(); if (isNUMA) { logger.warn("-----------------------------------------------\n" + "NUMA support is still alpha. If you have any Problems with it, please contact us.\n" + "-----------------------------------------------"); } return isNUMA; } catch (IOException ix) { ix.printStackTrace(); } } return false; } }
public long getProcessId() { Long pid = process.getPid(); return pid!=null ? pid : processId; }
public int waitFor() throws InterruptedException { return process.waitFor(); }
protected void onAfterProcessStart(ProcessControl process, RuntimeConfig runtimeConfig) { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); Processors.connect(process.getReader(), outputConfig.getOutput()); Processors.connect(process.getError(), StreamToLineProcessor.wrap(outputConfig.getError())); }
@Override protected final void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor(successMessage(), knownFailureMessages(), StreamToLineProcessor.wrap(outputConfig.getOutput())); Processors.connect(process.getReader(), logWatch); Processors.connect(process.getError(), StreamToLineProcessor.wrap(outputConfig.getError())); logWatch.waitForResult(getConfig().timeout().getStartupTimeout()); if (logWatch.isInitWithSuccess()) { setProcessId(Mongod.getMongodProcessId(logWatch.getOutput(), -1)); } else { String failureFound = logWatch.getFailureFound(); if (failureFound==null) { failureFound="\n" + "----------------------\n" + "Hmm.. no failure message.. \n" + "...the cause must be somewhere in the process output\n" + "----------------------\n" + ""+logWatch.getOutput(); } try { // Process could be finished with success here! In this case no need to throw an exception! if(process.waitFor() != 0){ throw new IOException("Could not start process: "+failureFound); } } catch (InterruptedException e) { throw new IOException("Could not start process: "+failureFound, e); } } }
@Override protected final void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); // memcached prints all status messages on error console, and only // if // started with -vv LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor( "server listening", knownFailureMessages(), StreamToLineProcessor.wrap(outputConfig.getError())); Processors.connect(process.getError(), logWatch); logWatch.waitForResult(getConfig().timeout().getStartupTimeout()); if (!logWatch.isInitWithSuccess()) { throw new IOException("Could not start process:" + logWatch.getOutput()); } if (Distribution.detectFor(getConfig().version()).getPlatform() == Platform.Windows) { // On windows, process won't be writing a pid file. Sigh. Use // some // force to find out the pid anyways. This works pretty well // on Unix // (won't help us much here..) and needs Sigar lib on Windows. setProcessId(process.getPid()); } else { setProcessId(getPidFromFile(pidFile())); } }
ProcessBuilder processBuilder = ProcessControl.newProcessBuilder( runtimeConfig.getCommandLinePostProcessor().process(distribution, getCommandLine(distribution, config, this.executable.getFile())), process = ProcessControl.start(config.supportConfig(), processBuilder); if (process.getPid() != null) { writePidFile(pidFile, process.getPid()); ProcessControl.addShutdownHook(new JobKiller()); registeredJobKiller = true;
public CachingArtifactStore(IArtifactStore delegate) { _delegate = delegate; ProcessControl.addShutdownHook(new CacheCleaner()); executor = Executors.newSingleThreadScheduledExecutor(new CustomThreadFactory()); executor.scheduleAtFixedRate(new RemoveUnused(), 10, 10, TimeUnit.SECONDS); }
public static ProcessControl start(SupportConfig runtime, ProcessBuilder processBuilder) throws IOException { return new ProcessControl(runtime, processBuilder.start()); }
protected void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); Processors.connect(process.getReader(), outputConfig.getOutput()); Processors.connect(process.getError(), StreamToLineProcessor.wrap(outputConfig.getError())); }
ProcessBuilder processBuilder = ProcessControl.newProcessBuilder( runtimeConfig.getCommandLinePostProcessor().process(distribution, getCommandLine(distribution, config, this.executable.getFile())), process = ProcessControl.start(config.supportConfig(), processBuilder); if (process.getPid() != null) { writePidFile(pidFile, process.getPid()); ProcessControl.addShutdownHook(new JobKiller()); registeredJobKiller = true;
public Executable(Distribution distribution, T config, IRuntimeConfig runtimeConfig, IExtractedFileSet executable) { this.distribution = distribution; this.config = config; this.runtimeConfig = runtimeConfig; this.executable = executable; // only add shutdown hook for daemon processes, // clis being invoked will usually die by themselves if (runtimeConfig.isDaemonProcess()) { ProcessControl.addShutdownHook(new JobKiller()); registeredJobKiller = true; } }
public static ProcessControl start(ISupportConfig runtime, ProcessBuilder processBuilder) throws IOException { return new ProcessControl(runtime, processBuilder.start()); }
@Override protected void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { final ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); final LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor( "performing post-bootstrap initialization", singleton("[initdb error]"), StreamToLineProcessor.wrap(outputConfig.getOutput())); Processors.connect(process.getReader(), logWatch); Processors.connect(process.getError(), StreamToLineProcessor.wrap(outputConfig.getError())); logWatch.waitForResult(getConfig().timeout().startupTimeout()); } }
public static boolean isNUMAOnce(ISupportConfig support, Platform platform) { if (platform == Platform.Linux) { try { ProcessControl process = ProcessControl .fromCommandLine(support, Collections.newArrayList("grep", "NUMA=y", "/boot/config-`uname -r`"), true); Reader reader = process.getReader(); String content = Readers.readAll(reader); process.stop(); boolean isNUMA = !content.isEmpty(); if (isNUMA) { logger.warn("-----------------------------------------------\n" + "NUMA support is still alpha. If you have any Problems with it, please contact us.\n" + "-----------------------------------------------"); } return isNUMA; } catch (IOException ix) { logger.debug("Could not determine presence of NUMA", ix); } } return false; } }
public int waitFor() throws InterruptedException { return process.waitFor(); }
public long getProcessId() { Long pid = process.getPid(); return pid!=null ? pid : processId; }
public Executable(Distribution distribution, T config, RuntimeConfig runtimeConfig, ExtractedFileSet executable) { this.distribution = distribution; this.config = config; this.runtimeConfig = runtimeConfig; this.executable = executable; // only add shutdown hook for daemon processes, // clis being invoked will usually die by themselves if (runtimeConfig.isDaemonProcess()) { ProcessControl.addShutdownHook(new JobKiller()); registeredJobKiller = true; } }
@Override public void onAfterProcessStart(final ProcessControl process, final IRuntimeConfig runtimeConfig) throws IOException { outputWatch = new NotifyingStreamProcessor(StreamToLineProcessor.wrap(runtimeConfig.getProcessOutput().getOutput())); Processors.connect(process.getReader(), outputWatch); Processors.connect(process.getError(), outputWatch); ResultMatchingListener startupListener = outputWatch.addListener(new ResultMatchingListener("ready for connections")); try { startupListener.waitForResult(getConfig().getTimeout(MILLISECONDS)); if (!startupListener.isInitWithSuccess()) { throw new RuntimeException("mysql start failed with error: " + startupListener.getFailureFound()); } } catch (Exception e) { // emit IO exception for {@link AbstractProcess} would try to stop running process gracefully throw new IOException(e); } }
public static boolean executeCommandLine(ISupportConfig support, String label, ProcessConfig processConfig) { boolean ret = false; List<String> commandLine = processConfig.getCommandLine(); try { ProcessControl process = fromCommandLine(support, processConfig.getCommandLine(), processConfig.getError() == null); Processors.connect(process.getReader(), processConfig.getOutput()); Thread.sleep(SLEEPT_TIMEOUT); ret = process.stop() == 0; logger.info("execSuccess: {} {}", ret, commandLine); return ret; } catch (IOException e) { logger.error("" + commandLine, e); } catch (InterruptedException e) { logger.error("" + commandLine, e); } return false; }