Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue_997][taier-all] support hive properties set fix #997 #1001

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,23 @@
</logger>

<logger name="com.dtstack.taier.scheduler.server.scheduler" level="info" additivity="false">
<appender-ref ref="schedule" />
<appender-ref ref="schedule"/>
</logger>
<logger name="com.dtstack.taier.scheduler.server.queue.JopPriorityQueue" level="info" additivity="false">
<appender-ref ref="schedule" />
<appender-ref ref="schedule"/>
</logger>

<logger name="com.dtstack.taier.datasource" level="error" additivity="false">
<appender-ref ref="schedule" />
<appender-ref ref="schedule"/>
</logger>

<logger name="org.apache.hive.jdbc" level="error" additivity="false">
<appender-ref ref="allAppender"/>
</logger>

<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="allAppender" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="allAppender"/>
</root>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@
public class PropertiesUtil {

public static Properties convertToProp(RdbmsSourceDTO rdbmsSourceDTO) {
return convertToProp(rdbmsSourceDTO, null);
return convertToProp(rdbmsSourceDTO, null, null);
}

public static Properties convertToProp(RdbmsSourceDTO rdbmsSourceDTO, Properties properties) {
return convertToProp(rdbmsSourceDTO, properties, null);
}

public static Properties convertToProp(RdbmsSourceDTO rdbmsSourceDTO, Properties properties, String prefix) {
if (Objects.isNull(properties)) {
properties = new Properties();
}
Expand All @@ -56,7 +60,8 @@ public static Properties convertToProp(RdbmsSourceDTO rdbmsSourceDTO, Properties
for (String key : propertiesJson.keySet()) {
String value = propertiesJson.getString(key);
if (StringUtils.isNotBlank(value)) {
properties.setProperty(key, value);
String newKey = key.startsWith(prefix) ? key : prefix + key;
properties.setProperty(newKey, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Connection getConn(ISourceDTO sourceDTO) throws Exception {
Properties properties = new Properties();
SSLUtil.SSLConfiguration sslConfiguration = SSLUtil.getSSLConfiguration(hiveSourceDTO);
dealSsl(properties, sslConfiguration);
PropertiesUtil.convertToProp(hiveSourceDTO, properties);
PropertiesUtil.convertToProp(hiveSourceDTO, properties, HIVE_CONF_PREFIX);
properties.put(DtClassConsistent.PublicConsistent.USER, hiveSourceDTO.getUsername() == null ? "" : hiveSourceDTO.getUsername());
properties.put(DtClassConsistent.PublicConsistent.PASSWORD, hiveSourceDTO.getPassword() == null ? "" : hiveSourceDTO.getPassword());
setQueue(properties, hiveSourceDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

package com.dtstack.taier.datasource.plugin.hive1;

import com.dtstack.taier.datasource.api.dto.SqlQueryDTO;
import com.dtstack.taier.datasource.api.dto.source.Hive1SourceDTO;
import com.dtstack.taier.datasource.api.dto.source.ISourceDTO;
import com.dtstack.taier.datasource.api.exception.SourceException;
import com.dtstack.taier.datasource.api.source.DataBaseType;
import com.dtstack.taier.datasource.plugin.common.DtClassConsistent;
import com.dtstack.taier.datasource.plugin.common.constant.CommonConstant;
import com.dtstack.taier.datasource.plugin.common.exception.ErrorCode;
Expand All @@ -27,11 +32,6 @@
import com.dtstack.taier.datasource.plugin.common.utils.SqlFormatUtil;
import com.dtstack.taier.datasource.plugin.kerberos.core.util.KerberosLoginUtil;
import com.dtstack.taier.datasource.plugin.rdbms.ConnFactory;
import com.dtstack.taier.datasource.api.dto.SqlQueryDTO;
import com.dtstack.taier.datasource.api.dto.source.Hive1SourceDTO;
import com.dtstack.taier.datasource.api.dto.source.ISourceDTO;
import com.dtstack.taier.datasource.api.exception.SourceException;
import com.dtstack.taier.datasource.api.source.DataBaseType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -53,6 +53,9 @@
@Slf4j
public class HiveConnFactory extends ConnFactory {

// Hive 属性前缀
private static final String HIVE_CONF_PREFIX = "hiveconf:";

private static final String SSL_FLAG = "ssl";

private static final String SSL_TRUST_STORE = "sslTrustStore";
Expand Down Expand Up @@ -82,7 +85,7 @@ public Connection getConn(ISourceDTO sourceDTO) throws Exception {
properties.put(DtClassConsistent.PublicConsistent.USER, hive1SourceDTO.getUsername() == null ? "" : hive1SourceDTO.getUsername());
properties.put(DtClassConsistent.PublicConsistent.PASSWORD, hive1SourceDTO.getPassword() == null ? "" : hive1SourceDTO.getPassword());

PropertiesUtil.convertToProp(hive1SourceDTO, properties);
PropertiesUtil.convertToProp(hive1SourceDTO, properties, HIVE_CONF_PREFIX);
setQueue(properties, hive1SourceDTO);
String urlWithoutSchema = HiveDriverUtil.removeSchema(hive1SourceDTO.getUrl());
return DriverManager.getConnection(urlWithoutSchema, properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
@Slf4j
public class HiveConnFactory extends ConnFactory {

// Hive 属性前缀
private static final String HIVE_CONF_PREFIX = "hiveconf:";

private static final String SSL_FLAG = "ssl";

private static final String SSL_TRUST_STORE = "sslTrustStore";
Expand Down Expand Up @@ -79,7 +82,7 @@ public Connection getConn(ISourceDTO sourceDTO) throws Exception {
dealSsl(properties, sslConfiguration);
properties.put(DtClassConsistent.PublicConsistent.USER, hiveSourceDTO.getUsername() == null ? "" : hiveSourceDTO.getUsername());
properties.put(DtClassConsistent.PublicConsistent.PASSWORD, hiveSourceDTO.getPassword() == null ? "" : hiveSourceDTO.getPassword());
PropertiesUtil.convertToProp(hiveSourceDTO, properties);
PropertiesUtil.convertToProp(hiveSourceDTO, properties, HIVE_CONF_PREFIX);
setQueue(properties, hiveSourceDTO);
String urlWithoutSchema = HiveDriverUtil.removeSchema(hiveSourceDTO.getUrl());
return DriverManager.getConnection(urlWithoutSchema, properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.dtstack.taier.datasource.api.client.IClient;
import com.dtstack.taier.datasource.api.dto.SqlQueryDTO;
import com.dtstack.taier.datasource.api.dto.source.ISourceDTO;
import com.dtstack.taier.datasource.api.dto.source.RdbmsSourceDTO;
import com.dtstack.taier.pluginapi.JobClient;
import com.dtstack.taier.pluginapi.enums.TaskStatus;
import com.dtstack.taier.pluginapi.pojo.JudgeResult;
Expand Down Expand Up @@ -82,6 +83,14 @@ public void executeJob(JobClient jobClient) {
LOGGER.info("jobId:{} taskType:{} submit to job start run", jobClient.getJobId(), jobClient.getTaskType());
// executeBatchQuery 执行不成功 会执行抛异常,不会返回false
ISourceDTO sourceDTO = sourceDTOLoader.buildSourceDTO(jobClient.getDatasourceId());
if (sourceDTO instanceof RdbmsSourceDTO) {
RdbmsSourceDTO rdbmsSourceDTO = (RdbmsSourceDTO) sourceDTO;
try {
rdbmsSourceDTO.setProperties(JSONObject.toJSONString(jobClient.getConfProperties()));
} catch (Exception e) {
}
sourceDTO = rdbmsSourceDTO;
}
IClient client = ClientCache.getClient(sourceDTO.getSourceType());
client.executeBatchQuery(sourceDTO, SqlQueryDTO.builder().sql(jobClient.getSql()).build());
try {
Expand Down