public class

ZKHelixDataAccessor

extends Object
implements ControllerChangeListener HelixDataAccessor
java.lang.Object
   ↳ org.apache.helix.manager.zk.ZKHelixDataAccessor

Summary

Public Constructors
ZKHelixDataAccessor(String clusterName, BaseDataAccessor<ZNRecord> baseDataAccessor)
ZKHelixDataAccessor(String clusterName, InstanceType instanceType, BaseDataAccessor<ZNRecord> baseDataAccessor)
Public Methods
<T extends HelixProperty> boolean[] createChildren(List<PropertyKey> keys, List<T> children)
Adds multiple children to a parent.
<T extends HelixProperty> boolean createProperty(PropertyKey key, T value)
Create a helix property only if it does not exist.
BaseDataAccessor<ZNRecord> getBaseDataAccessor()
Get underlying base data accessor
List<String> getChildNames(PropertyKey key)
Return the child names for a property.
<T extends HelixProperty> List<T> getChildValues(PropertyKey key)
Get the child values for a property.
<T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key)
Same as getChildValues except that it converts list into a map using the id of the HelixProperty
<T extends HelixProperty> List<T> getProperty(List<PropertyKey> keys)
Return a list of property values, each of which must be refer to a single Helix Property.
<T extends HelixProperty> T getProperty(PropertyKey key)
Return the property value, it must be refer to a single Helix Property.
PropertyKey.Builder keyBuilder()
Get key builder for the accessor
void onControllerChange(NotificationContext changeContext)
Invoked when controller changes
boolean removeProperty(PropertyKey key)
Removes the property
<T extends HelixProperty> boolean[] setChildren(List<PropertyKey> keys, List<T> children)
Sets multiple children under one parent
<T extends HelixProperty> boolean setProperty(PropertyKey key, T value)
Set a property, overwrite if it exists and creates if not exists.
void shutdown()
<T extends HelixProperty> boolean[] updateChildren(List<String> paths, List<DataUpdater<ZNRecord>> updaters, int options)
Updates multiple children under one parent TODO: change to use property-keys instead of paths
<T extends HelixProperty> boolean updateProperty(PropertyKey key, T value)
Updates a property using newvalue.merge(oldvalue)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.ControllerChangeListener
From interface org.apache.helix.HelixDataAccessor

Public Constructors

public ZKHelixDataAccessor (String clusterName, BaseDataAccessor<ZNRecord> baseDataAccessor)

public ZKHelixDataAccessor (String clusterName, InstanceType instanceType, BaseDataAccessor<ZNRecord> baseDataAccessor)

Public Methods

public boolean[] createChildren (List<PropertyKey> keys, List<T> children)

Adds multiple children to a parent.

Returns
  • array where true means the child was added and false means it was not

public boolean createProperty (PropertyKey key, T value)

Create a helix property only if it does not exist.

Returns
  • true if creation was successful. False if already exists or if it failed to create

public BaseDataAccessor<ZNRecord> getBaseDataAccessor ()

Get underlying base data accessor

Returns
  • a data accessor that can process ZNRecord objects

public List<String> getChildNames (PropertyKey key)

Return the child names for a property. PropertyKey needs to refer to a collection like instances, resources. PropertyKey.isLeaf must be false

Returns
  • SubPropertyNames

public List<T> getChildValues (PropertyKey key)

Get the child values for a property. PropertyKey needs to refer to just one level above the non leaf. PropertyKey.isCollection must be true.

Returns
  • subPropertyValues

public Map<String, T> getChildValuesMap (PropertyKey key)

Same as getChildValues except that it converts list into a map using the id of the HelixProperty

Returns
  • a map of property identifiers to typed properties

public List<T> getProperty (List<PropertyKey> keys)

Return a list of property values, each of which must be refer to a single Helix Property. Property may be bucketized.

public T getProperty (PropertyKey key)

Return the property value, it must be refer to a single Helix Property. i.e PropertyKey.isLeaf() must return true.

Returns
  • value, Null if absent or on error

public PropertyKey.Builder keyBuilder ()

Get key builder for the accessor

Returns
  • instantiated PropertyKey.Builder

public void onControllerChange (NotificationContext changeContext)

Invoked when controller changes

Parameters
changeContext description of the event and state

public boolean removeProperty (PropertyKey key)

Removes the property

Returns
  • true if removal was successful or node does not exist. false if the node existed and failed to remove it

public boolean[] setChildren (List<PropertyKey> keys, List<T> children)

Sets multiple children under one parent

Returns
  • array where true means the child was set and false means it was not

public boolean setProperty (PropertyKey key, T value)

Set a property, overwrite if it exists and creates if not exists. This api assumes the node exists and only tries to update it only if the call fail it will create the node. So there is a performance cost if always ends up creating the node.

Returns
  • true if the operation was successful

public void shutdown ()

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

Updates multiple children under one parent TODO: change to use property-keys instead of paths

Returns
  • array where true means the child was updated and false means it was not

public boolean updateProperty (PropertyKey key, T value)

Updates a property using newvalue.merge(oldvalue)

Returns
  • true if the update was successful