Class MapRTableMappingRules

java.lang.Object
org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
com.mapr.fs.hbase.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 final String
     
    static final org.apache.hadoop.fs.Path
     
    static final String
     
    static final String
     

    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

    Modifier and Type
    Method
    Description
    org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType
    org.apache.hadoop.fs.Path
     
    protected org.apache.hadoop.fs.FileSystem
    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
    Returns translated path according to the configured mapping.
    static org.apache.hadoop.fs.Path
    getMaprTablePath(org.apache.hadoop.conf.Configuration conf, String tableName)
     
    boolean
    boolean
    boolean
    isMapRTable(byte[] tableName)
    Tests if tableName should be treated as MapR table
    boolean
    isMapRTable(String tableName)
    Tests if tableName should be treated as MapR table
    static boolean
    isMapRTable(org.apache.hadoop.conf.Configuration conf, String tableName)
     
    protected org.apache.hadoop.fs.Path
    makePath(String parent, String table)
    Constructs absolute table path from the parent and the table name.
    void
    setClusterType(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)

    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 Details

  • Constructor Details

    • 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 Details

    • 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:
      IllegalArgumentException - If the passed tableName is null
    • isMapRTable

      public boolean isMapRTable(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:
      IllegalArgumentException - If the passed tableName is null
    • toString

      public String toString()
      Overrides:
      toString in class 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(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(String parent, 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, String tableName)
    • getMaprTablePath

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

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