Class MapRTableMappingRules
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
- 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 "hbase.table.namespace.mappings"
.
<name>hbase.table.namespace.mappings</name>
<value>*:/tables</value>
Any flat table name "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 "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/".
<name>hbase.table.namespace.mappings</name>
<value></value>
-
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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final org.apache.hadoop.fs.Pathstatic final Stringstatic final StringFields inherited from class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
HBASE_AVAILABLE, HBASE_PREFIX, inHBaseService_, INSTANCE, MAPRFS_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionMapRTableMappingRules(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
Modifier and TypeMethodDescriptionorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterTypeorg.apache.hadoop.fs.Pathprotected 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(String tableName) Returns translated path according to the configured mapping.static org.apache.hadoop.fs.PathgetMaprTablePath(org.apache.hadoop.conf.Configuration conf, String tableName) booleanbooleanbooleanisMapRTable(byte[] tableName) Tests iftableNameshould be treated as MapR tablebooleanisMapRTable(String tableName) Tests iftableNameshould be treated as MapR tablestatic booleanisMapRTable(org.apache.hadoop.conf.Configuration conf, String tableName) protected org.apache.hadoop.fs.PathConstructs absolute table path from the parent and the table name.voidsetClusterType(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype) toString()Methods inherited from class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
isInHBaseService, isMapRTable, setInHBaseService
-
Field Details
-
MAPR_ENGINE
- See Also:
-
HBASE_ENGINE
- See Also:
-
HBASE_TABLE_NAMESPACE_MAPPINGS
- See Also:
-
HBASE_PREFIX_PATH
public static final org.apache.hadoop.fs.Path HBASE_PREFIX_PATH
-
-
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 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 Details
-
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:
IllegalArgumentException- If the passedtableNameis null
-
isMapRTable
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:
IllegalArgumentException- If the passedtableNameis null
-
toString
-
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
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
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
-
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:
getDefaultTablePathin classorg.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
-