HiveConnectionFactory.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.primeton.dsp.datarelease.data.bdata;
  2. import com.primeton.dsp.datarelease.server.model.DspHiveResource;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.apache.commons.lang.StringUtils;
  5. /**
  6. *
  7. * 根据参数不同,生成不动的测试连接实例
  8. *
  9. * <pre>
  10. *
  11. * Created by zhaopx.
  12. * User: zhaopx
  13. * Date: 2020/4/21
  14. * Time: 18:02
  15. *
  16. * </pre>
  17. *
  18. * @author zhaopx
  19. */
  20. @Slf4j
  21. public class HiveConnectionFactory {
  22. /**
  23. * 生成不同的测试实例
  24. * @return
  25. */
  26. public static HiveConnectionService getHiveInstance(DspHiveResource hiveResource) {
  27. String type = hiveResource.getCollectionType();
  28. String authType = hiveResource.getAuthType();
  29. String hiveDbUser = hiveResource.getHiveDbUser();
  30. if(StringUtils.isBlank(hiveDbUser) || "noauth".equalsIgnoreCase(authType)) {
  31. // 默认无认证的方式测试
  32. return new SimpleHiveConnectionServiceImpl(hiveResource);
  33. } else if ("kerberos".equalsIgnoreCase(authType) && StringUtils.isNotBlank(hiveDbUser)) {
  34. return new Krb5HiveConnectionServiceImpl(hiveResource);
  35. } else if ("fi".equalsIgnoreCase(authType) && StringUtils.isNotBlank(hiveDbUser)) {
  36. return new FIHiveConnectionServiceImpl(hiveResource);
  37. }
  38. // 未知的方式,只能通过简单的来处理一下了。
  39. log.info("未知的Hive认证方式:" + authType);
  40. return new SimpleHiveConnectionServiceImpl(hiveResource);
  41. }
  42. }