Configuring the Default Database for AsyncHBase

For AsynchHBase 1.7 and later, you can configure whether AsyncHBase accesses HBase tables or MapR-DB tables by default. If this value is not configured, AsyncHBase will determine the table type.

You can configure the default database in the asynchbase.conf file and the client application. A default database setting in the client application overrides the default database configuration in the aynchbase.conf file.

The process that AsyncHBase uses to access tables differs based on the default database configuration.
  • When the default database is HBase, AsyncHBase accesses the table using the HBase port that was used to initialize the AsyncHBase client and the table name provided to the application.
  • When the default database is MapR-DB, the table name provided to the application is translated to the MapR-DB table path, and then AsyncHBase accesses the table.
  • When a default database is not configured, AsyncHBase first tries to access the table as a MapR-DB table. If that fails, it tries to access the table as an HBase table.

Set the Default Database using asynchbase.conf

To specify if AsyncHBase accesses HBase tables or MapR-DB tables:
  1. Add the mapr.hbase.default.db parameter in the asynchbase.conf (/opt/mapr/asynchbase/asynchbase-<version>/conf/asynchbase.conf) file.
  2. Set the value of mapr.hbase.default.db to one of the following values which will indicate the default database:
    • hbase
    • maprdb

Set the Default Database in the Client Application

Based on the database that you want as the default, add the following code in the client application:
  • To access MapR-DB tables:
    Config config = new Config();
    String dbString = "maprdb";
    config.overrideConfig(HBaseClient.CONFIG_PARAM_DEFAULT_DB,dbString);
    HBaseClient client = new
    HBaseClient(config);
  • To access HBase tables:
    Config config = new Config();
    String dbString = "hbase";
    config.overrideConfig(HBaseClient.CONFIG_PARAM_DEFAULT_DB,dbString);
    HBaseClient client = new
    HBaseClient(config);