public class ZooKeeperObject<T> extends Object
| Constructor and Description |
|---|
ZooKeeperObject(String path,
String zKID,
org.apache.curator.framework.CuratorFramework conn,
Class<T> typeParameterClass)
Creates a new Zookeeper object model.
|
| Modifier and Type | Method and Description |
|---|---|
String |
asJSON()
Returns the associated data model as a JSON string
|
void |
delete()
Deletes the associated Zookeeper Node.
|
String |
getConnectionString()
Returns the connection string associated with this object.
|
String |
getPath()
Returns the path for the object.
|
String |
getZKID()
Returns the id for the object.
|
String |
idFromPath(String path)
Extracts the ID from the provided path.
|
T |
load()
See load(Boolean)
|
T |
load(Boolean create)
Reads the data model from Zookeeper.
|
String |
save(T model)
Saves the specified model to Zookeeper
|
String |
save(T model,
org.apache.zookeeper.CreateMode mode)
Saves the specified model to Zookeeper using the given create mode attribute.
|
void |
setPath(String path)
Sets the path for the object.
|
void |
setZKID(String zKID)
Sets the ID for the object.
|
public ZooKeeperObject(String path, String zKID, org.apache.curator.framework.CuratorFramework conn, Class<T> typeParameterClass)
path - the Zookeeper node pathzKID - the zookeeper node idconn - the ZK connection objecttypeParameterClass - the type of the class - used to assist in marshalling/unmarshallingpublic String getConnectionString()
public String getPath()
public void setPath(String path)
path - the path valuepublic String getZKID()
public void setZKID(String zKID)
zKID - the ID valuepublic String save(T model) throws ZookeeperException
model - the data modelZookeeperException - if an error occurs while saving the data model to Zookeeper nodepublic String save(T model, org.apache.zookeeper.CreateMode mode) throws ZookeeperException
model - the data modelmode - the Zookeeper create modeZookeeperException - if an error occurs while saving the data model to Zookeeper nodepublic T load() throws ZookeeperException
ZookeeperException - if an error occurs while reading the data model from the Zookeeper nodepublic T load(Boolean create) throws ZookeeperException
create - Creates a new znode if the required path doesn't existZookeeperException - if an error occurs while reading the data model from the Zookeeper nodepublic void delete()
public String idFromPath(String path) throws NodePoolException
path - the path to the dataNodePoolException - if path is null, empty or otherwise malformedpublic String asJSON() throws ZookeeperException
ZookeeperException - if an error occurs while loading and converting the data modelCopyright © 2016–2018. All rights reserved.