HBaseConnectionFactory.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.primeton.damp.bigdata;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.apache.commons.lang.StringUtils;
  4. import java.util.Properties;
  5. import java.util.Set;
  6. /**
  7. *
  8. * 根据参数不同,生成不动的测试连接实例
  9. *
  10. * <pre>
  11. *
  12. * Created by zhaopx.
  13. * User: zhaopx
  14. * Date: 2020/4/21
  15. * Time: 18:02
  16. *
  17. * </pre>
  18. *
  19. * @author zhaopx
  20. */
  21. @Slf4j
  22. public class HBaseConnectionFactory {
  23. /**
  24. * 生成不同的测试实例
  25. * @return
  26. */
  27. public static HBaseConnectionService getHBaseInstance(Properties hbaseResource) {
  28. String authUser = hbaseResource.getProperty("authUser");
  29. String authType = hbaseResource.getProperty("authType");
  30. if("noauth".equalsIgnoreCase(authType) || StringUtils.isBlank(authUser) || "default".equalsIgnoreCase(authUser)) {
  31. // 无需认证
  32. return new SimpleHBaseConnectionServiceImpl(hbaseResource);
  33. } else if("kerberos".equalsIgnoreCase(authType)){
  34. // kerberos 认证
  35. return new Krb5HBaseConnectionServiceImpl(hbaseResource);
  36. } else {
  37. //fi 华为
  38. return new FiHBaseConnectionServiceImpl(hbaseResource);
  39. }
  40. }
  41. }