|
|
|
@ -34,7 +34,8 @@ import java.io.IOException;
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
import java.sql.DriverManager; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
public class HiveDataSourceProcessor extends AbstractDataSourceProcessor { |
|
|
|
@ -46,7 +47,7 @@ public class HiveDataSourceProcessor extends AbstractDataSourceProcessor {
|
|
|
|
|
|
|
|
|
|
hiveDataSourceParamDTO.setDatabase(hiveConnectionParam.getDatabase()); |
|
|
|
|
hiveDataSourceParamDTO.setUserName(hiveConnectionParam.getUser()); |
|
|
|
|
hiveDataSourceParamDTO.setOther(parseOther(hiveConnectionParam.getOther())); |
|
|
|
|
hiveDataSourceParamDTO.setOther(hiveConnectionParam.getOther()); |
|
|
|
|
hiveDataSourceParamDTO.setLoginUserKeytabUsername(hiveConnectionParam.getLoginUserKeytabUsername()); |
|
|
|
|
hiveDataSourceParamDTO.setLoginUserKeytabPath(hiveConnectionParam.getLoginUserKeytabPath()); |
|
|
|
|
hiveDataSourceParamDTO.setJavaSecurityKrb5Conf(hiveConnectionParam.getJavaSecurityKrb5Conf()); |
|
|
|
@ -90,8 +91,7 @@ public class HiveDataSourceProcessor extends AbstractDataSourceProcessor {
|
|
|
|
|
hiveConnectionParam.setLoginUserKeytabPath(hiveParam.getLoginUserKeytabPath()); |
|
|
|
|
hiveConnectionParam.setLoginUserKeytabUsername(hiveParam.getLoginUserKeytabUsername()); |
|
|
|
|
} |
|
|
|
|
hiveConnectionParam.setOther(transformOther(hiveParam.getOther())); |
|
|
|
|
hiveConnectionParam.setProps(hiveParam.getOther()); |
|
|
|
|
hiveConnectionParam.setOther(hiveParam.getOther()); |
|
|
|
|
return hiveConnectionParam; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -114,11 +114,10 @@ public class HiveDataSourceProcessor extends AbstractDataSourceProcessor {
|
|
|
|
|
public String getJdbcUrl(ConnectionParam connectionParam) { |
|
|
|
|
HiveConnectionParam hiveConnectionParam = (HiveConnectionParam) connectionParam; |
|
|
|
|
String jdbcUrl = hiveConnectionParam.getJdbcUrl(); |
|
|
|
|
String otherParams = filterOther(hiveConnectionParam.getOther()); |
|
|
|
|
if (StringUtils.isNotEmpty(otherParams) && !"?".equals(otherParams.substring(0, 1))) { |
|
|
|
|
jdbcUrl += ";"; |
|
|
|
|
if (MapUtils.isNotEmpty(hiveConnectionParam.getOther())) { |
|
|
|
|
return jdbcUrl + "?" + transformOther(hiveConnectionParam.getOther()); |
|
|
|
|
} |
|
|
|
|
return jdbcUrl + otherParams; |
|
|
|
|
return jdbcUrl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -140,47 +139,9 @@ public class HiveDataSourceProcessor extends AbstractDataSourceProcessor {
|
|
|
|
|
if (MapUtils.isEmpty(otherMap)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
|
otherMap.forEach((key, value) -> stringBuilder.append(String.format("%s=%s;", key, value))); |
|
|
|
|
return stringBuilder.toString(); |
|
|
|
|
List<String> otherList = new ArrayList<>(); |
|
|
|
|
otherMap.forEach((key, value) -> otherList.add(String.format("%s=%s", key, value))); |
|
|
|
|
return String.join(";", otherList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String filterOther(String otherParams) { |
|
|
|
|
if (StringUtils.isBlank(otherParams)) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StringBuilder hiveConfListSb = new StringBuilder(); |
|
|
|
|
hiveConfListSb.append("?"); |
|
|
|
|
StringBuilder sessionVarListSb = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
String[] otherArray = otherParams.split(";", -1); |
|
|
|
|
|
|
|
|
|
for (String conf : otherArray) { |
|
|
|
|
sessionVarListSb.append(conf).append(";"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// remove the last ";"
|
|
|
|
|
if (sessionVarListSb.length() > 0) { |
|
|
|
|
sessionVarListSb.deleteCharAt(sessionVarListSb.length() - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (hiveConfListSb.length() > 0) { |
|
|
|
|
hiveConfListSb.deleteCharAt(hiveConfListSb.length() - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return sessionVarListSb.toString() + hiveConfListSb.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Map<String, String> parseOther(String other) { |
|
|
|
|
if (other == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
Map<String, String> otherMap = new LinkedHashMap<>(); |
|
|
|
|
String[] configs = other.split(";"); |
|
|
|
|
for (String config : configs) { |
|
|
|
|
otherMap.put(config.split("=")[0], config.split("=")[1]); |
|
|
|
|
} |
|
|
|
|
return otherMap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|