我正在尝试使用以下代码连接到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;
}
私有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客户端服务”无效,因为需要HBase客户端服务 针对“ ../hbase-site.xml、../core-site.xml”验证的“ Hadoop配置文件”无效,因为“ Hadoop配置文件”不是受支持的属性
答案 0 :(得分:0)
TestRunner是为处理器创建的,您可以在创建处理器时看到它,并说“ newTestRunner(PutAllHbaseAvro.class)”。当您调用import matplotlib.pyplot as plt
distance = [100, 200, 300, 400, 500, 3000]
value = [10, 15, 50, 74, 95, 98]
plt.barh(range(len(distance)), value, height=0.6)
plt.yticks(range(len(distance)), distance)
plt.show()
时,它正在尝试在处理器上设置该属性,但是您的处理器没有hadoop conf files属性,该服务具有此属性。要在服务上进行设置,您必须拨打其他电话runner.setProperty(name, value)
。