Apache 什么';这是获得HBase稳定句柄的最佳方法?

Apache 什么';这是获得HBase稳定句柄的最佳方法?,apache,hbase,Apache,Hbase,一种方法是直接调用HTable构造函数,另一种方法是从HConnection调用getTable方法。第二个选项要求HConnection为“非托管”,这对我来说不是很好,因为我的进程将有许多线程访问HBase。我不想重新发明轮子来管理我自己的连接 谢谢你的帮助 [更新]: 我们坚持使用0.98.6,因此ConnectionFactory不可用 我发现下面的jira建议创建一个“非托管”连接并使用单个ExecuteService创建HTable。为什么我们不能简单地使用非托管连接的getTabl

一种方法是直接调用HTable构造函数,另一种方法是从HConnection调用getTable方法。第二个选项要求HConnection为“非托管”,这对我来说不是很好,因为我的进程将有许多线程访问HBase。我不想重新发明轮子来管理我自己的连接

谢谢你的帮助

[更新]: 我们坚持使用0.98.6,因此ConnectionFactory不可用

我发现下面的jira建议创建一个“非托管”连接并使用单个ExecuteService创建HTable。为什么我们不能简单地使用非托管连接的getTable方法来获取HTable?这是因为HTable不是线程安全的吗?

我坚持使用旧版本(感谢您的回复。忘了提到我们坚持使用0.98.6,因此没有连接工厂。我已更新了我的问题,并添加了另一个选项供选择。我已更新了我的答案,希望现在更清楚:)
ExecutorService executor = Executors.newFixedThreadPool(10);
Connection connection = ConnectionFactory.createConnection(conf, executor);
Table table = connection.getTable(TableName.valueOf("mytable"));
try {
    table.get(...);
    ...
} finally {
    table.close();
    connection.close();
}
HConnection connection = HConnectionManager.createConnection(config); // You can also provide an ExecutorService if you want to override the default one. HConnection is thread safe.
HTableInterface table = connection.getTable("table1");
try {
  // Use the table as needed, for a single operation and a single thread
} finally {
  table.close();
  connection.close();
}