|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectau.com.lastweekend.jen.util.LoopRunnable
au.com.lastweekend.jen.util.AbstractWatchdog
au.com.lastweekend.jen.util.ProcessWatchdog
public class ProcessWatchdog
Assumes the processes are well behaved. Each process under watch will have up to 4 threads - a watchdog thread. This will be waiting for the process to terminate - a thread gobbling standard output - a thread gobbling standard error (if not redirected) - a JVM thread for the Process itself. Stdout is logged at debug, Stderr logged at error.
| Constructor Summary | |
|---|---|
ProcessWatchdog(java.lang.ProcessBuilder builder)
|
|
| Method Summary | |
|---|---|
java.lang.Long |
getDelayTime()
|
protected void |
gobbleOutput(java.lang.String line,
boolean isErrorOutput)
The output of the process's stdout and stderr is sent to this method. |
protected void |
handleGobblerException(java.io.IOException e,
boolean isErrorOutput)
The threads eating the stdout/stderr can throw the odd exception. |
protected void |
handleStandardError(java.io.InputStream stderr)
Do something with stderr. |
protected void |
handleStandardInput(java.io.OutputStream stdin)
Do something with the stdin |
protected void |
handleStandardOutput(java.io.InputStream stdout)
Do something with stdout |
protected void |
processDestroy()
Called when the process is destroyed forcibly during the stop sequence. |
protected void |
processExit(int result)
Called when the process terminates of its own accord (or some external kill) |
protected void |
processStart()
Called each time the process is started |
void |
setDelayTime(long delayTime)
If the process exits within this period after starting, the watchdog thread will sleep for this period before trying again. |
java.lang.Thread |
start(java.lang.String name)
Convenience method to start this runnable in a new thread. |
protected void |
startException(java.io.IOException e)
Handle the IO exception thrown from builder.start() |
protected void |
stopped()
Called when the loop exits. |
protected void |
waitInterrupted(java.lang.InterruptedException e)
Handle the interrupt exception during the stop process. |
| Methods inherited from class au.com.lastweekend.jen.util.AbstractWatchdog |
|---|
getBuilder, loop |
| Methods inherited from class au.com.lastweekend.jen.util.LoopRunnable |
|---|
run, stop, stopAtShutdown |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProcessWatchdog(java.lang.ProcessBuilder builder)
| Method Detail |
|---|
public void setDelayTime(long delayTime)
default 0 = no delay.
delayTime - (milliseconds)public java.lang.Long getDelayTime()
public java.lang.Thread start(java.lang.String name)
LoopRunnable
start in class LoopRunnableprotected void startException(java.io.IOException e)
AbstractWatchdog
startException in class AbstractWatchdogprotected void waitInterrupted(java.lang.InterruptedException e)
AbstractWatchdog
waitInterrupted in class AbstractWatchdogprotected void handleStandardError(java.io.InputStream stderr)
AbstractWatchdog
handleStandardError in class AbstractWatchdogprotected void handleStandardOutput(java.io.InputStream stdout)
AbstractWatchdog
handleStandardOutput in class AbstractWatchdogprotected void handleStandardInput(java.io.OutputStream stdin)
AbstractWatchdog
handleStandardInput in class AbstractWatchdogprotected void processStart()
AbstractWatchdog
processStart in class AbstractWatchdogprotected void processDestroy()
AbstractWatchdog
processDestroy in class AbstractWatchdogprotected void processExit(int result)
AbstractWatchdog
processExit in class AbstractWatchdogprotected void stopped()
LoopRunnable
stopped in class LoopRunnable
protected void handleGobblerException(java.io.IOException e,
boolean isErrorOutput)
e - isErrorOutput -
protected void gobbleOutput(java.lang.String line,
boolean isErrorOutput)
line - isErrorOutput -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||