Class ReadyMonitor
- java.lang.Object
-
- org.apache.accumulo.server.conf.store.impl.ReadyMonitor
-
public class ReadyMonitor extends Object
Provides a barrier to block operations until a resource signals that it is ready. This class encapsulates a wait / notify operation using a lock and condition. Instances are initialized with the resource unavailable - callsetReady()
when the resource is available
-
-
Constructor Summary
Constructors Constructor Description ReadyMonitor(String resourceName, long timeout)
Create an instance of a ready monitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearReady()
Indicate that resource is NOT available and that calls toisReady()
should block.void
isReady()
Method blocks until the resource is ready.void
setClosed()
ZooKeeper has closed the connection.void
setReady()
Indicate that the resource is ready.boolean
test()
Non-blocking call to get ready state.String
toString()
-
-
-
Constructor Detail
-
ReadyMonitor
public ReadyMonitor(String resourceName, long timeout)
Create an instance of a ready monitor.- Parameters:
resourceName
- the resource name guarded by this monitor (used by logging)timeout
- the max time in milliseconds this will block waiting.
-
-
Method Detail
-
test
public boolean test()
Non-blocking call to get ready state. It will throw is the ZooKeeper connection has closed (non-recoverable condition)- Returns:
- true if resource is ready, false otherwise
-
isReady
public void isReady()
Method blocks until the resource is ready. If the resource does not become ready within the timeout an IllegalStateException is thrown.- Throws:
IllegalStateException
- if the resource does not signal ready withing timeout.
-
setClosed
public void setClosed()
ZooKeeper has closed the connection. This is a terminal state that cannot be recoved from without creating a new ZooKeeper client.
-
setReady
public void setReady()
Indicate that the resource is ready.
-
clearReady
public void clearReady()
Indicate that resource is NOT available and that calls toisReady()
should block.
-
-