public class MapRTableMappingRules extends Object
TableMappingRule
class encapsulate the rules for
deciding if a table name map to HBase table or a MapR table.
Apache HBase has its own flat namespace (no slashes in a table name). This namespace must be supported by MapR, because:
A single client JAR supports both Goose and Apache HBase.
The following rules determine, based on the table name/path, whether it's a Goose table or an Apache HBase table:
Pattern | Table type |
---|---|
a/b/c (anything with a slash) | Goose |
maprfs://... | Goose |
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 Goose table. Otherwise, it is a stock 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 stock HBase table or a Goose table. This is accomplished with a client-side configuration called hbase.table.namespace.mappings.
Example 1:<name>hbase.table.namespace.mappings</name>
<value>*:/tables</value>
Any flat table name foo is treated as a Goose table at /tables/foo.
Example 2:<name>hbase.table.namespace.mappings</name>
<value>mytable1:/user/aaa,mytable2:/user/bbb</value>
<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 Goose table at /user/aaa/mytable1
. Any flat
table with name starting with "mapr-"
is treated as a Goose
table at /user/bbb/mapr-*
. Any other flat table name
foo
is treated as a Goose table at /tables/foo
.
<name>hbase.table.namespace.mappings</name>
<value></value>
Modifier and Type | Class and Description |
---|---|
static class |
MapRTableMappingRules.ClusterType
Describe the type of cluster based on the running services.
|
Modifier and Type | Field and Description |
---|---|
static String |
HBASE_AVAILABLE |
static String |
HBASE_ENGINE |
static String |
HBASE_PREFIX |
static org.apache.hadoop.fs.Path |
HBASE_PREFIX_PATH |
static String |
HBASE_TABLE_NAMESPACE_MAPPINGS |
static String |
MAPR_ENGINE |
static String |
MAPRFS_PREFIX |
static byte[] |
META_TABLE_NAME
The META table's name.
|
static byte[] |
ROOT_TABLE_NAME
The root table's name.
|
static String |
UTF8_ENCODING
When we encode strings, we always specify UTF8 encoding
|
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 |
---|---|
MapRTableMappingRules.ClusterType |
getClusterType() |
protected org.apache.hadoop.fs.FileSystem |
getFS()
Lazy initialization of
FileSystem object using the Configuration
provided in the constructor. |
static org.apache.hadoop.fs.Path |
getMapRTablePath(org.apache.hadoop.conf.Configuration conf,
String tableName) |
org.apache.hadoop.fs.Path |
getMapRTablePath(String tableName)
Returns translated path according to the configured mapping.
|
boolean |
isMapRDefault() |
static boolean |
isMapRTable(org.apache.hadoop.conf.Configuration conf,
String tableName) |
boolean |
isMapRTable(String tableName)
Tests if
tableName should be treated as MapR table |
static boolean |
isMetaTable(String tableName)
Checks of the tableName being passed represents either
-ROOT- or .META. |
protected org.apache.hadoop.fs.Path |
makePath(String parent,
String table)
Constructs absolute table path from the parent and the table name.
|
String |
toString() |
public static final String MAPR_ENGINE
public static final String HBASE_ENGINE
public static final String HBASE_TABLE_NAMESPACE_MAPPINGS
public static final String HBASE_AVAILABLE
public static final String MAPRFS_PREFIX
public static final String HBASE_PREFIX
public static final org.apache.hadoop.fs.Path HBASE_PREFIX_PATH
public static final byte[] ROOT_TABLE_NAME
public static final byte[] META_TABLE_NAME
public static final String UTF8_ENCODING
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()
public MapRTableMappingRules.ClusterType getClusterType()
public boolean isMapRTable(String tableName)
tableName
should be treated as MapR tabletableName
- true
if the table is determined to be a MapR table.IOException
IllegalArgumentException
- If the passed tableName
is nullpublic static boolean isMapRTable(org.apache.hadoop.conf.Configuration conf, String tableName)
public static boolean isMetaTable(String tableName)
-ROOT-
or .META.
-ROOT-
or .META.
public org.apache.hadoop.fs.Path getMapRTablePath(String tableName) throws IllegalArgumentException
MapRTableMappingRules
tableName
- Absolute or relative table namenull
otherwiseIllegalArgumentException
public static org.apache.hadoop.fs.Path getMapRTablePath(org.apache.hadoop.conf.Configuration conf, String tableName)
protected org.apache.hadoop.fs.Path makePath(String parent, String table)
parent
- table
- IOException
protected org.apache.hadoop.fs.FileSystem getFS() throws IOException
FileSystem
object using the Configuration
provided in the constructor. This code will not get executed if there is no
rule with relative path.IOException
Copyright ? 2010-2019, The Async HBase Authors