@ThreadSafe public class SynchronizedGateKeeper extends java.lang.Object implements GateKeeper
Constructor and Description |
---|
SynchronizedGateKeeper() |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitDrained(long timeout,
java.util.concurrent.TimeUnit unit)
Waits for the server to finish outstanding requests, giving up if the timeout is reached.
|
void |
close()
Closes the gate to disallow incoming requests to be processed.
|
int |
getNumOutstandingRequests()
Returns the number of outstanding requests.
|
boolean |
isOpen()
Returns if the gate is open or not.
|
boolean |
letIn()
Lets a new request in to process it in the server if the gate is open.
|
void |
letOut()
Lets a processed request out.
|
void |
open()
Opens the gate to allow incoming requests to be processed.
|
public void open()
GateKeeper
open
in interface GateKeeper
public void close()
GateKeeper
close
in interface GateKeeper
public boolean isOpen()
GateKeeper
isOpen
in interface GateKeeper
public int getNumOutstandingRequests()
GateKeeper
getNumOutstandingRequests
in interface GateKeeper
public boolean awaitDrained(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
GateKeeper
awaitDrained
in interface GateKeeper
timeout
- the maximum time to waitunit
- the time unit of the timeout argumentjava.lang.InterruptedException
- if interrupted while waitingpublic boolean letIn()
GateKeeper
letIn
in interface GateKeeper
public void letOut()
GateKeeper
letOut
in interface GateKeeper