Package com.linkedin.venice.helix
Class SafeHelixDataAccessor
java.lang.Object
com.linkedin.venice.helix.SafeHelixDataAccessor
A wrapper around
HelixDataAccessor
which disables the unsafe functionality.
Venice should never use a HelixDataAccessor
directly. All uses of this class should
always be wrapped in a SafeHelixDataAccessor
.
In order to ensure a compile-time guarantee that only safe APIs are called, we explicitly
choose to remove the unsafe APIs from the interface. Therefore, we do not actually
implement the HelixDataAccessor
interface. These are the removed unsafe APIs:
- HelixDataAccessor.getProperty(List, boolean)
We don't want to allow calling this function, since it can be used unsafely if
throwException=false.
- HelixDataAccessor.getChildValues(PropertyKey, boolean)
We don't want to allow calling this function, since it can be used unsafely if
throwException=false.
- HelixDataAccessor.getChildValuesMap(PropertyKey, boolean)
We don't want to allow calling this function, since it can be used unsafely if
throwException=false.
- HelixDataAccessor.getBaseDataAccessor()
If we want to allow the use of the BaseDataAccessor
returned by this function,
then we would likewise need to wrap it inside of a Safe API, because it provides
unsafe calls such as BaseDataAccessor.get(List, List, int)
and potentially
others.
TODO: Review the rest of the functions and determine if more should be culled.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends org.apache.helix.HelixProperty>
boolean[]createChildren
(List<org.apache.helix.PropertyKey> keys, List<T> children) boolean
createControllerLeader
(org.apache.helix.model.LiveInstance leader) boolean
createControllerMessage
(org.apache.helix.model.Message message) boolean
createMaintenance
(org.apache.helix.model.MaintenanceSignal maintenanceSignal) boolean
createPause
(org.apache.helix.model.PauseSignal pauseSignal) boolean
createStateModelDef
(org.apache.helix.model.StateModelDefinition stateModelDef) getChildNames
(org.apache.helix.PropertyKey key) <T extends org.apache.helix.HelixProperty>
List<T>getChildValues
(org.apache.helix.PropertyKey key) N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.getChildValuesMap
(org.apache.helix.PropertyKey key) N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.<T extends org.apache.helix.HelixProperty>
List<T>getProperty
(List<org.apache.helix.PropertyKey> keys) N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.<T extends org.apache.helix.HelixProperty>
TgetProperty
(org.apache.helix.PropertyKey key) org.apache.helix.HelixProperty.Stat
getPropertyStat
(org.apache.helix.PropertyKey key) List<org.apache.helix.HelixProperty.Stat>
getPropertyStats
(List<org.apache.helix.PropertyKey> keys) org.apache.helix.PropertyKey.Builder
boolean
removeProperty
(org.apache.helix.PropertyKey key) <T extends org.apache.helix.HelixProperty>
boolean[]setChildren
(List<org.apache.helix.PropertyKey> keys, List<T> children) <T extends org.apache.helix.HelixProperty>
booleansetProperty
(org.apache.helix.PropertyKey key, T value) <T extends org.apache.helix.HelixProperty>
boolean[]updateChildren
(List<String> paths, List<org.apache.helix.zookeeper.zkclient.DataUpdater<org.apache.helix.zookeeper.datamodel.ZNRecord>> updaters, int options) <T extends org.apache.helix.HelixProperty>
booleanupdateProperty
(org.apache.helix.PropertyKey key, org.apache.helix.zookeeper.zkclient.DataUpdater<org.apache.helix.zookeeper.datamodel.ZNRecord> updater, T value) <T extends org.apache.helix.HelixProperty>
booleanupdateProperty
(org.apache.helix.PropertyKey key, T value)
-
Constructor Details
-
SafeHelixDataAccessor
public SafeHelixDataAccessor(org.apache.helix.HelixDataAccessor helixDataAccessor)
-
-
Method Details
-
createStateModelDef
public boolean createStateModelDef(org.apache.helix.model.StateModelDefinition stateModelDef) -
createControllerMessage
public boolean createControllerMessage(org.apache.helix.model.Message message) -
createControllerLeader
public boolean createControllerLeader(org.apache.helix.model.LiveInstance leader) -
createPause
public boolean createPause(org.apache.helix.model.PauseSignal pauseSignal) -
createMaintenance
public boolean createMaintenance(org.apache.helix.model.MaintenanceSignal maintenanceSignal) -
setProperty
public <T extends org.apache.helix.HelixProperty> boolean setProperty(org.apache.helix.PropertyKey key, T value) -
updateProperty
public <T extends org.apache.helix.HelixProperty> boolean updateProperty(org.apache.helix.PropertyKey key, T value) -
updateProperty
public <T extends org.apache.helix.HelixProperty> boolean updateProperty(org.apache.helix.PropertyKey key, org.apache.helix.zookeeper.zkclient.DataUpdater<org.apache.helix.zookeeper.datamodel.ZNRecord> updater, T value) -
getProperty
public <T extends org.apache.helix.HelixProperty> T getProperty(org.apache.helix.PropertyKey key) -
getProperty
public <T extends org.apache.helix.HelixProperty> List<T> getProperty(List<org.apache.helix.PropertyKey> keys) throws org.apache.helix.api.exceptions.HelixMetaDataAccessException N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.- Throws:
org.apache.helix.api.exceptions.HelixMetaDataAccessException
-
removeProperty
public boolean removeProperty(org.apache.helix.PropertyKey key) -
getPropertyStat
public org.apache.helix.HelixProperty.Stat getPropertyStat(org.apache.helix.PropertyKey key) -
getPropertyStats
-
getChildNames
-
getChildValues
public <T extends org.apache.helix.HelixProperty> List<T> getChildValues(org.apache.helix.PropertyKey key) throws org.apache.helix.api.exceptions.HelixMetaDataAccessException N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.- Throws:
org.apache.helix.api.exceptions.HelixMetaDataAccessException
-
getChildValuesMap
public <T extends org.apache.helix.HelixProperty> Map<String,T> getChildValuesMap(org.apache.helix.PropertyKey key) throws org.apache.helix.api.exceptions.HelixMetaDataAccessException N.B.: The behavior of this function is different from that ofHelixDataAccessor
, which would swallow exceptions and return an empty collection.- Throws:
org.apache.helix.api.exceptions.HelixMetaDataAccessException
-
createChildren
-
setChildren
-
updateChildren
-
keyBuilder
public org.apache.helix.PropertyKey.Builder keyBuilder()
-