@InterfaceAudience.Private public class VisibilityLabelsCache extends Object implements VisibilityLabelOrdinalProvider
Modifier and Type | Field and Description |
---|---|
private static List<String> |
EMPTY_LIST |
private static Set<Integer> |
EMPTY_SET |
private Map<String,Set<Integer>> |
groupAuths |
private static VisibilityLabelsCache |
instance |
private Map<String,Integer> |
labels |
private ReentrantReadWriteLock |
lock
This covers the members labels, ordinalVsLabels and userAuths
|
private static org.slf4j.Logger |
LOG |
private Map<Integer,String> |
ordinalVsLabels |
private Map<String,Set<Integer>> |
userAuths |
private ZKVisibilityLabelWatcher |
zkVisibilityWatcher |
Modifier | Constructor and Description |
---|---|
private |
VisibilityLabelsCache(ZKWatcher watcher,
org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
static 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() |
List<String> |
getGroupAuths(String[] groups) |
Set<Integer> |
getGroupAuthsAsOrdinals(String[] groups)
Returns the list of ordinals of labels associated with the groups
|
String |
getLabel(int ordinal)
Returns the string associated with the ordinal.
|
int |
getLabelOrdinal(String label) |
int |
getLabelsCount() |
List<String> |
getUserAuths(String user) |
Set<Integer> |
getUserAuthsAsOrdinals(String user)
Returns the list of ordinals of labels associated with the user
|
void |
refreshLabelsCache(byte[] data) |
void |
refreshUserAuthsCache(byte[] data) |
void |
writeToZookeeper(byte[] data,
boolean labelsOrUserAuths) |
private static final org.slf4j.Logger LOG
private static final List<String> EMPTY_LIST
private static VisibilityLabelsCache instance
private ZKVisibilityLabelWatcher zkVisibilityWatcher
private Map<Integer,String> ordinalVsLabels
private Map<String,Set<Integer>> groupAuths
private ReentrantReadWriteLock lock
private VisibilityLabelsCache(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static VisibilityLabelsCache createAndGet(ZKWatcher watcher, org.apache.hadoop.conf.Configuration conf) throws IOException
watcher
- conf
- IOException
public static VisibilityLabelsCache get()
IllegalStateException
- when this is called before calling
createAndGet(ZKWatcher, Configuration)
public void refreshLabelsCache(byte[] data) throws IOException
IOException
public void refreshUserAuthsCache(byte[] data) throws IOException
IOException
public int getLabelOrdinal(String label)
getLabelOrdinal
in interface VisibilityLabelOrdinalProvider
label
- Not null label stringpublic String getLabel(int ordinal)
VisibilityLabelOrdinalProvider
getLabel
in interface VisibilityLabelOrdinalProvider
ordinal
- The ordinal of label which we are looking for.null
when no label exist in
the system with given ordinalpublic int getLabelsCount()
public List<String> getUserAuths(String user)
public List<String> getGroupAuths(String[] groups)
public Set<Integer> getUserAuthsAsOrdinals(String user)
user
- Not null value.public Set<Integer> getGroupAuthsAsOrdinals(String[] groups)
groups
- public void writeToZookeeper(byte[] data, boolean labelsOrUserAuths) throws IOException
IOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.