public class

ZkBaseDataAccessor

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

Summary

Nested Classes
class ZkBaseDataAccessor.AccessResult struct holding return information  
Public Constructors
ZkBaseDataAccessor(ZkClient zkClient)
Public Methods
boolean create(String path, T record, int options)
sync create
boolean[] createChildren(List<String> paths, List<T> records, int options)
async create TODO: rename to create
AccessResult doCreate(String path, T record, int options)
sync create
AccessResult doSet(String path, T record, int expectVersion, int options)
sync set
AccessResult doUpdate(String path, DataUpdater<T> updater, int options)
sync update
boolean[] exists(List<String> paths, int options)
async exists
boolean exists(String path, int options)
sync exists
List<T> get(List<String> paths, List<Stat> stats, int options)
async get
T get(String path, Stat stat, int options)
sync get
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 getStat
static void main(String[] args)
boolean[] remove(List<String> paths, int options)
async remove
boolean remove(String path, int options)
sync remove
void reset()
Reset
boolean set(String path, T record, int options)
sync set
boolean set(String path, T record, int expectVersion, int options)
sync set
boolean[] setChildren(List<String> paths, List<T> records, int options)
async set TODO: rename to set
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
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

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 TODO: rename to create

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

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

sync set

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

sync update

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

async exists

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

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

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 getStat

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 static void main (String[] args)

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

async remove

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

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

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 TODO: rename to set

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

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