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 1b64c6cabe..cfd875d610 100644 --- a/dinky-admin/src/main/java/org/dinky/init/SystemInit.java +++ b/dinky-admin/src/main/java/org/dinky/init/SystemInit.java @@ -220,7 +220,7 @@ public static Project getProject() { } public void registerUDF() { - List allUDF = taskService.getAllUDF(); + List allUDF = taskService.getReleaseUDF(); if (CollUtil.isNotEmpty(allUDF)) { UdfCodePool.registerPool(allUDF.stream().map(UDFUtils::taskToUDF).collect(Collectors.toList())); } diff --git a/dinky-admin/src/main/java/org/dinky/service/TaskService.java b/dinky-admin/src/main/java/org/dinky/service/TaskService.java index 7a68610be5..3974ef9897 100644 --- a/dinky-admin/src/main/java/org/dinky/service/TaskService.java +++ b/dinky-admin/src/main/java/org/dinky/service/TaskService.java @@ -197,6 +197,12 @@ public interface TaskService extends ISuperService { */ List getAllUDF(); + /** + * Get a list of all release user-defined functions (UDFs) in the system. + * @return A list of {@link Task} objects representing the release UDFs. + */ + List getReleaseUDF(); + /** * Get the API address of the given task. * diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java index 55186c3163..c099ce604a 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java @@ -554,6 +554,9 @@ public boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) thro if (lifeCycle == JobLifeCycle.PUBLISH) { Integer taskVersionId = taskVersionService.createTaskVersionSnapshot(task); task.setVersionId(taskVersionId); + UdfCodePool.addOrUpdate(UDFUtils.taskToUDF(task.buildTask())); + } else { + UdfCodePool.remove(task.getConfigJson().getUdfConfig().getClassName()); } boolean saved = saveOrUpdate(task.buildTask()); if (saved && Asserts.isNotNull(task.getJobInstanceId())) { @@ -613,7 +616,11 @@ public boolean saveOrUpdateTask(Task task) { UdfCodePool.remove(task.getConfigJson().getUdfConfig().getClassName()); } task.getConfigJson().getUdfConfig().setClassName(className); - UdfCodePool.addOrUpdate(UDFUtils.taskToUDF(task)); + if (task.getStep().equals(JobLifeCycle.PUBLISH.getValue())) { + UdfCodePool.addOrUpdate(UDFUtils.taskToUDF(task)); + } else { + UdfCodePool.remove(task.getConfigJson().getUdfConfig().getClassName()); + } } return this.saveOrUpdate(task); @@ -691,6 +698,15 @@ public List getAllUDF() { .isNotNull("save_point_path")); } + @Override + public List getReleaseUDF() { + return list(new LambdaQueryWrapper() + .in(Task::getDialect, Dialect.JAVA.getValue(), Dialect.SCALA.getValue(), Dialect.PYTHON.getValue()) + .eq(Task::getEnabled, 1) + .eq(Task::getStep, JobLifeCycle.PUBLISH.getValue()) + .isNotNull(Task::getSavePointPath)); + } + @Override public boolean rollbackTask(TaskRollbackVersionDTO dto) { if (Asserts.isNull(dto.getVersionId()) || Asserts.isNull(dto.getTaskId())) { diff --git a/pom.xml b/pom.xml index a6af110350..b30e668c02 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 1.3 6.2.0.Final 4.5.13 - 5.8.24 + 5.8.25 2.14.1 2.1.6 1.9.3