AbstractHBaseClient.java 879 B

123456789101112131415161718192021222324252627282930313233343536
  1. package com.yihu.base.hbase;
  2. import org.apache.hadoop.hbase.client.Connection;
  3. import org.apache.hadoop.hbase.client.ConnectionFactory;
  4. import org.springframework.data.hadoop.hbase.HbaseTemplate;
  5. /**
  6. * AbstractHBaseClient - 基类
  7. * @author hzp
  8. * @created 2017.05.03
  9. */
  10. public class AbstractHBaseClient {
  11. public AbstractHBaseClient(HbaseTemplate hbaseTemplate) {
  12. this.hbaseTemplate = hbaseTemplate;
  13. }
  14. protected HbaseTemplate hbaseTemplate;
  15. /**
  16. * 创建连接
  17. */
  18. protected Connection getConnection() throws Exception {
  19. return getConnection(hbaseTemplate);
  20. }
  21. /**
  22. * 创建连接
  23. */
  24. protected Connection getConnection(HbaseTemplate hbaseTemplate) throws Exception {
  25. Connection connection = ConnectionFactory.createConnection(hbaseTemplate.getConfiguration());
  26. return connection;
  27. }
  28. }