org.apache.hadoop.hbase.security.visibility
Class VisibilityLabelsCache

java.lang.Object
  extended by org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache
All Implemented Interfaces:
VisibilityLabelOrdinalProvider

@InterfaceAudience.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


Method Summary
static VisibilityLabelsCache createAndGet(ZooKeeperWatcher 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createAndGet

public static VisibilityLabelsCache createAndGet(ZooKeeperWatcher watcher,
                                                 org.apache.hadoop.conf.Configuration conf)
                                          throws IOException
Creates the singleton instance, if not yet present, and returns the same.

Parameters:
watcher -
conf -
Returns:
Singleton instance of VisibilityLabelsCache
Throws:
IOException

get

public static VisibilityLabelsCache get()
Returns:
Singleton instance of VisibilityLabelsCache
Throws:
IllegalStateException - when this is called before calling createAndGet(ZooKeeperWatcher, Configuration)

refreshLabelsCache

public void refreshLabelsCache(byte[] data)
                        throws IOException
Throws:
IOException

refreshUserAuthsCache

public void refreshUserAuthsCache(byte[] data)
                           throws IOException
Throws:
IOException

getLabelOrdinal

public int getLabelOrdinal(String label)
Specified by:
getLabelOrdinal in interface VisibilityLabelOrdinalProvider
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

public String getLabel(int ordinal)
Description copied from interface: VisibilityLabelOrdinalProvider
Returns the string associated with the ordinal. Not be used in MR.

Specified by:
getLabel in interface VisibilityLabelOrdinalProvider
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

public int getLabelsCount()
Returns:
The total number of visibility labels.

getUserAuths

public List<String> getUserAuths(String user)

getGroupAuths

public List<String> getGroupAuths(String[] groups)

getUserAuthsAsOrdinals

public Set<Integer> getUserAuthsAsOrdinals(String user)
Returns the list of ordinals of labels associated with the user

Parameters:
user - Not null value.
Returns:
the list of ordinals

getGroupAuthsAsOrdinals

public Set<Integer> getGroupAuthsAsOrdinals(String[] groups)
Returns the list of ordinals of labels associated with the groups

Parameters:
groups -
Returns:
the list of ordinals

writeToZookeeper

public void writeToZookeeper(byte[] data,
                             boolean labelsOrUserAuths)
                      throws IOException
Throws:
IOException


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.