|
|
|
@ -30,13 +30,13 @@ import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
|
|
|
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
import com.google.auto.service.AutoService; |
|
|
|
@ -56,7 +56,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()); |
|
|
|
@ -100,8 +100,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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -124,11 +123,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 |
|
|
|
@ -155,47 +153,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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|