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.BaseTableMappingRulesTheTableMappingRuleclass 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
- A customer may run Apache HBase on a MapR cluster.
- A customer may have applications with hard-coded table names which they want to migrate to M7.
- 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.
Pattern Table type a/b/c (anything with a slash) M7 maprfs://... M7 hbase://mytable1 Apache 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
Example 1:"hbase.table.namespace.mappings".<name>hbase.table.namespace.mappings</name>
<value>*:/tables</value>Any flat table name
Example 2:"foo"is treated as a M7 table"/tables/foo".<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.
<name>hbase.table.namespace.mappings</name>
<value> mytable1:/user/aaa,mapr-*:/user/bbb,*:/tables</value>Mappings are evaluated in order. The flat table name
Example 4 (same as not specifying this parameter at all):"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/".
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.<name>hbase.table.namespace.mappings</name>
<value></value>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHBASE_ENGINEstatic org.apache.hadoop.fs.PathHBASE_PREFIX_PATHstatic java.lang.StringHBASE_TABLE_NAMESPACE_MAPPINGSstatic java.lang.StringMAPR_ENGINE
-
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 theconf.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterTypegetClusterType()org.apache.hadoop.fs.PathgetDefaultTablePath()protected org.apache.hadoop.fs.FileSystemgetFS()Lazy initialization ofFileSystemobject using theConfigurationprovided in the constructor.org.apache.hadoop.fs.PathgetMaprTablePath(byte[] tableName)Returns translated path according to the configured mappingorg.apache.hadoop.fs.PathgetMaprTablePath(java.lang.String tableName)Returns translated path according to the configured mapping.static org.apache.hadoop.fs.PathgetMaprTablePath(org.apache.hadoop.conf.Configuration conf, java.lang.String tableName)booleanisMapRClientInstalled()booleanisMapRDefault()booleanisMapRTable(byte[] tableName)Tests iftableNameshould be treated as MapR tablebooleanisMapRTable(java.lang.String tableName)Tests iftableNameshould be treated as MapR tablestatic booleanisMapRTable(org.apache.hadoop.conf.Configuration conf, java.lang.String tableName)protected org.apache.hadoop.fs.PathmakePath(java.lang.String parent, java.lang.String table)Constructs absolute table path from the parent and the table name.voidsetClusterType(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)java.lang.StringtoString()
-
-
-
Field Detail
-
MAPR_ENGINE
public static final java.lang.String MAPR_ENGINE
- See Also:
- Constant Field Values
-
HBASE_ENGINE
public static final java.lang.String HBASE_ENGINE
- See Also:
- Constant Field Values
-
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 theconf.The class maintains a global
HashMapof 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:
isMapRDefaultin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-
isMapRClientInstalled
public boolean isMapRClientInstalled()
- Overrides:
isMapRClientInstalledin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-
setClusterType
public void setClusterType(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)
- Overrides:
setClusterTypein classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-
getClusterType
public org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType getClusterType()
- Overrides:
getClusterTypein classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-
isMapRTable
public boolean isMapRTable(byte[] tableName)
Tests iftableNameshould be treated as MapR table- Overrides:
isMapRTablein classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules- Parameters:
conf-tableName-- Returns:
trueif the table is determined to be a MapR table.- Throws:
java.lang.IllegalArgumentException- If the passedtableNameis null
-
isMapRTable
public boolean isMapRTable(java.lang.String tableName)
Tests iftableNameshould be treated as MapR table- Overrides:
isMapRTablein classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules- Parameters:
conf-tableName-- Returns:
trueif the table is determined to be a MapR table.- Throws:
java.lang.IllegalArgumentException- If the passedtableNameis null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getMaprTablePath
public org.apache.hadoop.fs.Path getMaprTablePath(byte[] tableName)
Returns translated path according to the configured mapping- Overrides:
getMaprTablePathin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules- Parameters:
conf- Hadoop Configuration instancetableName- Absolute or relative table name- Returns:
- Translated absolute path if the table is a MapR table,
nullotherwise
-
getMaprTablePath
public org.apache.hadoop.fs.Path getMaprTablePath(java.lang.String tableName)
Returns translated path according to the configured mapping. SeeMapRTableMappingRules- Overrides:
getMaprTablePathin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules- Parameters:
tableName- Absolute or relative table name- Returns:
- Translated absolute path if the table is a MapR table,
nullotherwise
-
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.- If the parent does not end with '/', table name is ignored else table name is appended to parent.
- 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 ofFileSystemobject using theConfigurationprovided 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:
getDefaultTablePathin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-
-