Class VisibilityLabelsCache
java.lang.Object
org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache
- All Implemented Interfaces:
VisibilityLabelOrdinalProvider
@Private
public class VisibilityLabelsCache
extends Object
implements VisibilityLabelOrdinalProvider
Maintains the cache for visibility labels and also uses the zookeeper to update the labels in the
system. The cache updation happens based on the data change event that happens on the zookeeper
znode for labels table
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static VisibilityLabelsCacheprivate ReentrantReadWriteLockThis covers the members labels, ordinalVsLabels and userAuthsprivate static final org.slf4j.Loggerprivate ZKVisibilityLabelWatcher -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateVisibilityLabelsCache(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionstatic VisibilityLabelsCachecreateAndGet(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) Creates the singleton instance, if not yet present, and returns the same.static VisibilityLabelsCacheget()getGroupAuths(String[] groups) getGroupAuthsAsOrdinals(String[] groups) Returns the list of ordinals of labels associated with the groupsgetLabel(int ordinal) Returns the string associated with the ordinal.intgetLabelOrdinal(String label) intReturns The total number of visibility labels.getUserAuths(String user) getUserAuthsAsOrdinals(String user) Returns the list of ordinals of labels associated with the uservoidrefreshLabelsCache(byte[] data) voidrefreshUserAuthsCache(byte[] data) voidwriteToZookeeper(byte[] data, boolean labelsOrUserAuths)
-
Field Details
-
LOG
-
EMPTY_LIST
-
EMPTY_SET
-
instance
-
zkVisibilityWatcher
-
labels
-
ordinalVsLabels
-
userAuths
-
groupAuths
-
lock
This covers the members labels, ordinalVsLabels and userAuths
-
-
Constructor Details
-
VisibilityLabelsCache
private VisibilityLabelsCache(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
-
Method Details
-
createAndGet
public static VisibilityLabelsCache createAndGet(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) throws IOException Creates the singleton instance, if not yet present, and returns the same.- Returns:
- Singleton instance of VisibilityLabelsCache
- Throws:
IOException
-
get
- Returns:
- Singleton instance of VisibilityLabelsCache when this is called before calling
createAndGet(ZKWatcher, Configuration)
-
refreshLabelsCache
- Throws:
IOException
-
refreshUserAuthsCache
- Throws:
IOException
-
getLabelOrdinal
- Specified by:
getLabelOrdinalin interfaceVisibilityLabelOrdinalProvider- Parameters:
label- Not null label string- Returns:
- The ordinal for the label. The ordinal starts from 1. Returns 0 when passed a non existing label.
-
getLabel
Description copied from interface:VisibilityLabelOrdinalProviderReturns the string associated with the ordinal. Not be used in MR.- Specified by:
getLabelin interfaceVisibilityLabelOrdinalProvider- Parameters:
ordinal- The ordinal of label which we are looking for.- Returns:
- The label having the given ordinal. Returns
nullwhen no label exist in the system with given ordinal
-
getLabelsCount
Returns The total number of visibility labels. -
getUserAuths
-
getGroupAuths
-
getUserAuthsAsOrdinals
Returns the list of ordinals of labels associated with the user- Parameters:
user- Not null value.- Returns:
- the list of ordinals
-
getGroupAuthsAsOrdinals
Returns the list of ordinals of labels associated with the groups- Returns:
- the list of ordinals
-
writeToZookeeper
- Throws:
IOException
-