public class MapRTableMappingRules
extends org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules
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
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>
"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)."mytable2" is treated as a
M7 table at "/user/bbb/mytable2". <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>
| Modifier and Type | Field and 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 |
| Constructor and 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. |
| Modifier and Type | Method and 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
|
static org.apache.hadoop.fs.Path |
getMaprTablePath(org.apache.hadoop.conf.Configuration conf,
java.lang.String tableName) |
org.apache.hadoop.fs.Path |
getMaprTablePath(java.lang.String tableName)
Returns translated path according to the configured mapping.
|
boolean |
isMapRClientInstalled() |
boolean |
isMapRDefault() |
boolean |
isMapRTable(byte[] tableName)
Tests if
tableName should be treated as MapR table |
static boolean |
isMapRTable(org.apache.hadoop.conf.Configuration conf,
java.lang.String tableName) |
boolean |
isMapRTable(java.lang.String tableName)
Tests if
tableName should be treated as MapR table |
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() |
public static final java.lang.String MAPR_ENGINE
public static final java.lang.String HBASE_ENGINE
public static final java.lang.String HBASE_TABLE_NAMESPACE_MAPPINGS
public static final org.apache.hadoop.fs.Path HBASE_PREFIX_PATH
public MapRTableMappingRules(org.apache.hadoop.conf.Configuration conf)
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.
conf - public boolean isMapRDefault()
isMapRDefault in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulespublic boolean isMapRClientInstalled()
isMapRClientInstalled in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulespublic void setClusterType(org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType ctype)
setClusterType in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulespublic org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules.ClusterType getClusterType()
getClusterType in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulespublic boolean isMapRTable(byte[] tableName)
tableName should be treated as MapR tableisMapRTable in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulesconf - tableName - true if the table is determined to be a MapR table.java.lang.IllegalArgumentException - If the passed tableName is nullpublic boolean isMapRTable(java.lang.String tableName)
tableName should be treated as MapR tableisMapRTable in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulesconf - tableName - true if the table is determined to be a MapR table.java.lang.IllegalArgumentException - If the passed tableName is nullpublic java.lang.String toString()
toString in class java.lang.Objectpublic org.apache.hadoop.fs.Path getMaprTablePath(byte[] tableName)
getMaprTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulesconf - Hadoop Configuration instancetableName - Absolute or relative table namenull otherwisepublic org.apache.hadoop.fs.Path getMaprTablePath(java.lang.String tableName)
MapRTableMappingRulesgetMaprTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRulestableName - Absolute or relative table namenull otherwiseprotected org.apache.hadoop.fs.Path makePath(java.lang.String parent,
java.lang.String table)
parent - table - protected org.apache.hadoop.fs.FileSystem getFS()
FileSystem object using the Configuration
provided in the constructor. This code will not get executed if there is no
rule with relative path.public static boolean isMapRTable(org.apache.hadoop.conf.Configuration conf,
java.lang.String tableName)
public static org.apache.hadoop.fs.Path getMaprTablePath(org.apache.hadoop.conf.Configuration conf,
java.lang.String tableName)
public org.apache.hadoop.fs.Path getDefaultTablePath()
getDefaultTablePath in class org.apache.hadoop.hbase.client.mapr.BaseTableMappingRules