|
|
@ -29,6 +29,7 @@ import cn.escheduler.common.task.sql.SqlBinds; |
|
|
|
import cn.escheduler.common.task.sql.SqlParameters; |
|
|
|
import cn.escheduler.common.task.sql.SqlParameters; |
|
|
|
import cn.escheduler.common.task.sql.SqlType; |
|
|
|
import cn.escheduler.common.task.sql.SqlType; |
|
|
|
import cn.escheduler.common.utils.CollectionUtils; |
|
|
|
import cn.escheduler.common.utils.CollectionUtils; |
|
|
|
|
|
|
|
import cn.escheduler.common.utils.CommonUtils; |
|
|
|
import cn.escheduler.common.utils.ParameterUtils; |
|
|
|
import cn.escheduler.common.utils.ParameterUtils; |
|
|
|
import cn.escheduler.dao.AlertDao; |
|
|
|
import cn.escheduler.dao.AlertDao; |
|
|
|
import cn.escheduler.dao.DaoFactory; |
|
|
|
import cn.escheduler.dao.DaoFactory; |
|
|
@ -43,6 +44,8 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang3.EnumUtils; |
|
|
|
import org.apache.commons.lang3.EnumUtils; |
|
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration; |
|
|
|
|
|
|
|
import org.apache.hadoop.security.UserGroupInformation; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.sql.*; |
|
|
|
import java.sql.*; |
|
|
@ -51,6 +54,8 @@ import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.escheduler.common.utils.PropertyUtils.getString; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* sql task |
|
|
|
* sql task |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -228,7 +233,15 @@ public class SqlTask extends AbstractTask { |
|
|
|
List<String> createFuncs){ |
|
|
|
List<String> createFuncs){ |
|
|
|
Connection connection = null; |
|
|
|
Connection connection = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
if (CommonUtils.getKerberosStartupState()) { |
|
|
|
|
|
|
|
System.setProperty(cn.escheduler.common.Constants.JAVA_SECURITY_KRB5_CONF, |
|
|
|
|
|
|
|
getString(cn.escheduler.common.Constants.JAVA_SECURITY_KRB5_CONF_PATH)); |
|
|
|
|
|
|
|
Configuration configuration = new Configuration(); |
|
|
|
|
|
|
|
configuration.set(cn.escheduler.common.Constants.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); |
|
|
|
|
|
|
|
UserGroupInformation.setConfiguration(configuration); |
|
|
|
|
|
|
|
UserGroupInformation.loginUserFromKeytab(getString(cn.escheduler.common.Constants.LOGIN_USER_KEY_TAB_USERNAME), |
|
|
|
|
|
|
|
getString(cn.escheduler.common.Constants.LOGIN_USER_KEY_TAB_PATH)); |
|
|
|
|
|
|
|
} |
|
|
|
if (DbType.HIVE.name().equals(sqlParameters.getType())) { |
|
|
|
if (DbType.HIVE.name().equals(sqlParameters.getType())) { |
|
|
|
Properties paramProp = new Properties(); |
|
|
|
Properties paramProp = new Properties(); |
|
|
|
paramProp.setProperty("user", baseDataSource.getUser()); |
|
|
|
paramProp.setProperty("user", baseDataSource.getUser()); |
|
|
@ -278,7 +291,7 @@ public class SqlTask extends AbstractTask { |
|
|
|
array.add(mapOfColValues); |
|
|
|
array.add(mapOfColValues); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logger.info("execute sql : {}", JSONObject.toJSONString(array, SerializerFeature.WriteMapNullValue)); |
|
|
|
logger.debug("execute sql : {}", JSONObject.toJSONString(array, SerializerFeature.WriteMapNullValue)); |
|
|
|
|
|
|
|
|
|
|
|
// send as an attachment
|
|
|
|
// send as an attachment
|
|
|
|
if (StringUtils.isEmpty(sqlParameters.getShowType())) { |
|
|
|
if (StringUtils.isEmpty(sqlParameters.getShowType())) { |
|
|
|