在每個API調用,我這樣做:HBase的連接關閉()
Configuration config = HBaseConfiguration.create();
Path hbase = new Path("hbase-site.xml");
Path core = new Path("core-site.xml");
config.addResource(hbase);
config.addResource(core);
Connection connection = ConnectionFactory.createConnection(config);
然後當我獲取當前API調用數據關閉此連接:
finally {
if (null != connection) {
try {
connection.close();
} catch (Exception e) {
}
}
}
請告訴我這個模型是正確的還是錯誤的。每個api請求都需要以這種方式提供服務 - 使用ConnectionFactory打開連接,獲取數據並最終關閉它。我聽到有人說這個連接不需要關閉。
請指教