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
Modifier and TypeFieldDescriptionprivate static VisibilityLabelsCache
private ReentrantReadWriteLock
This covers the members labels, ordinalVsLabels and userAuthsprivate static final org.slf4j.Logger
private ZKVisibilityLabelWatcher
-
Constructor Summary
ModifierConstructorDescriptionprivate
VisibilityLabelsCache
(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionstatic VisibilityLabelsCache
createAndGet
(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) Creates the singleton instance, if not yet present, and returns the same.static VisibilityLabelsCache
get()
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.int
getLabelOrdinal
(String label) int
Returns The total number of visibility labels.getUserAuths
(String user) getUserAuthsAsOrdinals
(String user) Returns the list of ordinals of labels associated with the uservoid
refreshLabelsCache
(byte[] data) void
refreshUserAuthsCache
(byte[] data) void
writeToZookeeper
(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:
getLabelOrdinal
in 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:VisibilityLabelOrdinalProvider
Returns the string associated with the ordinal. Not be used in MR.- Specified by:
getLabel
in interfaceVisibilityLabelOrdinalProvider
- Parameters:
ordinal
- The ordinal of label which we are looking for.- Returns:
- The label having the given ordinal. Returns
null
when 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
-