MAPREDUCE服务 MRS-初始化HBase配置:代码样例

时间:2024-11-01 09:29:15

代码样例

下面代码片段在com.huawei.bigdata.hbase.examples包的“TestMain”类的init方法中。

private static void init() throws IOException {
    // Default load from conf directory
    conf = HBaseConfiguration.create();
    //In Windows environment
    String userdir = TestMain.class.getClassLoader().getResource("conf").getPath() + File.separator;
    //In Linux environment
    //String userdir = System.getProperty("user.dir") + File.separator + "conf" + File.separator;
    conf.addResource(new Path(userdir + "core-site.xml"), false);
    conf.addResource(new Path(userdir + "hdfs-site.xml"), false);
    conf.addResource(new Path(userdir + "hbase-site.xml"), false);
  }
support.huaweicloud.com/devg-lts-mrs/mrs_07_080015.html