public class

ZkBaseDataAccessor

extends Object
implements BaseDataAccessor<T>
java.lang.Object
   ↳ org.apache.helix.manager.zk.ZkBaseDataAccessor<T>

Summary

Nested Classes
class ZkBaseDataAccessor.AccessResult structure holding return information  
Public Constructors
ZkBaseDataAccessor(ZkClient zkClient)
Public Methods
boolean create(String path, T record, int options)
sync create a znode
boolean[] createChildren(List<String> paths, List<T> records, int options)
async create multiple znodes
AccessResult doCreate(String path, T record, int options)
sync create a znode.
AccessResult doSet(String path, T record, int expectVersion, int options)
sync set a znode, create parent paths if necessary
AccessResult doUpdate(String path, DataUpdater<T> updater, int options)
sync update a znode, create parent paths if necessary
boolean[] exists(List<String> paths, int options)
async test existence on multiple znodes
boolean exists(String path, int options)
sync exists
List<T> get(List<String> paths, List<Stat> stats, int options)
async get a list of znodes
T get(String path, Stat stat, int options)
sync get a znode
List<String> getChildNames(String parentPath, int options)
sync getChildNames
List<T> getChildren(String parentPath, List<Stat> stats, int options)
asyn getChildren
Stat getStat(String path, int options)
sync getStat
Stat[] getStats(List<String> paths, int options)
async get stats of mulitple znodes
boolean[] remove(List<String> paths, int options)
async remove multiple znodes
boolean remove(String path, int options)
sync remove
void reset()
Reset
boolean set(String path, T record, int options)
sync set a znode
boolean set(String path, T record, int expectVersion, int options)
sync set a znode with expect version
boolean[] setChildren(List<String> paths, List<T> records, int options)
async set multiple znodes
List<String> subscribeChildChanges(String path, IZkChildListener listener)
Subscrie to zookeeper data changes
void subscribeDataChanges(String path, IZkDataListener listener)
Subscribe to zookeeper data changes
void unsubscribeChildChanges(String path, IZkChildListener childListener)
Unsubscrie to zookeeper data changes
void unsubscribeDataChanges(String path, IZkDataListener dataListener)
Unsubscribe to zookeeper data changes
boolean update(String path, DataUpdater<T> updater, int options)
sync update a znode
boolean[] updateChildren(List<String> paths, List<DataUpdater<T>> updaters, int options)
async update
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.BaseDataAccessor

Public Constructors

public ZkBaseDataAccessor (ZkClient zkClient)

Public Methods

public boolean create (String path, T record, int options)

sync create a znode

Parameters
path path to the ZNode to create
record the data to write to the ZNode
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if creation succeeded, false otherwise (e.g. if the ZNode exists)

public boolean[] createChildren (List<String> paths, List<T> records, int options)

async create multiple znodes

Parameters
paths the paths to the children ZNodes
options Set the type of ZNode see the valid values in AccessOption
Returns
  • For each child: true if creation succeeded, false otherwise (e.g. if the child exists)

public AccessResult doCreate (String path, T record, int options)

sync create a znode. create parent znodes if necessary

Parameters
path path to create
record value to create, null for no value

public AccessResult doSet (String path, T record, int expectVersion, int options)

sync set a znode, create parent paths if necessary

public AccessResult doUpdate (String path, DataUpdater<T> updater, int options)

sync update a znode, create parent paths if necessary

public boolean[] exists (List<String> paths, int options)

async test existence on multiple znodes

Parameters
paths paths to the ZNodes to test
options Set the type of ZNode see the valid values in AccessOption
Returns
  • for each path, true if a valid ZNode exists, false otherwise

public boolean exists (String path, int options)

sync exists

Parameters
path path to the ZNode to test
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if the ZNode exists, false otherwise

public List<T> get (List<String> paths, List<Stat> stats, int options)

async get a list of znodes

Parameters
paths paths to the ZNodes
stats retrieve a list of stats for the ZNodes
options Set the type of ZNode see the valid values in AccessOption
Returns
  • List of record data stored at each ZNode

public T get (String path, Stat stat, int options)

sync get a znode

Parameters
path path to the ZNode
stat retrieve the stat of the ZNode
options Set the type of ZNode see the valid values in AccessOption
Returns
  • the record data stored at the ZNode

public List<String> getChildNames (String parentPath, int options)

sync getChildNames

Parameters
parentPath path to the immediate parent ZNode
options Set the type of ZNode see the valid values in AccessOption
Returns
  • null if parentPath doesn't exist

public List<T> getChildren (String parentPath, List<Stat> stats, int options)

asyn getChildren

Parameters
stats Zookeeper Stat objects corresponding to each child
options Set the type of ZNode see the valid values in AccessOption
Returns
  • A list of children of the parent ZNode

public Stat getStat (String path, int options)

sync getStat

Parameters
path path of the ZNode to query
options Set the type of ZNode see the valid values in AccessOption
Returns
  • Zookeeper Stat object corresponding to the ZNode

public Stat[] getStats (List<String> paths, int options)

async get stats of mulitple znodes

Parameters
paths paths of the ZNodes to query
options Set the type of ZNode see the valid values in AccessOption
Returns
  • Zookeeper Stat object for each path

public boolean[] remove (List<String> paths, int options)

async remove multiple znodes

Parameters
paths paths to the ZNodes to remove
options Set the type of ZNode see the valid values in AccessOption
Returns
  • For each ZNode, true if successfully removed, false otherwise

public boolean remove (String path, int options)

sync remove

Parameters
path path to the root ZNode to remove
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if the removal succeeded, false otherwise

public void reset ()

Reset

public boolean set (String path, T record, int options)

sync set a znode

Parameters
path path to the ZNode to set
record the data to write to the ZNode
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if data was successfully set, false otherwise

public boolean set (String path, T record, int expectVersion, int options)

sync set a znode with expect version

Parameters
path path to the ZNode to set
record the data to write to the ZNode
expectVersion the expected version of the data to be overwritten, -1 means match any version
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if data was successfully set, false otherwise (e.g. if the version mismatches)

public boolean[] setChildren (List<String> paths, List<T> records, int options)

async set multiple znodes

Parameters
paths the paths to the children ZNodes
options Set the type of ZNode see the valid values in AccessOption
Returns
  • For each child: true if the data was set, false otherwise

public List<String> subscribeChildChanges (String path, IZkChildListener listener)

Subscrie to zookeeper data changes

Parameters
path path to the immediate parent ZNode
listener the listener to register for changes

public void subscribeDataChanges (String path, IZkDataListener listener)

Subscribe to zookeeper data changes

Parameters
path path to the ZNode to listen to
listener the listener to register for changes

public void unsubscribeChildChanges (String path, IZkChildListener childListener)

Unsubscrie to zookeeper data changes

Parameters
path path to the immediate parent ZNode
childListener the listener currently subscribed to the children

public void unsubscribeDataChanges (String path, IZkDataListener dataListener)

Unsubscribe to zookeeper data changes

Parameters
path path to the ZNode to stop listening to
dataListener the listener currently subscribed to the ZNode

public boolean update (String path, DataUpdater<T> updater, int options)

sync update a znode

Parameters
path path to the ZNode to update
updater an update routine for the data to merge in
options Set the type of ZNode see the valid values in AccessOption
Returns
  • true if data update succeeded, false otherwise

public boolean[] updateChildren (List<String> paths, List<DataUpdater<T>> updaters, int options)

async update

Parameters
updaters List of update routines for records to update
options Set the type of ZNode see the valid values in AccessOption
Returns
  • For each child, true if the data is updated successfully, false otherwise