简体   繁体   English

从Java应用程序连接到Kerberos保护HBase集群

[英]Connecting to Kerberos secured HBase cluster from Java application

I am trying to connect to hbase using the following code: 我正在尝试使用以下代码连接到hbase:

@Test public void onTrigger() throws Exception { @Test public void onTrigger()抛出Exception {

    TestRunner runner = getTestRunner();
      runner.run();

} }

private TestRunner getTestRunner() throws FileNotFoundException, InitializationException { private TestRunner getTestRunner()抛出FileNotFoundException,InitializationException {

    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(final TestRunner runner) throws InitializationException { private HBaseMyClientService getHBaseClientService(final TestRunner runner)抛出InitializationException {

    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;

}

and get an error. 并得到一个错误。 Can not understand why I have such a mistake: 无法理解为什么我有这样的错误:

'HBase Client Service' is invalid because HBase Client Service is required 'Hadoop Configuration Files' validated against '../hbase-site.xml, ../core-site.xml' is invalid because 'Hadoop Configuration Files' is not a supported property 'HBase客户端服务'无效,因为HBase客户端服务是必需的'Hadoop配置文件'验证'../hbase-site.xml,../core-site.xml'无效,因为'Hadoop配置文件'不是支持的财产

A TestRunner is made for a processor which you can see when you create it and say "newTestRunner(PutAllHbaseAvro.class)". TestRunner是为处理器制作的,您可以在创建它时看到并说“newTestRunner(PutAllHbaseAvro.class)”。 When you call runner.setProperty(name, value) , it is trying to set that property on the processor, but your processor doesn't have the hadoop conf files property, the service has it. 当你调用runner.setProperty(name, value) ,它试图在处理器上设置该属性,但是你的处理器没有hadoop conf files属性,服务就有了它。 To set it on the service you have to make a different call runner.setProperty(service, name, value) . 要在服务上设置它,您必须进行另一个调用runner.setProperty(service, name, value)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM