public class ResourceClaim extends Object implements ZooKeeperConnectionObserver, Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
ResourceClaim.State
Internal state of this ResourceClaim.
|
| Modifier and Type | Field and Description |
|---|---|
protected ResourceClaim.State |
state |
| Modifier and Type | Method and Description |
|---|---|
static ResourceClaim |
claim(org.apache.zookeeper.ZooKeeper zookeeper,
int poolSize,
String znode)
Claim a resource.
|
void |
close()
Relinquish the claim to this resource, and release it back to the resource pool.
|
void |
connected()
Called when the connection to the ZooKeeper quorum is established.
|
void |
disconnected()
Called when the connection to the ZooKeeper quorum was interrupted.
|
int |
get()
Get the claimed resource.
|
String |
getConfiguredZNode() |
protected ResourceClaim.State state
public static ResourceClaim claim(org.apache.zookeeper.ZooKeeper zookeeper, int poolSize, String znode) throws IOException
zookeeper - ZooKeeper connection to use.poolSize - Size of the resource pool.znode - Root znode of the ZooKeeper resource-pool.IOExceptionpublic int get()
IllegalStateException - Thrown when the claim is no longer held.public void close()
close in interface Closeableclose in interface AutoCloseablepublic String getConfiguredZNode()
public void disconnected()
ZooKeeperConnectionObserverdisconnected in interface ZooKeeperConnectionObserverpublic void connected()
ZooKeeperConnectionObserverconnected in interface ZooKeeperConnectionObserverCopyright © 2014–2015 Lable. All rights reserved.