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(ZooKeeperConnection zooKeeperConnection,
int poolSize,
String znode)
Claim a resource.
|
void |
close()
Relinquish the claim to this resource, and release it back to the resource pool.
|
void |
close(boolean nodeAlreadyDeleted) |
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(ZooKeeperConnection zooKeeperConnection, int poolSize, String znode) throws IOException
zooKeeperConnection - 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 void close(boolean nodeAlreadyDeleted)
public String getConfiguredZNode()
public void disconnected()
ZooKeeperConnectionObserverdisconnected in interface ZooKeeperConnectionObserverpublic void connected()
ZooKeeperConnectionObserverconnected in interface ZooKeeperConnectionObserverCopyright © 2014–2018 Lable. All rights reserved.