Package gov.usgs.util
Class TimeoutProcess
- java.lang.Object
-
- gov.usgs.util.TimeoutProcess
-
public class TimeoutProcess extends java.lang.ObjectTimeoutProcess wraps a Process object. It is most commonly used with TimeoutProcessBuilder, which configures the process timeout (and sets the timed out state once the timeout is reached).- See Also:
Process,TimeoutProcessBuilder,ProcessTimeoutException
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimeoutProcess(java.lang.Process process)Construct a new TimeoutProcess.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroys a processbyte[]errorOutput()intexitValue()java.io.InputStreamgetErrorStream()java.io.InputStreamgetInputStream()java.io.OutputStreamgetOutputStream()protected voidsetTimeoutElapsed(boolean timeoutElapsed)protected voidsetTimer(java.util.Timer timer)protected booleantimeoutElapsed()intwaitFor()Wait for the process to complete, either normally or because its timeout was reached.
-
-
-
Method Detail
-
destroy
public void destroy()
Destroys a process
-
errorOutput
public byte[] errorOutput()
- Returns:
- errorOutput byte array
-
exitValue
public int exitValue()
- Returns:
- exit value
-
getErrorStream
public java.io.InputStream getErrorStream()
- Returns:
- InputStream of error stream
-
getInputStream
public java.io.InputStream getInputStream()
- Returns:
- InputStream
-
getOutputStream
public java.io.OutputStream getOutputStream()
- Returns:
- OutputStream
-
waitFor
public int waitFor() throws java.lang.InterruptedException, java.io.IOException, ProcessTimeoutExceptionWait for the process to complete, either normally or because its timeout was reached.- Returns:
- exitStatus.
- Throws:
java.lang.InterruptedException- if thread interruption occursjava.io.IOException- if IO error occursProcessTimeoutException- if the process timed out before exiting.
-
setTimeoutElapsed
protected void setTimeoutElapsed(boolean timeoutElapsed)
- Parameters:
timeoutElapsed- to set
-
timeoutElapsed
protected boolean timeoutElapsed()
- Returns:
- timeoutElapsed boolean
-
setTimer
protected void setTimer(java.util.Timer timer)
- Parameters:
timer- to set
-
-