首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Java应用程序连接到Kerberos安全的HBase集群

从Java应用程序连接到Kerberos安全的HBase集群
EN

Stack Overflow用户
提问于 2019-04-22 21:19:08
回答 1查看 103关注 0票数 0

我正在尝试使用以下代码连接到hbase:

@Test public void onTrigger()抛出异常{

代码语言:javascript
复制
    TestRunner runner = getTestRunner();
      runner.run();

}

private TestRunner getTestRunner()抛出FileNotFoundException,InitializationException {

代码语言:javascript
复制
    final TestRunner runner = TestRunners.newTestRunner(PutAllHBaseAVRO.class);
    runner.setProperty(PutAllHBaseAVRO.TABLE_NAME, "myTable");
    runner.setProperty(PutAllHBaseAVRO.COLUMN_FAMILY, "cf");
    runner.setProperty(PutAllHBaseAVRO.BATCH_SIZE, "10000");

    getHBaseClientService(runner);

    runner.setProperty(PutAllHBaseAVRO.ROW_ID,"Row1");

    // runner.setProperty(PutAllHBaseAVRO.HBASE_CLIENT_SERVICE, hBaseClient);
    runner.setProperty(PutAllHBaseAVRO.ROW_FIELD_REVERSE_STATEGY, "Reverse");
    runner.setProperty(PutAllHBaseAVRO.TS_FIELD_NAME, "dateTimeValue");
    runner.setProperty(PutAllHBaseAVRO.TS_FIELD_FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ");
    return runner;
}

private HBaseMyClientService getHBaseClientService(最终TestRunner运行程序)抛出InitializationException {

代码语言:javascript
复制
    final HBaseMyClientService hBaseClient = new HBase_1_1_2_MyClientService();


    runner.setProperty(HBaseMyClientService.HADOOP_CONF_FILES, "../hbase-site.xml, ../core-site.xml");

    runner.addControllerService("HBaseMyClientService", hBaseClient);

    //runner.setProperty("Kerberos Principal", "myKerberosPrincipal");

    //runner.setProperty("Kerberos Keytab", "/mypath.keytab");

   // runner.setProperty(HBaseMyClientService.ZOOKEEPER_QUORUM, "hbaseClient");

   // runner.enableControllerService(hBaseClient);

    return hBaseClient;

}

并得到一个错误。我不明白为什么我会有这样的错误:

'HBase客户端服务‘无效,因为需要核心客户端服务'Hadoop配置文件’根据'../ HBase -site.xml,../hbase-site.xml‘验证无效,因为'Hadoop配置文件’不是受支持的属性

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-23 21:45:06

TestRunner是为处理器创建的,当您创建它并说"newTestRunner(PutAllHbaseAvro.class)“时,您可以看到它。当您调用runner.setProperty(name, value)时,它会尝试在处理器上设置该属性,但是您的处理器没有hadoop conf files属性,而是服务具有该属性。要在服务上设置它,您必须进行一个不同的调用runner.setProperty(service, name, value)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55795047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档