public class ManagedProcess extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
ManagedProcess.OutputReader
OutputReader provides a background process to read in all of the output
from the process.
|
Modifier and Type | Field and Description |
---|---|
protected Lock |
myLock
The log for the process.
|
protected Condition |
myLogUpdated
The condition to notify listeners that the log has been updated.
|
protected StringBuilder |
myOutput
The output of the process.
|
protected BufferedReader |
myReader
The reader for data from the process.
|
static boolean |
ourWriteMongoDbOutput
Boolean to control if the output from the MongoDB processes are written
to the console.
|
Constructor and Description |
---|
ManagedProcess(String executable,
Process process)
Creates a new ClusterTestSupport.ManagedProcess.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes/kills the managed process.
|
String |
getOutput()
Returns the output value.
|
protected void |
sleep(long millis)
Sleeps for the specified number of milliseconds.
|
void |
waitFor()
Waits for the process to exit.
|
void |
waitFor(int port,
long waitMs)
Waits for the specified port to start accepting connections.
|
void |
waitFor(String tokenRegex,
int count,
long waitMs)
Waits for the log file to contain the specified token
count
times. |
void |
waitFor(String token,
long waitMs)
Waits for the log file to contain the specified token.
|
public static boolean ourWriteMongoDbOutput
protected final Lock myLock
protected final Condition myLogUpdated
protected final StringBuilder myOutput
protected final BufferedReader myReader
public void close()
public String getOutput()
public void waitFor()
public void waitFor(int port, long waitMs)
port
- The port to search for.waitMs
- How long to wait before giving up.public void waitFor(String tokenRegex, int count, long waitMs)
count
times.tokenRegex
- The token regular expression to search for.count
- The number of instances of the token to find.waitMs
- How long to wait before giving up.public void waitFor(String token, long waitMs)
token
- The token to search for.waitMs
- How long to wait before giving up.protected void sleep(long millis)
millis
- The number of milliseconds to sleep.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.