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

zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 8505f1878d Expose swagger.properties to release (#14590)
8505f1878d is described below

commit 8505f1878d4b3cfc12e9ede8ea394a31c9a0d6fb
Author: Wenjun Ruan <[email protected]>
AuthorDate: Wed Jul 19 22:24:42 2023 +0800

    Expose swagger.properties to release (#14590)
---
 .../main/assembly/dolphinscheduler-api-server.xml  |  1 +
 ...onfiguration.java => SwaggerConfiguration.java} | 34 ++++++++++----
 .../src/main/resources/swagger.properties          |  3 ++
 .../dolphinscheduler/dao/entity/DsVersion.java     | 35 ++++++++++++++
 .../dao/mapper/DsVersionMapper.java                | 25 ++++++++++
 .../dao/repository/DsVersionDao.java               | 28 +++++++++++
 .../dao/repository/impl/DsVersionDaoImpl.java      | 54 ++++++++++++++++++++++
 .../src/main/resources/sql/dolphinscheduler_h2.sql |  2 +-
 .../main/resources/sql/dolphinscheduler_mysql.sql  |  2 +-
 .../resources/sql/dolphinscheduler_postgresql.sql  |  2 +-
 .../src/main/resources/sql/soft_version            |  2 +-
 .../src/main/resources/application.yaml            | 13 ------
 12 files changed, 176 insertions(+), 25 deletions(-)

diff --git 
a/dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml 
b/dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml
index ed7d421009..77b2f54c64 100644
--- a/dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml
+++ b/dolphinscheduler-api/src/main/assembly/dolphinscheduler-api-server.xml
@@ -30,6 +30,7 @@
             <includes>
                 <include>*.yaml</include>
                 <include>*.xml</include>
+                <include>swagger.properties</include>
             </includes>
             <outputDirectory>conf</outputDirectory>
         </fileSet>
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPIConfiguration.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/SwaggerConfiguration.java
similarity index 62%
rename from 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPIConfiguration.java
rename to 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/SwaggerConfiguration.java
index 349445616b..f24d923d08 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/OpenAPIConfiguration.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/SwaggerConfiguration.java
@@ -16,7 +16,11 @@
  */
 package org.apache.dolphinscheduler.api.configuration;
 
+import org.apache.dolphinscheduler.dao.entity.DsVersion;
+import org.apache.dolphinscheduler.dao.repository.DsVersionDao;
+
 import org.springdoc.core.GroupedOpenApi;
+import org.springframework.beans.factory.annotation.Autowired;
 import 
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -27,20 +31,26 @@ import io.swagger.v3.oas.models.OpenAPI;
 import io.swagger.v3.oas.models.info.Info;
 
 /**
- * swager2 config class
+ * Swagger configuration, only enabled when the configuration item 
api.swagger.enable is true.
+ * The swagger ui is under <a 
href="http://${host}:${port}/dolphinscheduler/swagger-ui.html";>http://${host}:${port}/dolphinscheduler/swagger-ui.html</a>
  */
 @Configuration
 @ConditionalOnWebApplication
 @PropertySource("classpath:swagger.properties")
-public class OpenAPIConfiguration implements WebMvcConfigurer {
+public class SwaggerConfiguration implements WebMvcConfigurer {
+
+    @Autowired
+    private DsVersionDao dsVersionDao;
+
+    private volatile String dsVersion;
 
     @Bean
-    public OpenAPI apiV1Info1() {
-        return new OpenAPI()
-                .info(new Info()
-                        .title("Dolphin Scheduler Api Docs")
-                        .description("Dolphin Scheduler Api Docs")
-                        .version("V1"));
+    public OpenAPI openAPI() {
+        Info info = new Info()
+                .title("Apache DolphinScheduler Api Docs")
+                .description("Apache DolphinScheduler Api Docs")
+                .version(getDsVersion());
+        return new OpenAPI().info(info);
     }
 
     @Bean
@@ -58,4 +68,12 @@ public class OpenAPIConfiguration implements 
WebMvcConfigurer {
                 .pathsToMatch("/v2/**")
                 .build();
     }
+
+    private String getDsVersion() {
+        if (dsVersion != null) {
+            return dsVersion;
+        }
+        dsVersion = 
dsVersionDao.selectVersion().map(DsVersion::getVersion).orElse("unknown");
+        return dsVersion;
+    }
 }
diff --git a/dolphinscheduler-api/src/main/resources/swagger.properties 
b/dolphinscheduler-api/src/main/resources/swagger.properties
index e4f51880d4..6900947ed3 100644
--- a/dolphinscheduler-api/src/main/resources/swagger.properties
+++ b/dolphinscheduler-api/src/main/resources/swagger.properties
@@ -16,3 +16,6 @@
 #
 
 springfox.documentation.swagger.v2.path=/api-docs
+
+# If set to false, will disable swagger-ui
+springdoc.api-docs.enabled=true
diff --git 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DsVersion.java
 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DsVersion.java
new file mode 100644
index 0000000000..e1c6af9711
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DsVersion.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.entity;
+
+import lombok.Data;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@Data
+@TableName("t_ds_version")
+public class DsVersion {
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String version;
+
+}
diff --git 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DsVersionMapper.java
 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DsVersionMapper.java
new file mode 100644
index 0000000000..bfe1043385
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DsVersionMapper.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.mapper;
+
+import org.apache.dolphinscheduler.dao.entity.DsVersion;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface DsVersionMapper extends BaseMapper<DsVersion> {
+}
diff --git 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/DsVersionDao.java
 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/DsVersionDao.java
new file mode 100644
index 0000000000..d8752d3b68
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/DsVersionDao.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.repository;
+
+import org.apache.dolphinscheduler.dao.entity.DsVersion;
+
+import java.util.Optional;
+
+public interface DsVersionDao extends IDao<DsVersion> {
+
+    Optional<DsVersion> selectVersion();
+
+}
diff --git 
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/DsVersionDaoImpl.java
 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/DsVersionDaoImpl.java
new file mode 100644
index 0000000000..7f83810e4b
--- /dev/null
+++ 
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/DsVersionDaoImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.repository.impl;
+
+import org.apache.dolphinscheduler.dao.entity.DsVersion;
+import org.apache.dolphinscheduler.dao.mapper.DsVersionMapper;
+import org.apache.dolphinscheduler.dao.repository.BaseDao;
+import org.apache.dolphinscheduler.dao.repository.DsVersionDao;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import java.util.List;
+import java.util.Optional;
+
+import lombok.NonNull;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Repository;
+
+@Slf4j
+@Repository
+public class DsVersionDaoImpl extends BaseDao<DsVersion, DsVersionMapper> 
implements DsVersionDao {
+
+    public DsVersionDaoImpl(@NonNull DsVersionMapper dsVersionMapper) {
+        super(dsVersionMapper);
+    }
+
+    @Override
+    public Optional<DsVersion> selectVersion() {
+        List<DsVersion> dsVersions = mybatisMapper.selectList(null);
+        if (CollectionUtils.isEmpty(dsVersions)) {
+            log.info("There is no version information in the database");
+        }
+        if (dsVersions.size() > 1) {
+            log.info("There are multiple version information in the database");
+        }
+        return dsVersions.stream().findFirst();
+    }
+}
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
index f886493ca0..7f48e75803 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
@@ -1051,7 +1051,7 @@ CREATE TABLE t_ds_version
 -- Records of t_ds_version
 -- ----------------------------
 INSERT INTO t_ds_version
-VALUES ('1', '1.4.0');
+VALUES ('1', 'dev');
 
 
 -- ----------------------------
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
index 11b31d23d0..fba0b077e1 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
+++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
@@ -1042,7 +1042,7 @@ CREATE TABLE `t_ds_version` (
 -- ----------------------------
 -- Records of t_ds_version
 -- ----------------------------
-INSERT IGNORE INTO `t_ds_version` VALUES ('1', '2.0.2');
+INSERT IGNORE INTO `t_ds_version` VALUES ('1', 'dev');
 
 
 -- ----------------------------
diff --git 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
index 7ddb20c732..dcbad8188e 100644
--- 
a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
+++ 
b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
@@ -1040,7 +1040,7 @@ INSERT INTO t_ds_queue(queue_name, queue, create_time, 
update_time)
 VALUES ('default', 'default', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
 
 -- Records of t_ds_queue,default queue name : default
-INSERT INTO t_ds_version(version) VALUES ('1.4.0');
+INSERT INTO t_ds_version(version) VALUES ('dev');
 
 --
 -- Table structure for table t_ds_plugin_define
diff --git a/dolphinscheduler-dao/src/main/resources/sql/soft_version 
b/dolphinscheduler-dao/src/main/resources/sql/soft_version
index 4a36342fca..38f8e886e1 100644
--- a/dolphinscheduler-dao/src/main/resources/sql/soft_version
+++ b/dolphinscheduler-dao/src/main/resources/sql/soft_version
@@ -1 +1 @@
-3.0.0
+dev
diff --git 
a/dolphinscheduler-standalone-server/src/main/resources/application.yaml 
b/dolphinscheduler-standalone-server/src/main/resources/application.yaml
index 3247253511..75ff196f0d 100644
--- a/dolphinscheduler-standalone-server/src/main/resources/application.yaml
+++ b/dolphinscheduler-standalone-server/src/main/resources/application.yaml
@@ -112,19 +112,6 @@ security:
         trust-store: "/ldapkeystore.jks"
         trust-store-password: ""
 
-# Traffic control, if you turn on this config, the maximum number of request/s 
will be limited.
-# global max request number per second
-# default tenant-level max request number
-traffic:
-  control:
-    global-switch: false
-    max-global-qps-rate: 300
-    tenant-switch: false
-    default-tenant-qps-rate: 10
-    #customize-tenant-qps-rate:
-      # eg.
-      #tenant1: 11
-      #tenant2: 20
 
 master:
   listen-port: 5678

Reply via email to