You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by ya...@apache.org on 2022/09/23 01:24:21 UTC

[incubator-streampark] branch dev updated: [improve] jackson ignore improve (#1665)

This is an automated email from the ASF dual-hosted git repository.

yangzhou pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 63770b6dd [improve] jackson ignore improve (#1665)
63770b6dd is described below

commit 63770b6dd8e9d2ec330d06a580c420b06a4bc4de
Author: benjobs <be...@apache.org>
AuthorDate: Fri Sep 23 09:24:12 2022 +0800

    [improve] jackson ignore improve (#1665)
---
 .../console/core/entity/Application.java           |  9 ++---
 .../console/core/entity/ApplicationConfig.java     |  2 --
 .../console/core/entity/FlinkCluster.java          |  1 -
 .../streampark/console/core/entity/FlinkEnv.java   |  1 -
 .../streampark/console/core/entity/Project.java    | 17 ++++------
 .../console/core/metrics/flink/JvmProfiler.java    |  3 +-
 .../console/core/service/SettingService.java       |  5 +++
 .../core/service/impl/SettingServiceImpl.java      | 38 ++++++++++------------
 8 files changed, 32 insertions(+), 44 deletions(-)

diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
index 88c78c051..b8d281a08 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
@@ -398,12 +398,10 @@ public class Application implements Serializable {
         return ExecutionMode.of(executionMode);
     }
 
-    @JsonIgnore
     public boolean cpFailedTrigger() {
         return this.cpMaxFailureInterval != null && this.cpFailureRateInterval != null && this.cpFailureAction != null;
     }
 
-    @JsonIgnore
     public boolean eqFlinkJob(Application other) {
         if (this.isFlinkSqlJob() && other.isFlinkSqlJob()) {
             if (this.getFlinkSql().trim().equals(other.getFlinkSql().trim())) {
@@ -543,7 +541,6 @@ public class Application implements Serializable {
     /**
      * Parameter comparison, mainly to compare whether the parameters related to Flink runtime have changed
      */
-    @JsonIgnore
     public boolean eqJobParam(Application other) {
         // 1) Resolve Order has it changed
         // 2) flink Version has it changed
@@ -631,10 +628,12 @@ public class Application implements Serializable {
         }
     }
 
+    @JsonIgnore
     public FsOperator getFsOperator() {
         return FsOperator.of(getStorageType());
     }
 
+    @JsonIgnore
     public Workspace getWorkspace() {
         return Workspace.of(getStorageType());
     }
@@ -651,7 +650,6 @@ public class Application implements Serializable {
         return Collections.EMPTY_MAP;
     }
 
-    @JsonIgnore
     @SneakyThrows
     public void doSetHotParams() {
         Map<String, String> hotParams = new HashMap<>();
@@ -671,7 +669,6 @@ public class Application implements Serializable {
         }
     }
 
-    @JsonIgnore
     @SneakyThrows
     public void updateHotParams(Application appParam) {
         ExecutionMode executionModeEnum = appParam.getExecutionModeEnum();
@@ -694,7 +691,6 @@ public class Application implements Serializable {
         private List<Pom> pom = Collections.emptyList();
         private List<String> jar = Collections.emptyList();
 
-        @JsonIgnore
         @SneakyThrows
         public static Dependency toDependency(String dependency) {
             if (Utils.notEmpty(dependency)) {
@@ -730,7 +726,6 @@ public class Application implements Serializable {
             return new HashSet<>(pom).containsAll(other.pom);
         }
 
-        @JsonIgnore
         public DependencyInfo toJarPackDeps() {
             List<Artifact> mvnArts = this.pom.stream()
                 .map(pom -> new Artifact(pom.getGroupId(), pom.getArtifactId(), pom.getVersion()))
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ApplicationConfig.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ApplicationConfig.java
index 572dab714..4a50cae9f 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ApplicationConfig.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ApplicationConfig.java
@@ -25,7 +25,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
@@ -74,7 +73,6 @@ public class ApplicationConfig {
         application.setFormat(this.format);
     }
 
-    @JsonIgnore
     public Map<String, String> readConfig() {
         switch (this.getFormat()) {
             case 1:
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCluster.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCluster.java
index 28491cfe2..c336e4dac 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCluster.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkCluster.java
@@ -135,7 +135,6 @@ public class FlinkCluster implements Serializable {
         return null;
     }
 
-    @JsonIgnore
     public boolean verifyConnection() {
         if (address == null) {
             return false;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkEnv.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkEnv.java
index ca06504dc..d0df7b57a 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkEnv.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkEnv.java
@@ -88,7 +88,6 @@ public class FlinkEnv implements Serializable {
         }
     }
 
-    @JsonIgnore
     public Map<String, String> convertFlinkYamlAsMap() {
         String flinkYamlString = DeflaterUtils.unzipString(flinkConf);
         return PropertiesUtils.loadFlinkConfYaml(flinkYamlString);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index f5094791a..3265a10b3 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -17,6 +17,7 @@
 
 package org.apache.streampark.console.core.entity;
 
+import org.apache.streampark.common.conf.CommonConfig;
 import org.apache.streampark.common.conf.Workspace;
 import org.apache.streampark.common.util.CommandUtils;
 import org.apache.streampark.console.base.util.CommonUtils;
@@ -104,9 +105,6 @@ public class Project implements Serializable {
      */
     private transient String appSource;
 
-    @JsonIgnore
-    private transient SettingService settingService;
-
     /**
      * get project source
      */
@@ -145,7 +143,6 @@ public class Project implements Serializable {
         return new File(home, ".git");
     }
 
-    @JsonIgnore
     public void delete() throws IOException {
         FileUtils.deleteDirectory(getAppSource());
         FileUtils.deleteDirectory(getDistHome());
@@ -176,7 +173,6 @@ public class Project implements Serializable {
         return Collections.emptyList();
     }
 
-    @JsonIgnore
     public GitAuthorizedError gitCheck() {
         try {
             if (CommonUtils.notEmpty(userName, password)) {
@@ -233,14 +229,15 @@ public class Project implements Serializable {
 
         StringBuffer cmdBuffer = new StringBuffer(mvn).append(" clean package -DskipTests ");
 
-        String settings = settingService.getMavenSettings();
-        if (StringUtils.isNotEmpty(settings)) {
-            cmdBuffer.append(" --settings ").append(settings);
-        }
-
         if (StringUtils.isNotEmpty(this.buildArgs)) {
             cmdBuffer.append(this.buildArgs.trim());
         }
+
+        Setting setting = SettingService.SETTINGS.get(CommonConfig.MAVEN_SETTINGS_PATH());
+        if (setting != null) {
+            cmdBuffer.append(" --settings ").append(setting.getSettingValue());
+        }
+
         return cmdBuffer.toString();
     }
 
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/JvmProfiler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/JvmProfiler.java
index c8cb2d97c..304aa90f9 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/JvmProfiler.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/JvmProfiler.java
@@ -32,8 +32,7 @@ import java.util.Map;
 @Data
 public class JvmProfiler implements Serializable {
 
-    @JsonIgnore
-    private ObjectMapper mapper = new ObjectMapper();
+    private transient ObjectMapper mapper = new ObjectMapper();
 
     private String metric;
     private Long id;
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/SettingService.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/SettingService.java
index 5014c6c04..ac547d754 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/SettingService.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/SettingService.java
@@ -22,8 +22,13 @@ import org.apache.streampark.console.core.entity.Setting;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 public interface SettingService extends IService<Setting> {
 
+    Map<String, Setting> SETTINGS = new ConcurrentHashMap<>();
+
     String KEY_MAVEN_SETTINGS = "streampark.maven.settings";
     String KEY_MAVEN_REPOSITORY = "streampark.maven.central.repository";
     String KEY_MAVEN_AUTH_USER = "streampark.maven.auth.user";
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SettingServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SettingServiceImpl.java
index b753bd144..238fa1bb7 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SettingServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/SettingServiceImpl.java
@@ -34,9 +34,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
 
 @Slf4j
 @Service
@@ -49,14 +47,12 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting>
         return baseMapper.get(key);
     }
 
-    private final Map<String, Setting> settings = new ConcurrentHashMap<>();
-
     private final Setting emptySetting = new Setting();
 
     @Override
     public void onApplicationEvent(ContextRefreshedEvent event) {
         List<Setting> settingList = super.list();
-        settingList.forEach(x -> settings.put(x.getSettingKey(), x));
+        settingList.forEach(x -> SETTINGS.put(x.getSettingKey(), x));
     }
 
     @Override
@@ -77,7 +73,7 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting>
                 InternalConfigHolder.set(CommonConfig.MAVEN_AUTH_PASSWORD(), value);
             }
 
-            Optional<Setting> optional = Optional.ofNullable(settings.get(setting.getSettingKey()));
+            Optional<Setting> optional = Optional.ofNullable(SETTINGS.get(setting.getSettingKey()));
             if (optional.isPresent()) {
                 optional.get().setSettingValue(value);
             }
@@ -90,12 +86,12 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting>
     @Override
     public SenderEmail getSenderEmail() {
         try {
-            String host = settings.get(SettingService.KEY_ALERT_EMAIL_HOST).getSettingValue();
-            String port = settings.get(SettingService.KEY_ALERT_EMAIL_PORT).getSettingValue();
-            String from = settings.get(SettingService.KEY_ALERT_EMAIL_FROM).getSettingValue();
-            String userName = settings.get(SettingService.KEY_ALERT_EMAIL_USERNAME).getSettingValue();
-            String password = settings.get(SettingService.KEY_ALERT_EMAIL_PASSWORD).getSettingValue();
-            String ssl = settings.get(SettingService.KEY_ALERT_EMAIL_SSL).getSettingValue();
+            String host = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_HOST).getSettingValue();
+            String port = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_PORT).getSettingValue();
+            String from = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_FROM).getSettingValue();
+            String userName = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_USERNAME).getSettingValue();
+            String password = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_PASSWORD).getSettingValue();
+            String ssl = SETTINGS.get(SettingService.KEY_ALERT_EMAIL_SSL).getSettingValue();
 
             SenderEmail senderEmail = new SenderEmail();
             senderEmail.setSmtpHost(host);
@@ -113,46 +109,46 @@ public class SettingServiceImpl extends ServiceImpl<SettingMapper, Setting>
 
     @Override
     public String getDockerRegisterAddress() {
-        return settings.getOrDefault(SettingService.KEY_DOCKER_REGISTER_ADDRESS, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_DOCKER_REGISTER_ADDRESS, emptySetting).getSettingValue();
     }
 
     @Override
     public String getDockerRegisterUser() {
-        return settings.getOrDefault(SettingService.KEY_DOCKER_REGISTER_USER, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_DOCKER_REGISTER_USER, emptySetting).getSettingValue();
     }
 
     @Override
     public String getDockerRegisterPassword() {
-        return settings.getOrDefault(SettingService.KEY_DOCKER_REGISTER_PASSWORD, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_DOCKER_REGISTER_PASSWORD, emptySetting).getSettingValue();
     }
 
     @Override
     public String getDockerRegisterNamespace() {
-        return settings.getOrDefault(SettingService.KEY_DOCKER_REGISTER_NAMESPACE, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_DOCKER_REGISTER_NAMESPACE, emptySetting).getSettingValue();
     }
 
     @Override
     public String getStreamParkAddress() {
-        return settings.getOrDefault(SettingService.KEY_STREAMPARK_ADDRESS, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_STREAMPARK_ADDRESS, emptySetting).getSettingValue();
     }
 
     @Override
     public String getMavenSettings() {
-        return settings.getOrDefault(SettingService.KEY_MAVEN_SETTINGS, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_MAVEN_SETTINGS, emptySetting).getSettingValue();
     }
 
     @Override
     public String getMavenRepository() {
-        return settings.getOrDefault(SettingService.KEY_MAVEN_REPOSITORY, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_MAVEN_REPOSITORY, emptySetting).getSettingValue();
     }
 
     @Override
     public String getMavenAuthUser() {
-        return settings.getOrDefault(SettingService.KEY_MAVEN_AUTH_USER, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_MAVEN_AUTH_USER, emptySetting).getSettingValue();
     }
 
     @Override
     public String getMavenAuthPassword() {
-        return settings.getOrDefault(SettingService.KEY_MAVEN_AUTH_PASSWORD, emptySetting).getSettingValue();
+        return SETTINGS.getOrDefault(SettingService.KEY_MAVEN_AUTH_PASSWORD, emptySetting).getSettingValue();
     }
 }