public class BatchProcessDriverCLI
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private class |
BatchProcessDriverCLI.InterruptWatcher
Class to watch stdin from the driver for anything that is typed.
|
private class |
BatchProcessDriverCLI.InterruptWriter
Class that writes to the child process
to force an interrupt in the child process.
|
private class |
BatchProcessDriverCLI.StreamGobbler |
private class |
BatchProcessDriverCLI.StreamWatcher |
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String[] |
commandLine |
private BatchProcessDriverCLI.StreamGobbler |
errorWatcher |
private java.lang.Thread |
errorWatcherThread |
private BatchProcessDriverCLI.InterruptWatcher |
interruptWatcher |
private java.lang.Thread |
interruptWatcherThread |
private BatchProcessDriverCLI.InterruptWriter |
interruptWriter |
private java.lang.Thread |
interruptWriterThread |
private static org.slf4j.Logger |
LOG |
private int |
loopsAfterRestartMessageReceived |
private int |
maxProcessRestarts |
private int |
numRestarts |
private BatchProcessDriverCLI.StreamGobbler |
outGobbler |
private java.lang.Thread |
outGobblerThread |
private java.lang.Process |
process |
static int |
PROCESS_COMPLETED_SUCCESSFULLY |
static int |
PROCESS_NO_RESTART_EXIT_CODE |
static int |
PROCESS_RESTART_EXIT_CODE
This relies on an special exit values of 254 (do not restart),
0 ended correctly, 253 ended with exception (do restart)
|
private long |
pulseMillis |
private boolean |
receivedRestartMsg |
private boolean |
redirectChildProcessToStdOut |
private boolean |
userInterrupted |
private int |
waitNumLoopsAfterRestartMessage |
| Constructor and Description |
|---|
BatchProcessDriverCLI(java.lang.String[] commandLine) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute() |
int |
getNumRestarts() |
boolean |
getUserInterrupted() |
static void |
main(java.lang.String[] args) |
private boolean |
restart(java.lang.Integer exitValue,
boolean receivedRestartMsg)
Tries to restart (stop and then start) the child process
|
void |
setRedirectChildProcessToStdOut(boolean redirectChildProcessToStdOut)
Typically only used for testing.
|
private void |
shutdownDriverNow() |
private void |
start() |
private void |
stop() |
private java.lang.String[] |
tryToReadMaxRestarts(java.lang.String[] commandLine) |
public static final int PROCESS_RESTART_EXIT_CODE
public static final int PROCESS_NO_RESTART_EXIT_CODE
public static final int PROCESS_COMPLETED_SUCCESSFULLY
private static final org.slf4j.Logger LOG
private int maxProcessRestarts
private long pulseMillis
private int waitNumLoopsAfterRestartMessage
private int loopsAfterRestartMessageReceived
private volatile boolean userInterrupted
private boolean receivedRestartMsg
private java.lang.Process process
private BatchProcessDriverCLI.StreamGobbler errorWatcher
private BatchProcessDriverCLI.StreamGobbler outGobbler
private BatchProcessDriverCLI.InterruptWriter interruptWriter
private final BatchProcessDriverCLI.InterruptWatcher interruptWatcher
private java.lang.Thread errorWatcherThread
private java.lang.Thread outGobblerThread
private java.lang.Thread interruptWriterThread
private final java.lang.Thread interruptWatcherThread
private final java.lang.String[] commandLine
private int numRestarts
private boolean redirectChildProcessToStdOut
public BatchProcessDriverCLI(java.lang.String[] commandLine)
private java.lang.String[] tryToReadMaxRestarts(java.lang.String[] commandLine)
public void execute()
throws java.lang.Exception
java.lang.Exceptionprivate void shutdownDriverNow()
public int getNumRestarts()
public boolean getUserInterrupted()
private boolean restart(java.lang.Integer exitValue,
boolean receivedRestartMsg)
throws java.lang.Exception
java.lang.Exceptionprivate void stop()
private void start()
throws java.lang.Exception
java.lang.Exceptionpublic void setRedirectChildProcessToStdOut(boolean redirectChildProcessToStdOut)
redirectChildProcessToStdOut - should the driver redirect the child's stdoutpublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception