public class ZKStateStorage extends Object implements IStateStorage
Constructor and Description |
---|
ZKStateStorage(Map<Object,Object> conf,
Map authConf,
List<org.apache.zookeeper.data.ACL> acls,
ClusterStateContext context) |
Modifier and Type | Method and Description |
---|---|
void |
add_listener(org.apache.curator.framework.state.ConnectionStateListener listener)
Add a StateStorageListener to the connection.
|
void |
close()
Close the connection to the data store.
|
String |
create_sequential(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acls)
Path will be appended with a monotonically increasing integer, a new node will be created there, and data will be put at that node.
|
void |
delete_node_blobstore(String path,
String nimbusHostPortInfo)
Allows us to delete the znodes within /storm/blobstore/key_name whose znodes start with the corresponding nimbusHostPortInfo
|
void |
delete_node(String path)
Deletes the node at a given path, and any child nodes that may exist.
|
void |
delete_worker_hb(String path)
Deletes the heartbeat at a given path, and any child nodes that may exist.
|
List<String> |
get_children(String path,
boolean watch)
Get a list of paths of all the child nodes which exist immediately under path.
|
VersionedData<byte[]> |
get_data_with_version(String path,
boolean watch)
Get the data at the node along with its version.
|
byte[] |
get_data(String path,
boolean watch)
Get the data from the node at path
|
Integer |
get_version(String path,
boolean watch)
Gets the ‘version’ of the node at a path.
|
List<String> |
get_worker_hb_children(String path,
boolean watch)
Get a list of paths of all the child nodes which exist immediately under path.
|
byte[] |
get_worker_hb(String path,
boolean watch)
Get the heartbeat from the node at path
|
void |
mkdirs(String path,
List<org.apache.zookeeper.data.ACL> acls)
Creates nodes for path and all its parents.
|
boolean |
node_exists(String path,
boolean watch)
Check if a node exists and optionally set a watch on the path.
|
String |
register(ZKStateChangedCallback callback)
Registers a callback function that gets called when CuratorEvents happen.
|
void |
set_data(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acls)
Set the value of the node at path to data.
|
void |
set_ephemeral_node(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acls)
Creates an ephemeral node at path.
|
void |
set_worker_hb(String path,
byte[] data,
List<org.apache.zookeeper.data.ACL> acls)
Write a worker heartbeat at the path.
|
void |
sync_path(String path)
Force consistency on a path.
|
void |
unregister(String id)
Unregisters a callback function that was registered with register(…).
|
public void delete_node_blobstore(String path, String nimbusHostPortInfo)
IStateStorage
Allows us to delete the znodes within /storm/blobstore/key_name whose znodes start with the corresponding nimbusHostPortInfo
delete_node_blobstore
in interface IStateStorage
path
- /storm/blobstore/key_namenimbusHostPortInfo
- Contains the host port information of a nimbus node.public String register(ZKStateChangedCallback callback)
IStateStorage
Registers a callback function that gets called when CuratorEvents happen.
register
in interface IStateStorage
callback
- is a clojure IFn that accepts the type - translated to clojure keyword as in zookeeper - and the path: (callback type path)public void unregister(String id)
IStateStorage
Unregisters a callback function that was registered with register(…).
unregister
in interface IStateStorage
id
- is the String id that was returned from register(…).public String create_sequential(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acls)
IStateStorage
Path will be appended with a monotonically increasing integer, a new node will be created there, and data will be put at that node.
create_sequential
in interface IStateStorage
path
- The path that the monotonically increasing integer suffix will be added to.data
- The data that will be written at the suffixed path’s node.acls
- The acls to apply to the path. May be null.public void mkdirs(String path, List<org.apache.zookeeper.data.ACL> acls)
IStateStorage
Creates nodes for path and all its parents. Path elements are separated by a “/”, as in *nix filesystem notation. Equivalent to mkdir -p in *nix.
mkdirs
in interface IStateStorage
path
- The path to create, along with all its parents.acls
- The acls to apply to the path. May be null.public void delete_node(String path)
IStateStorage
Deletes the node at a given path, and any child nodes that may exist.
delete_node
in interface IStateStorage
path
- The path to deletepublic void set_ephemeral_node(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acls)
IStateStorage
Creates an ephemeral node at path. Ephemeral nodes are destroyed by the store when the client disconnects.
set_ephemeral_node
in interface IStateStorage
path
- The path where a node will be created.data
- The data to be written at the node.acls
- The acls to apply to the path. May be null.public Integer get_version(String path, boolean watch) throws Exception
IStateStorage
Gets the ‘version’ of the node at a path. Optionally sets a watch on that node. The version should increase whenever a write happens.
get_version
in interface IStateStorage
path
- The path to get the version of.watch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.Exception
public boolean node_exists(String path, boolean watch)
IStateStorage
Check if a node exists and optionally set a watch on the path.
node_exists
in interface IStateStorage
path
- The path to check for the existence of a node.watch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public List<String> get_children(String path, boolean watch)
IStateStorage
Get a list of paths of all the child nodes which exist immediately under path.
get_children
in interface IStateStorage
path
- The path to look underwatch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public void close()
IStateStorage
Close the connection to the data store.
close
in interface IStateStorage
public void set_data(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acls)
IStateStorage
Set the value of the node at path to data.
set_data
in interface IStateStorage
path
- The path whose node we want to set.data
- The data to put in the node.acls
- The acls to apply to the path. May be null.public byte[] get_data(String path, boolean watch)
IStateStorage
Get the data from the node at path
get_data
in interface IStateStorage
path
- The path to look underwatch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public VersionedData<byte[]> get_data_with_version(String path, boolean watch)
IStateStorage
Get the data at the node along with its version. Data is returned in an Map with the keys data and version.
get_data_with_version
in interface IStateStorage
path
- The path to look underwatch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public void set_worker_hb(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acls)
IStateStorage
Write a worker heartbeat at the path.
set_worker_hb
in interface IStateStorage
path
- The path whose node we want to set.data
- The data to put in the node.acls
- The acls to apply to the path. May be null.public byte[] get_worker_hb(String path, boolean watch)
IStateStorage
Get the heartbeat from the node at path
get_worker_hb
in interface IStateStorage
path
- The path to look underwatch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public List<String> get_worker_hb_children(String path, boolean watch)
IStateStorage
Get a list of paths of all the child nodes which exist immediately under path. This is similar to get_children, but must be used for any nodes
get_worker_hb_children
in interface IStateStorage
path
- The path to look underwatch
- Whether or not to set a watch on the path. Watched paths emit events which are consumed by functions registered with the register method. Very useful for catching updates to nodes.public void delete_worker_hb(String path)
IStateStorage
Deletes the heartbeat at a given path, and any child nodes that may exist.
delete_worker_hb
in interface IStateStorage
path
- The path to delete.public void add_listener(org.apache.curator.framework.state.ConnectionStateListener listener)
IStateStorage
Add a StateStorageListener to the connection.
add_listener
in interface IStateStorage
listener
- A StateStorageListener to handle changing cluster state events.public void sync_path(String path)
IStateStorage
Force consistency on a path. Any writes committed on the path before this call will be completely propagated when it returns.
sync_path
in interface IStateStorage
path
- The path to synchronize.Copyright © 2019 The Apache Software Foundation. All Rights Reserved.