1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package com.primeton.dsp.datarelease.data.bdata;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang.StringUtils;
- import java.util.Properties;
- /**
- *
- * 根据参数不同,生成不动的测试连接实例
- *
- * <pre>
- *
- * Created by zhaopx.
- * User: zhaopx
- * Date: 2020/4/21
- * Time: 18:02
- *
- * </pre>
- *
- * @author zhaopx
- */
- @Slf4j
- public class HiveConnectionFactory {
- /**
- * 生成不同的测试实例
- * @return
- */
- public static HiveConnectionService getHiveInstance(Properties hiveResource) {
- String authType = hiveResource.getProperty("authType");
- String hiveDbUser = hiveResource.getProperty("hiveDbUser");
- if("noauth".equalsIgnoreCase(authType)) {
- // 默认无认证的方式测试
- return new SimpleHiveConnectionServiceImpl(hiveResource);
- } else if ("kerberos".equalsIgnoreCase(authType) && StringUtils.isNotBlank(hiveDbUser)) {
- return new Krb5HiveConnectionServiceImpl(hiveResource);
- } else if ("fi".equalsIgnoreCase(authType) && StringUtils.isNotBlank(hiveDbUser)) {
- return new FIHiveConnectionServiceImpl(hiveResource);
- }
- // 未知的方式,只能通过简单的来处理一下了。
- log.info("未知的Hive认证方式:" + authType);
- return new SimpleHiveConnectionServiceImpl(hiveResource);
- }
- }
|