AbstractHBaseClient.java 1001 B

12345678910111213141516171819202122232425262728293031323334353637
  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.apache.hadoop.hbase.security.User;
  5. import org.apache.hadoop.security.UserGroupInformation;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.beans.factory.annotation.Value;
  8. import org.springframework.data.hadoop.hbase.HbaseTemplate;
  9. import java.io.IOException;
  10. /**
  11. * @author hzp
  12. * @created 2017.05.03
  13. */
  14. public class AbstractHBaseClient {
  15. @Autowired
  16. protected HbaseTemplate hbaseTemplate;
  17. /**
  18. * 创建连接
  19. */
  20. protected Connection getConnection() throws Exception {
  21. return getConnection(hbaseTemplate);
  22. }
  23. /**
  24. * 创建连接
  25. */
  26. protected Connection getConnection(HbaseTemplate hbaseTemplate) throws Exception {
  27. Connection connection = ConnectionFactory.createConnection(hbaseTemplate.getConfiguration());
  28. return connection;
  29. }
  30. }