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_1157][taier-scheduler] fix DataX sqlText replace #1157 #1158

Merged
merged 1 commit into from
Mar 15, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package com.dtstack.taier.scheduler.service;

import com.alibaba.fastjson.JSONObject;
import com.dtstack.taier.common.enums.EScheduleJobType;
import com.dtstack.taier.common.env.EnvironmentContext;
import com.dtstack.taier.common.exception.TaierDefineException;
import com.dtstack.taier.common.util.TaskParamsUtils;
import com.dtstack.taier.dao.domain.ScheduleJob;
import com.dtstack.taier.dao.domain.ScheduleTaskShade;
import com.dtstack.taier.dao.dto.ScheduleTaskParamShade;
import com.dtstack.taier.pluginapi.constrant.ConfigConstant;
import com.dtstack.taier.pluginapi.enums.EDeployMode;
import com.dtstack.taier.scheduler.PluginWrapper;
import com.dtstack.taier.scheduler.executor.DatasourceOperator;
import com.dtstack.taier.scheduler.server.pipeline.JobParamReplace;
import com.dtstack.taier.scheduler.utils.CreateJsonFileUtil;
import com.dtstack.taier.scheduler.utils.FileUtil;
import com.dtstack.taier.scheduler.utils.ScriptUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -35,15 +28,6 @@
@Service
public class DataxService {

@Autowired
private ClusterService clusterService;

@Autowired
private EnvironmentContext environmentContext;

@Autowired
private DatasourceOperator datasourceOperator;

@Autowired
private PluginWrapper pluginWrapper;

Expand Down Expand Up @@ -74,19 +58,6 @@ public void handDataxParams(Map<String, Object> actionParam, ScheduleTaskShade t
}
dealDataxExeParams(actionParam, task, scheduleJob, sqlText);
}
/**
* 将脚本上传到 hdfs
*
* @param sqlText
* @param task
* @param scheduleJob
* @return
*/
private String uploadToHdfs(String sqlText, ScheduleTaskShade task, ScheduleJob scheduleJob) {
JSONObject pluginInfo = clusterService.pluginInfoJSON(task.getTenantId(), task.getTaskType(), null, null, null);
String hdfsPath = environmentContext.getHdfsTaskPath() + (FileUtil.getUploadFileName(task.getTaskType(), scheduleJob.getJobId()));
return datasourceOperator.uploadToHdfs(pluginInfo, task.getTenantId(), sqlText, hdfsPath);
}

private void dealDataxExeParams(Map<String, Object> actionParam, ScheduleTaskShade task, ScheduleJob scheduleJob,
String sqlText) throws IOException {
Expand All @@ -112,7 +83,7 @@ private void dealDataxExeParams(Map<String, Object> actionParam, ScheduleTaskSha
throw new TaierDefineException("datax.local.path is null");
}
//生成datax的json文件
String taskTempPath = CreateJsonFileUtil.createJsonFile(task.getSqlText(), tempPath, task.getName());
String taskTempPath = CreateJsonFileUtil.createJsonFile(sqlText, tempPath, task.getName());
if (StringUtils.isBlank(taskTempPath)) {
throw new TaierDefineException("创建datax.json文件失败");
}
Expand Down
Loading