From 6af2bddf715b801ad3ae03a9eff823c069300915 Mon Sep 17 00:00:00 2001 From: "yuhang2.zhang" Date: Fri, 1 Nov 2024 20:14:20 +0800 Subject: [PATCH 1/3] [Bug] [dinky-admin] Fix the issue of primary key generation strategy causing negative primary keys. --- dinky-admin/src/main/java/org/dinky/data/model/Resources.java | 2 +- .../org/dinky/service/resource/impl/ResourceServiceImpl.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/model/Resources.java b/dinky-admin/src/main/java/org/dinky/data/model/Resources.java index 5a00c3032e..ecbc133b4a 100644 --- a/dinky-admin/src/main/java/org/dinky/data/model/Resources.java +++ b/dinky-admin/src/main/java/org/dinky/data/model/Resources.java @@ -54,7 +54,7 @@ @AllArgsConstructor public class Resources extends Model { - @TableId(type = IdType.ASSIGN_ID) + @TableId(type = IdType.AUTO) @ApiModelProperty(value = "ID", dataType = "Integer", example = "1", notes = "Unique identifier for the resource") private Integer id; diff --git a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java index e10c1ec7c4..5f9b5db87f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java @@ -86,6 +86,8 @@ public boolean syncRemoteDirectoryStructure() { x.setType(resources.getType()); x.setUserId(resources.getUserId()); } + x.setId(Math.abs(x.getId())); + x.setPid(Math.abs(x.getPid())); }) .collect(Collectors.toList()); // not delete root directory From 1e9512c29e94097039e66145798a29ddac989f80 Mon Sep 17 00:00:00 2001 From: "yuhang2.zhang" Date: Wed, 13 Nov 2024 17:58:59 +0800 Subject: [PATCH 2/3] [Fix] [dinky-admin] Uniformly use '/' as the file separator. --- .../java/org/dinky/resource/impl/LocalResourceManager.java | 6 +++++- .../java/org/dinky/resource/impl/LocalResourceManager.java | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dinky-app/dinky-app-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java b/dinky-app/dinky-app-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java index c01bc2d1e6..9066b4f76b 100644 --- a/dinky-app/dinky-app-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java +++ b/dinky-app/dinky-app-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java @@ -30,11 +30,13 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Objects; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -98,6 +100,8 @@ public String getFileContent(String path) { @Override public List getFullDirectoryStructure(int rootId) { String basePath = getBasePath(); + String systemSeparator = Pattern.quote(FileSystems.getDefault().getSeparator()); + try (Stream paths = Files.walk(Paths.get(basePath))) { return paths.map(path -> { if (path.compareTo(Paths.get(basePath)) == 0) { @@ -115,7 +119,7 @@ public List getFullDirectoryStructure(int rootId) { return ResourcesVO.builder() .id(self.hashCode()) .pid(pid) - .fullName(self) + .fullName(self.replaceAll(systemSeparator, "/")) .fileName(file.getName()) .isDirectory(file.isDirectory()) .type(0) diff --git a/dinky-client/dinky-client-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java b/dinky-client/dinky-client-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java index e792f4f396..fcdc81d549 100644 --- a/dinky-client/dinky-client-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java +++ b/dinky-client/dinky-client-base/src/main/java/org/dinky/resource/impl/LocalResourceManager.java @@ -31,11 +31,13 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Objects; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -92,6 +94,7 @@ public String getFileContent(String path) { @Override public List getFullDirectoryStructure(int rootId) { String basePath = FileUtil.file(getBasePath()).getPath(); + String systemSeparator = Pattern.quote(FileSystems.getDefault().getSeparator()); try (Stream paths = Files.walk(Paths.get(basePath))) { return paths.map(path -> { @@ -112,7 +115,7 @@ public List getFullDirectoryStructure(int rootId) { return ResourcesVO.builder() .id(self.hashCode()) .pid(parentId) - .fullName(self) + .fullName(self.replaceAll(systemSeparator, "/")) .fileName(file.getName()) .isDirectory(file.isDirectory()) .type(0) From 40845e63054fa5b40688a0387bec30089b148c42 Mon Sep 17 00:00:00 2001 From: "yuhang2.zhang" Date: Wed, 27 Nov 2024 20:46:50 +0800 Subject: [PATCH 3/3] [Optimization][dinky-getaway] Delete the previously failed cluster when resubmitting the task. --- .../apache/flink/kubernetes/KubernetesClusterDescriptor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dinky-client/dinky-client-1.18/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java b/dinky-client/dinky-client-1.18/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java index 41b782176a..27ed7870ae 100644 --- a/dinky-client/dinky-client-1.18/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java +++ b/dinky-client/dinky-client-1.18/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java @@ -171,7 +171,8 @@ public ClusterClientProvider deployApplicationCluster( throws ClusterDeploymentException { if (client.getService(ExternalServiceDecorator.getExternalServiceName(clusterId)) .isPresent()) { - throw new ClusterDeploymentException("The Flink cluster " + clusterId + " already exists."); + client.stopAndCleanupCluster(clusterId); + LOG.warn("The Flink cluster {} already exists, automatically stopAndCleanupCluster.", clusterId); } checkNotNull(clusterSpecification);