Updated on 2022-06-01 GMT+08:00

Creating the Configuration Object

Function Description

HBase obtains configuration items by loading a configuration file, including user login information configuration items.

Sample Code

The following code snippets are in the com.huawei.bigdata.hbase.examples packet.

Invoke the init () method under the TestMain class to initialize the Configuration object.

    private static void init() throws IOException {
        // load hbase client info
        if(clientInfo == null) {
            clientInfo = new ClientInfo(CONF_DIR + HBASE_CLIENT_PROPERTIES);
            restServerInfo = clientInfo.getRestServerInfo();
        }
        // Default load from conf directory
        conf = HBaseConfiguration.create();

        conf.addResource(CONF_DIR + "core-site.xml");
        conf.addResource(CONF_DIR + "hdfs-site.xml");
        conf.addResource(CONF_DIR + "hbase-site.xml");

    }