public class ResourceClaim extends Object implements org.lable.oss.dynamicconfig.zookeeper.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.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection,
int poolSize,
String znode)
Claim a resource.
|
static ResourceClaim |
claim(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection,
int poolSize,
String znode,
Duration timeout)
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() |
void |
disconnected() |
int |
get()
Get the claimed resource.
|
String |
getConfiguredZNode() |
protected ResourceClaim.State state
public static ResourceClaim claim(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection 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 static ResourceClaim claim(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection, int poolSize, String znode, Duration timeout) throws IOException
zooKeeperConnection - ZooKeeper connection to use.poolSize - Size of the resource pool.znode - Root znode of the ZooKeeper resource-pool.timeout - Time out if the process takes longer than this.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()
disconnected in interface org.lable.oss.dynamicconfig.zookeeper.ZooKeeperConnectionObserverpublic void connected()
connected in interface org.lable.oss.dynamicconfig.zookeeper.ZooKeeperConnectionObserverCopyright © 2014–2020 Lable. All rights reserved.