Skip to content

Commit

Permalink
[Improvement] Optimize selection prompt information when querying in …
Browse files Browse the repository at this point in the history
…yarn application mode; Added Run button to check select execute (#3260)

Co-authored-by: 173lyb <[email protected]>
  • Loading branch information
LeonYoah and 173lyb authored Mar 9, 2024
1 parent 13214ce commit 24887a2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ public JobResult debugTask(TaskDTO task) throws Exception {
task.setUseResult(true);
// Debug mode need execute
task.setStatementSet(false);
// mode check
if (GatewayType.get(task.getType()).isDeployCluster()) {
throw new BusException(Status.MODE_IS_NOT_ALLOW_SELECT.getMessage());
}

// 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
JobResult jobResult;
Expand Down
3 changes: 2 additions & 1 deletion dinky-common/src/main/java/org/dinky/data/enums/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ public enum Status {
TASK_IS_PUBLISH_CANNOT_DELETE(12011, "task.is.publish.cannot.delete"),
TASK_IS_RUNNING_CANNOT_DELETE(12012, "task.is.running.cannot.delete"),
JOB_ALERT_MAX_SEND_COUNT(12013, "job.alert.max.send.count"),
MODE_IS_NOT_ALLOW_SELECT(12014, "mode.is.not.allow.select"),
OPERATE_NOT_SUPPORT_QUERY(12015, "operate.not.support.query"),

/**
* alert instance
Expand Down Expand Up @@ -347,7 +349,6 @@ public enum Status {

SYS_ENV_SETTINGS_DIFF_MINUTE_MAX_SEND_COUNT(120, "sys.env.settings.diffMinuteMaxSendCount"),
SYS_ENV_SETTINGS_DIFF_MINUTE_MAX_SEND_COUNT_NOTE(121, "sys.env.settings.diffMinuteMaxSendCount.note"),

SYS_ENV_SETTINGS_MAX_RETAIN_DAYS(1171, "sys.env.settings.maxRetainDays"),
SYS_ENV_SETTINGS_MAX_RETAIN_DAYS_NOTE(1172, "sys.env.settings.maxRetainDays.note"),
SYS_ENV_SETTINGS_MAX_RETAIN_COUNT(1173, "sys.env.settings.maxRetainCount"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ gateway.kubernetes.test.failed= failed to test the Flink configuration:
task.status.is.not.done=The current job status is not stopped, please stop after operation
task.sql.explain.failed=SQL parsing failed, please check the SQL statement
task.update.failed=Task Update failed
mode.is.not.allow.select=Application / Pre-Job mode does not allow executing select statements. To perform this operation, please switch to Local, Standalone, or Yarn session modes.
operate.not.support.query=The [Run] button does not support select statements, please switch to the [Query] button.

# process
process.submit.submitTask= Submit the job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ gateway.kubernetes.test.failed=测试 Flink 配置失败:
task.status.is.not.done=当前作业状态未停止,请停止后操作
task.sql.explain.failed=sql解析失败,请检查
task.update.failed=Task更新失败
mode.is.not.allow.select=Application / Pre-Job 模式不允许执行 select 语句, 如需执行此操作, 请切换至 Local、Standalone、Yarn session等模式
operate.not.support.query=[运行] 按钮不支持 select 语句,请切换至 [查询] 按钮

# process
process.submit.submitTask=提交作业
Expand Down
8 changes: 6 additions & 2 deletions dinky-core/src/main/java/org/dinky/job/JobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.dinky.data.annotations.ProcessStep;
import org.dinky.data.enums.GatewayType;
import org.dinky.data.enums.ProcessStepType;
import org.dinky.data.enums.Status;
import org.dinky.data.exception.BusException;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.data.result.ErrorResult;
Expand Down Expand Up @@ -108,7 +109,6 @@ public class JobManager {
private boolean useStatementSet = false;
private boolean useRestAPI = false;
private GatewayType runMode = GatewayType.LOCAL;

private JobParam jobParam = null;
private String currentSql = "";
private final WeakReference<DinkyClassLoader> dinkyClassLoader = new WeakReference<>(DinkyClassLoader.build());
Expand Down Expand Up @@ -350,8 +350,12 @@ public JobResult executeSql(String statement) throws Exception {
success();
}
} catch (Exception e) {
String errorMessage = e.getMessage();
if (errorMessage.contains("Only insert statement is supported now")) {
throw new BusException(Status.OPERATE_NOT_SUPPORT_QUERY.getMessage());
}
String error = StrFormatter.format(
"Exception in executing FlinkSQL:\n{}\n{}", SqlUtil.addLineNumber(currentSql), e.getMessage());
"Exception in executing FlinkSQL:\n{}\n{}", SqlUtil.addLineNumber(currentSql), errorMessage);
job.setEndTime(LocalDateTime.now());
job.setStatus(Job.JobStatus.FAILED);
job.setError(error);
Expand Down

0 comments on commit 24887a2

Please sign in to comment.