Unverified Commit bab998f9 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Fix] [admin,core] Fix pretreatment twice and unable to alarm (#1492)

parent 54cebe02
...@@ -1270,8 +1270,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1270,8 +1270,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
Integer jobInstanceId = jobInstance.getId(); Integer jobInstanceId = jobInstance.getId();
JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceId); // 获取任务历史信息 JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceId); // 获取任务历史信息
String jobJson = jobHistory.getJobJson(); // 获取任务历史信息的jobJson ObjectNode jsonNodes = jobHistory.getJob();
ObjectNode jsonNodes = JSONUtil.parseObject(jobJson);
if (jsonNodes.has("errors")) { if (jsonNodes.has("errors")) {
return; return;
} }
...@@ -1288,8 +1287,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1288,8 +1287,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
String duration = getDuration(asLongStartTime, asLongEndTime); String duration = getDuration(asLongStartTime, asLongEndTime);
// 获取任务的 duration 使用的是 start-time 和 end-time 计算 // 获取任务的 duration 使用的是 start-time 和 end-time 计算
// 不采用 duration 字段 // 不采用 duration 字段
String clusterJson = jobHistory.getClusterJson(); // 获取任务历史信息的clusterJson 主要获取 jobManagerHost // 获取任务历史信息的clusterJson 主要获取 jobManagerHost
ObjectNode clusterJsonNodes = JSONUtil.parseObject(clusterJson); ObjectNode clusterJsonNodes = jobHistory.getCluster();
String jobManagerHost = clusterJsonNodes.get("jobManagerHost").asText(); String jobManagerHost = clusterJsonNodes.get("jobManagerHost").asText();
if (Asserts.isNotNull(task.getAlertGroupId())) { if (Asserts.isNotNull(task.getAlertGroupId())) {
...@@ -1431,8 +1430,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1431,8 +1430,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private void findTheConditionSavePointToOnline(TaskOperatingResult taskOperatingResult, private void findTheConditionSavePointToOnline(TaskOperatingResult taskOperatingResult,
JobInstance jobInstanceByTaskId) { JobInstance jobInstanceByTaskId) {
final JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceByTaskId.getId()); final JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceByTaskId.getId());
if (jobHistory != null && StringUtils.isNotBlank(jobHistory.getCheckpointsJson())) { if (jobHistory != null) {
final ObjectNode jsonNodes = JSONUtil.parseObject(jobHistory.getCheckpointsJson()); final ObjectNode jsonNodes = jobHistory.getCheckpoints();
final ArrayNode history = jsonNodes.withArray("history"); final ArrayNode history = jsonNodes.withArray("history");
if (!history.isEmpty()) { if (!history.isEmpty()) {
startGoingLiveTask(taskOperatingResult, findTheConditionSavePoint(history)); startGoingLiveTask(taskOperatingResult, findTheConditionSavePoint(history));
......
...@@ -114,7 +114,7 @@ public class Explainer { ...@@ -114,7 +114,7 @@ public class Explainer {
public Explainer initialize(JobManager jobManager, JobConfig config, String statement) { public Explainer initialize(JobManager jobManager, JobConfig config, String statement) {
jobManager.initClassLoader(config); jobManager.initClassLoader(config);
jobManager.initUDF(pretreatStatements(SqlUtil.getStatements(statement, sqlSeparator)).getUdfList()); jobManager.initUDF(parseUDFFromStatements(SqlUtil.getStatements(statement, sqlSeparator)));
return this; return this;
} }
...@@ -145,7 +145,10 @@ public class Explainer { ...@@ -145,7 +145,10 @@ public class Explainer {
} else if (operationType.equals(SqlType.EXECUTE)) { } else if (operationType.equals(SqlType.EXECUTE)) {
execute.add(new StatementParam(statement, operationType)); execute.add(new StatementParam(statement, operationType));
} else { } else {
UDF udf = UDFUtil.toUDF(statement);
if (Asserts.isNotNull(udf)) {
udfList.add(UDFUtil.toUDF(statement)); udfList.add(UDFUtil.toUDF(statement));
}
ddl.add(new StatementParam(statement, operationType)); ddl.add(new StatementParam(statement, operationType));
statementList.add(statement); statementList.add(statement);
} }
...@@ -153,6 +156,20 @@ public class Explainer { ...@@ -153,6 +156,20 @@ public class Explainer {
return new JobParam(statementList, ddl, trans, execute, CollUtil.removeNull(udfList)); return new JobParam(statementList, ddl, trans, execute, CollUtil.removeNull(udfList));
} }
public List<UDF> parseUDFFromStatements(String[] statements) {
List<UDF> udfList = new ArrayList<>();
for (String statement : statements) {
if (statement.isEmpty()) {
continue;
}
UDF udf = UDFUtil.toUDF(statement);
if (Asserts.isNotNull(udf)) {
udfList.add(UDFUtil.toUDF(statement));
}
}
return udfList;
}
public List<SqlExplainResult> explainSqlResult(String statement) { public List<SqlExplainResult> explainSqlResult(String statement) {
String[] sqls = SqlUtil.getStatements(statement, sqlSeparator); String[] sqls = SqlUtil.getStatements(statement, sqlSeparator);
List<SqlExplainResult> sqlExplainRecords = new ArrayList<>(); List<SqlExplainResult> sqlExplainRecords = new ArrayList<>();
......
...@@ -290,8 +290,10 @@ public class JobManager { ...@@ -290,8 +290,10 @@ public class JobManager {
} }
public void initUDF(List<UDF> udfList) { public void initUDF(List<UDF> udfList) {
if (Asserts.isNotNullCollection(udfList)) {
initUDF(udfList, runMode, config.getTaskId()); initUDF(udfList, runMode, config.getTaskId());
} }
}
public void initUDF(List<UDF> udfList, GatewayType runMode, Integer taskId) { public void initUDF(List<UDF> udfList, GatewayType runMode, Integer taskId) {
if (taskId == null) { if (taskId == null) {
......
...@@ -43,6 +43,14 @@ public class JobParam { ...@@ -43,6 +43,14 @@ public class JobParam {
this.trans = trans; this.trans = trans;
} }
public JobParam(List<String> statements, List<StatementParam> ddl, List<StatementParam> trans,
List<StatementParam> execute) {
this.statements = statements;
this.ddl = ddl;
this.trans = trans;
this.execute = execute;
}
public JobParam(List<String> statements, List<StatementParam> ddl, List<StatementParam> trans, public JobParam(List<String> statements, List<StatementParam> ddl, List<StatementParam> trans,
List<StatementParam> execute, List<UDF> udfList) { List<StatementParam> execute, List<UDF> udfList) {
this.statements = statements; this.statements = statements;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment