Help Center/
CloudTable Service/
Developer Guide/
HBase Application Development Guide/
Developing HBase Applications/
Sample Code Description/
Creating the Configuration Object
Updated on 2024-04-29 GMT+08:00
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.
Parent topic: Sample Code Description
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot