Creating the Configuration Object
Function Description
HBase obtains configuration items by loading a configuration file.
- Loading the configuration file is time-consuming. If unnecessary, use the same Configuration object.
- Multi-thread synchronization is not considered in the sample code. If necessary, add it by yourself. Other sample codes are the same.
Sample Code
The following code snippets are in the com.huawei.cloudtable.hbase.examples packet.
private static void init() throws IOException {
// Default load from conf directory
conf = HBaseConfiguration.create(); // Note [1]
String userdir = System.getProperty("user.dir") + File.separator + "conf" + File.separator;
Path hbaseSite = new Path(userdir + "hbase-site.xml");
if (new File(hbaseSite.toString()).exists()) {
conf.addResource(hbaseSite);
}
} Precautions
- Note [1] If the conf directory of the configuration file is added to the classpath path, the code for loading the specified configuration file can be skipped.
Last Article: Parameter Configuration
Next Article: Performing IAM Authentication for Clusters
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.