public void testPidUnavailableThrows() { final String name = "Name without PID"; try { ProcessUtils.identifyPid(name); fail("PidUnavailableException should have been thrown for " + name); } catch (PidUnavailableException e) { // passed } } }
private void validateProcessControllerFactory(boolean isAttachAPIFound) throws Exception { final ProcessControllerFactory factory = new ProcessControllerFactory(); assertEquals(isAttachAPIFound, factory.isAttachAPIFound()); if (isAttachAPIFound) { final ProcessControllerParameters parms = new NullMBeanControllerParameters(); final ProcessController controller = factory.createProcessController(parms, ProcessUtils.identifyPid()); assertTrue(controller instanceof MBeanProcessController); } else { final ProcessControllerParameters parms = new NullFileControllerParameters(); final ProcessController controller = factory.createProcessController(parms, ProcessUtils.identifyPid()); assertTrue(controller instanceof FileProcessController); } }
@Override public String status() throws UnableToControlProcessException, IOException, InterruptedException, TimeoutException { return status(this.arguments.getWorkingDirectory(), this.arguments.getProcessType().getStatusRequestFileName(), this.arguments.getProcessType().getStatusFileName()); }
@Override public String status() throws UnableToControlProcessException, ConnectionFailedException, IOException, MBeanInvocationFailedException { return status(this.arguments.getNamePattern(), this.arguments.getPidAttribute(), this.arguments.getStatusMethod(), this.arguments.getAttributes(), this.arguments.getValues()); }
@Override public void stop() throws UnableToControlProcessException, ConnectionFailedException, IOException, MBeanInvocationFailedException { stop(this.arguments.getNamePattern(), this.arguments.getPidAttribute(), this.arguments.getStopMethod(), this.arguments.getAttributes(), this.arguments.getValues()); }
private static void deleteFiles(final File workingDir, final ProcessType processType) { deleteFile(workingDir, processType.getStatusRequestFileName()); deleteFile(workingDir, processType.getStatusFileName()); deleteFile(workingDir, processType.getStopRequestFileName()); }
@Override public void stop() throws UnableToControlProcessException, IOException { stop(this.arguments.getWorkingDirectory(), this.arguments.getProcessType().getStopRequestFileName()); }
private static int identifyPid() { try { return ProcessUtils.identifyPid(); } catch (PidUnavailableException e) { return 0; } }
/** * Returns the process id (PID). * * @return the process id (PID) */ public int getPid() { return this.launcher.getPid(); }
/** * Returns true if this process should redirect output to the system log. * @return true if this process should redirect output to the system log */ public static boolean isRedirectingOutput() { final ProcessLauncherContext context = get(); if (context == null) { return REDIRECT_OUTPUT_DEFAULT; } return context.redirectOutput(); }
public static StartupStatusListener getStartupListener() { final ProcessLauncherContext context = get(); if (context == null) { return null; } return context.startupListener(); }
/** * Returns the PID file. * * @return the PID file */ public File getPidFile() { return this.launcher.getPidFile(); }
/** * Returns true if a process identified by the process id was * running on this host machine and has been terminated by this operation. * * @param pid process id * @return true if the process was terminated by this operation */ public static boolean killProcess(final int pid) { return internal.killProcess(pid); }
private static void installLogListener(StartupStatusListener startupListener) { if (startupListener != null) { StartupStatus.setListener(startupListener); } }
@Override public String status() throws UnableToControlProcessException, IOException, InterruptedException, TimeoutException { return status(this.arguments.getWorkingDirectory(), this.arguments.getProcessType().getStatusRequestFileName(), this.arguments.getProcessType().getStatusFileName()); }
@Override public String status() throws UnableToControlProcessException, ConnectionFailedException, IOException, MBeanInvocationFailedException { return status(this.arguments.getNamePattern(), this.arguments.getPidAttribute(), this.arguments.getStatusMethod(), this.arguments.getAttributes(), this.arguments.getValues()); }
@Override public void stop() throws UnableToControlProcessException, ConnectionFailedException, IOException, MBeanInvocationFailedException { stop(this.arguments.getNamePattern(), this.arguments.getPidAttribute(), this.arguments.getStopMethod(), this.arguments.getAttributes(), this.arguments.getValues()); }
private static void deleteFiles(final File workingDir, final ProcessType processType) { deleteFile(workingDir, processType.getStatusRequestFileName()); deleteFile(workingDir, processType.getStatusFileName()); deleteFile(workingDir, processType.getStopRequestFileName()); }
@Override public void stop() throws UnableToControlProcessException, IOException { stop(this.arguments.getWorkingDirectory(), this.arguments.getProcessType().getStopRequestFileName()); }
private static Integer identifyPid() { try { return ProcessUtils.identifyPid(); } catch (PidUnavailableException ignore) { return null; } }