From 117e1a6bb889059243e3ca14a77aca160d940d97 Mon Sep 17 00:00:00 2001 From: ZackYoung Date: Tue, 26 Nov 2024 18:39:42 +0800 Subject: [PATCH] [Optimize][Flink]Optimize DInky without Flink dependency, unable to start, etc (#3955) --- .../org/dinky/controller/FlinkController.java | 6 ++-- .../main/java/org/dinky/init/SystemInit.java | 36 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/controller/FlinkController.java b/dinky-admin/src/main/java/org/dinky/controller/FlinkController.java index f50e2178f2..a60b123980 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/FlinkController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/FlinkController.java @@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController; import cn.dev33.satoken.annotation.SaCheckLogin; +import cn.hutool.core.lang.Singleton; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -45,14 +46,13 @@ @SaCheckLogin @RequiredArgsConstructor public class FlinkController { - - protected static final CheckpointRead INSTANCE = new CheckpointRead(); private final FlinkService flinkService; @GetMapping("/readCheckPoint") @ApiOperation("Read Checkpoint") public Result>> readCheckPoint(String path, String operatorId) { - return Result.data(INSTANCE.readCheckpoint(path, operatorId)); + CheckpointRead checkpointRead = Singleton.get(CheckpointRead.class); + return Result.data(checkpointRead.readCheckpoint(path, operatorId)); } @GetMapping("/configOptions") diff --git a/dinky-admin/src/main/java/org/dinky/init/SystemInit.java b/dinky-admin/src/main/java/org/dinky/init/SystemInit.java index 2ac2720263..bc1af97dd4 100644 --- a/dinky-admin/src/main/java/org/dinky/init/SystemInit.java +++ b/dinky-admin/src/main/java/org/dinky/init/SystemInit.java @@ -93,20 +93,30 @@ public class SystemInit implements ApplicationRunner { @Override public void run(ApplicationArguments args) { - TenantContextHolder.ignoreTenant(); - initResources(); - List tenants = tenantService.list(); - sysConfigService.initSysConfig(); - sysConfigService.initExpressionVariables(); - - for (Tenant tenant : tenants) { - taskService.initDefaultFlinkSQLEnv(tenant.getId()); + try { + TenantContextHolder.ignoreTenant(); + initResources(); + List tenants = tenantService.list(); + sysConfigService.initSysConfig(); + sysConfigService.initExpressionVariables(); + + for (Tenant tenant : tenants) { + taskService.initDefaultFlinkSQLEnv(tenant.getId()); + } + initDaemon(); + initDolphinScheduler(); + registerUDF(); + updateGitBuildState(); + registerURL(); + } catch (NoClassDefFoundError e) { + if (e.getMessage().contains("org/apache/flink")) { + log.error( + "No Flink Jar dependency detected, please put the Flink Jar dependency into the DInky program first. (未检测到有 Flink Jar依赖,请先放入 Flink Jar 依赖到 DInky程序里)", + e); + } else { + log.error("", e); + } } - initDaemon(); - initDolphinScheduler(); - registerUDF(); - updateGitBuildState(); - registerURL(); } private void registerURL() {