从 Java 应用程序连接到 Kerberos 安全 HBase 集群
Connecting to Kerberos secured HBase cluster from Java application
我正在尝试使用以下代码连接到 hbase:
@测试
public void onTrigger() 抛出异常 {
TestRunner runner = getTestRunner();
runner.run();
}
私有 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(最终的 TestRunner 运行器)抛出 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;
}
并得到一个错误。无法理解为什么我会出现这样的错误:
'HBase Client Service' 无效,因为需要 HBase 客户端服务
'Hadoop Configuration Files' 针对 '../hbase-site.xml、../core-site.xml' 验证无效,因为 'Hadoop Configuration Files' 不受支持 属性
TestRunner 是为处理器制作的,您可以在创建它时看到它并说 "newTestRunner(PutAllHbaseAvro.class)"。当您调用 runner.setProperty(name, value)
时,它会尝试在处理器上设置 属性,但您的处理器没有 hadoop conf 文件 属性,服务有。要在服务上设置它,您必须进行不同的调用 runner.setProperty(service, name, value)
。
我正在尝试使用以下代码连接到 hbase:
@测试 public void onTrigger() 抛出异常 {
TestRunner runner = getTestRunner();
runner.run();
}
私有 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(最终的 TestRunner 运行器)抛出 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;
}
并得到一个错误。无法理解为什么我会出现这样的错误:
'HBase Client Service' 无效,因为需要 HBase 客户端服务 'Hadoop Configuration Files' 针对 '../hbase-site.xml、../core-site.xml' 验证无效,因为 'Hadoop Configuration Files' 不受支持 属性
TestRunner 是为处理器制作的,您可以在创建它时看到它并说 "newTestRunner(PutAllHbaseAvro.class)"。当您调用 runner.setProperty(name, value)
时,它会尝试在处理器上设置 属性,但您的处理器没有 hadoop conf 文件 属性,服务有。要在服务上设置它,您必须进行不同的调用 runner.setProperty(service, name, value)
。