Class MapRTableMappingRules


  • public class MapRTableMappingRules
    extends org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
    The TableMappingRule class encapsulate the rules for deciding if a table name map to HBase table or a M7 table.

    Apache HBase has its own flat namespace (no slashes in a table name). This namespace must be supported by MapR, because

    1. A customer may run Apache HBase on a MapR cluster.
    2. A customer may have applications with hard-coded table names which they want to migrate to M7.
    3. A single client JAR supports both M7 and Apache HBase.

    The following rules determine, based on the table name/path, whether it's a M7 table or an Apache HBase table.

    PatternTable type
    a/b/c (anything with a slash)    M7
    maprfs://...M7
    hbase://mytable1Apache HBase
    mytable1 (no slash)   (See notes below)

    Notes:

    If a mapping for this table name exists in the client configuration, this is a M7 table. Otherwise, it is a Apache HBase table.

    HBase table namespace mappings

    As explained in FS-NS-003, there needs to be a way to determine whether a flat table name (no slashes and doesn't start with hbase://) should be treated as a Apache HBase table or a M7 table. This is accomplished with a client-side configuration "hbase.table.namespace.mappings" .

    Example 1:

    <name>hbase.table.namespace.mappings</name>
    <value>*:/tables</value>

    Any flat table name "foo" is treated as a M7 table "/tables/foo".

    Example 2:

    <name>hbase.table.namespace.mappings</name>
    <value>mytable1:/user/aaa,mytable2:/user/bbb/</value>

    • The flat table name "mytable1" is treated as a M7 table "/user/aaa" (if the flat table name in the mapping is not a glob and there is no "/" at the end of target path, the target path is treated as alias).
    • The flat table name "mytable2" is treated as a M7 table at "/user/bbb/mytable2".
    • All other flat table names are treated as Apache HBase tables.
    Example 3:

    <name>hbase.table.namespace.mappings</name>
    <value> mytable1:/user/aaa,mapr-*:/user/bbb,*:/tables</value>

    Mappings are evaluated in order. The flat table name "mytable1" is treated as a M7 table "/user/aaa. Any flat table with name starting with "mapr-" is treated as a M7 table under "/user/bbb/". All other flat table name, say, "foo" is treated as a M7 table under "/tables/".

    Example 4 (same as not specifying this parameter at all):

    <name>hbase.table.namespace.mappings</name>
    <value></value>

    All flat table names are treated as Apache HBase tables. IMPORTANT: This class functionality has been duplicated in fcclusterconf.h to provide similar helper methods for MapRDB C APIs. Any change in functionality over here should be reflected in that class as well, and vice-versa.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules

        org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HBASE_ENGINE  
      static org.apache.hadoop.fs.Path HBASE_PREFIX_PATH  
      static java.lang.String HBASE_TABLE_NAMESPACE_MAPPINGS  
      static java.lang.String MAPR_ENGINE  
      • Fields inherited from class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules

        HBASE_AVAILABLE, HBASE_PREFIX, inHBaseService_, INSTANCE, MAPRFS_PREFIX
    • Constructor Summary

      Constructors 
      Constructor Description
      MapRTableMappingRules​(org.apache.hadoop.conf.Configuration conf)
      Creates a table mapping rule object based on the value of 'hbase.table.namespace.mappings' parameter in the conf.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType getClusterType()
      org.apache.hadoop.fs.Path getDefaultTablePath()  
      protected org.apache.hadoop.fs.FileSystem getFS()
      Lazy initialization of FileSystem object using the Configuration provided in the constructor.
      org.apache.hadoop.fs.Path getMaprTablePath​(byte[] tableName)
      Returns translated path according to the configured mapping
      org.apache.hadoop.fs.Path getMaprTablePath​(java.lang.String tableName)
      Returns translated path according to the configured mapping.
      static org.apache.hadoop.fs.Path getMaprTablePath​(org.apache.hadoop.conf.Configuration conf, java.lang.String tableName)  
      boolean isMapRClientInstalled()
      boolean isMapRDefault()
      boolean isMapRTable​(byte[] tableName)
      Tests if tableName should be treated as MapR table
      boolean isMapRTable​(java.lang.String tableName)
      Tests if tableName should be treated as MapR table
      static boolean isMapRTable​(org.apache.hadoop.conf.Configuration conf, java.lang.String tableName)  
      protected org.apache.hadoop.fs.Path makePath​(java.lang.String parent, java.lang.String table)
      Constructs absolute table path from the parent and the table name.
      void setClusterType​(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)
      java.lang.String toString()
      • Methods inherited from class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules

        isInHBaseService, isMapRTable, setInHBaseService
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • HBASE_TABLE_NAMESPACE_MAPPINGS

        public static final java.lang.String HBASE_TABLE_NAMESPACE_MAPPINGS
        See Also:
        Constant Field Values
      • HBASE_PREFIX_PATH

        public static final org.apache.hadoop.fs.Path HBASE_PREFIX_PATH
    • Constructor Detail

      • MapRTableMappingRules

        public MapRTableMappingRules​(org.apache.hadoop.conf.Configuration conf)
        Creates a table mapping rule object based on the value of 'hbase.table.namespace.mappings' parameter in the conf.

        The class maintains a global HashMap of mapping rules string and its compiled form. If the current mapping rule is not found in the map, it is compiled and put in the hash-map.

        Parameters:
        conf -
    • Method Detail

      • isMapRDefault

        public boolean isMapRDefault()
        Overrides:
        isMapRDefault in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
      • isMapRClientInstalled

        public boolean isMapRClientInstalled()
        Overrides:
        isMapRClientInstalled in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
      • setClusterType

        public void setClusterType​(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)
        Overrides:
        setClusterType in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
      • getClusterType

        public org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType getClusterType()
        Overrides:
        getClusterType in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
      • isMapRTable

        public boolean isMapRTable​(byte[] tableName)
        Tests if tableName should be treated as MapR table
        Overrides:
        isMapRTable in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
        Parameters:
        conf -
        tableName -
        Returns:
        true if the table is determined to be a MapR table.
        Throws:
        java.lang.IllegalArgumentException - If the passed tableName is null
      • isMapRTable

        public boolean isMapRTable​(java.lang.String tableName)
        Tests if tableName should be treated as MapR table
        Overrides:
        isMapRTable in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
        Parameters:
        conf -
        tableName -
        Returns:
        true if the table is determined to be a MapR table.
        Throws:
        java.lang.IllegalArgumentException - If the passed tableName is null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getMaprTablePath

        public org.apache.hadoop.fs.Path getMaprTablePath​(byte[] tableName)
        Returns translated path according to the configured mapping
        Overrides:
        getMaprTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
        Parameters:
        conf - Hadoop Configuration instance
        tableName - Absolute or relative table name
        Returns:
        Translated absolute path if the table is a MapR table, null otherwise
      • getMaprTablePath

        public org.apache.hadoop.fs.Path getMaprTablePath​(java.lang.String tableName)
        Returns translated path according to the configured mapping. See MapRTableMappingRules
        Overrides:
        getMaprTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
        Parameters:
        tableName - Absolute or relative table name
        Returns:
        Translated absolute path if the table is a MapR table, null otherwise
      • makePath

        protected org.apache.hadoop.fs.Path makePath​(java.lang.String parent,
                                                     java.lang.String table)
        Constructs absolute table path from the parent and the table name.
        1. If the parent does not end with '/', table name is ignored else table name is appended to parent.
        2. If parent does not start with '/', user's home directory is prefixed to the resultant path.
        Parameters:
        parent -
        table -
        Returns:
      • getFS

        protected org.apache.hadoop.fs.FileSystem getFS()
        Lazy initialization of FileSystem object using the Configuration provided in the constructor. This code will not get executed if there is no rule with relative path.
        Returns:
      • isMapRTable

        public static boolean isMapRTable​(org.apache.hadoop.conf.Configuration conf,
                                          java.lang.String tableName)
      • getMaprTablePath

        public static org.apache.hadoop.fs.Path getMaprTablePath​(org.apache.hadoop.conf.Configuration conf,
                                                                 java.lang.String tableName)
      • getDefaultTablePath

        public org.apache.hadoop.fs.Path getDefaultTablePath()
        Overrides:
        getDefaultTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules