This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new ab9e725 [INLONG-2161][Feature][Manager] add the sort_cluster_config
table for getClusterConfig interface (#2287)
ab9e725 is described below
commit ab9e725f5714b8091824764978be7c20e00c1b83
Author: imvan <[email protected]>
AuthorDate: Sun Jan 23 19:32:52 2022 +0800
[INLONG-2161][Feature][Manager] add the sort_cluster_config table for
getClusterConfig interface (#2287)
---
.../dao/entity/SortClusterConfgiEntity.java} | 32 +++----
.../dao/mapper/SortClusterConfgiEntityMapper.java} | 44 ++++-----
.../src/main/resources/generatorConfig.xml | 9 +-
.../mappers/SortClusterConfgiEntityMapper.xml | 106 +++++++++++++++++++++
...viceImpl.java => SortClusterConfigService.java} | 30 +++---
...Impl.java => SortClusterConfigServiceImpl.java} | 20 ++--
.../manager/service/core/impl/SortServiceImpl.java | 29 +++++-
.../manager-web/sql/apache_inlong_manager.sql | 13 +++
.../web/controller/openapi/SortControllerTest.java | 11 +++
9 files changed, 222 insertions(+), 72 deletions(-)
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortClusterConfgiEntity.java
similarity index 51%
copy from
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
copy to
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortClusterConfgiEntity.java
index f287939..d9530ca 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
+++
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/SortClusterConfgiEntity.java
@@ -15,27 +15,17 @@
* limitations under the License.
*/
-package org.apache.inlong.manager.service.core.impl;
+package org.apache.inlong.manager.dao.entity;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
-import org.apache.inlong.manager.service.core.SortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
+import lombok.Data;
-/**
- * Sort service implementation.
- */
-@Slf4j
-@Service
-public class SortServiceImpl implements SortService {
-
- private static final Logger LOGGER =
LoggerFactory.getLogger(SortServiceImpl.class);
+import java.io.Serializable;
- @Override
- public SortClusterConfigResponse getClusterConfig(String clusterName,
String md5) {
- LOGGER.info("start getClusterConfig");
- return SortClusterConfigResponse.builder().build();
- }
-}
+@Data
+public class SortClusterConfgiEntity implements Serializable {
+ private Integer id;
+ private String clusterName;
+ private String taskName;
+ private String sinkType;
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/SortClusterConfgiEntityMapper.java
similarity index 51%
copy from
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
copy to
inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/SortClusterConfgiEntityMapper.java
index f287939..567514e 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
+++
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/SortClusterConfgiEntityMapper.java
@@ -15,27 +15,27 @@
* limitations under the License.
*/
-package org.apache.inlong.manager.service.core.impl;
+package org.apache.inlong.manager.dao.mapper;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
-import org.apache.inlong.manager.service.core.SortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
+import org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity;
+import org.springframework.stereotype.Repository;
-/**
- * Sort service implementation.
- */
-@Slf4j
-@Service
-public class SortServiceImpl implements SortService {
-
- private static final Logger LOGGER =
LoggerFactory.getLogger(SortServiceImpl.class);
-
- @Override
- public SortClusterConfigResponse getClusterConfig(String clusterName,
String md5) {
- LOGGER.info("start getClusterConfig");
- return SortClusterConfigResponse.builder().build();
- }
-}
+import java.util.List;
+
+@Repository
+public interface SortClusterConfgiEntityMapper {
+ int deleteByPrimaryKey(Integer id);
+
+ int insert(SortClusterConfgiEntity record);
+
+ int insertSelective(SortClusterConfgiEntity record);
+
+ SortClusterConfgiEntity selectByPrimaryKey(Integer id);
+
+ int updateByPrimaryKeySelective(SortClusterConfgiEntity record);
+
+ int updateByPrimaryKey(SortClusterConfgiEntity record);
+
+ List<SortClusterConfgiEntity> selectTasksByClusterName(String clusterName);
+
+}
\ No newline at end of file
diff --git a/inlong-manager/manager-dao/src/main/resources/generatorConfig.xml
b/inlong-manager/manager-dao/src/main/resources/generatorConfig.xml
index b46e258..4f0d9c9 100644
--- a/inlong-manager/manager-dao/src/main/resources/generatorConfig.xml
+++ b/inlong-manager/manager-dao/src/main/resources/generatorConfig.xml
@@ -210,7 +210,14 @@
enableUpdateByPrimaryKey="true"
enableDeleteByPrimaryKey="true" enableInsert="true"
enableCountByExample="false" enableDeleteByExample="false"
- enableSelectByExample="false"
enableUpdateByExample="false"/>-->
+ enableSelectByExample="false" enableUpdateByExample="false"/>
+
+ <table tableName="sort_cluster_config"
domainObjectName="SortClusterConfgiEntity"
+ enableSelectByPrimaryKey="true"
+ enableUpdateByPrimaryKey="true"
+ enableDeleteByPrimaryKey="true" enableInsert="true"
+ enableCountByExample="false" enableDeleteByExample="false"
+ enableSelectByExample="false" enableUpdateByExample="false"/>-->
</context>
</generatorConfiguration>
diff --git
a/inlong-manager/manager-dao/src/main/resources/mappers/SortClusterConfgiEntityMapper.xml
b/inlong-manager/manager-dao/src/main/resources/mappers/SortClusterConfgiEntityMapper.xml
new file mode 100644
index 0000000..6a2020e
--- /dev/null
+++
b/inlong-manager/manager-dao/src/main/resources/mappers/SortClusterConfgiEntityMapper.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper
namespace="org.apache.inlong.manager.dao.mapper.SortClusterConfgiEntityMapper">
+ <resultMap id="BaseResultMap"
type="org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity">
+ <id column="id" jdbcType="INTEGER" property="id" />
+ <result column="cluster_name" jdbcType="VARCHAR" property="clusterName" />
+ <result column="task_name" jdbcType="VARCHAR" property="taskName" />
+ <result column="sink_type" jdbcType="VARCHAR" property="sinkType" />
+ </resultMap>
+ <sql id="Base_Column_List">
+ id, cluster_name, task_name, sink_type
+ </sql>
+ <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from sort_cluster_config
+ where id = #{id,jdbcType=INTEGER}
+ </select>
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+ delete from sort_cluster_config
+ where id = #{id,jdbcType=INTEGER}
+ </delete>
+ <insert id="insert"
parameterType="org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity">
+ insert into sort_cluster_config (id, cluster_name, task_name,
+ sink_type)
+ values (#{id,jdbcType=INTEGER}, #{clusterName,jdbcType=VARCHAR},
#{taskName,jdbcType=VARCHAR},
+ #{sinkType,jdbcType=VARCHAR})
+ </insert>
+ <insert id="insertSelective"
parameterType="org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity">
+ insert into sort_cluster_config
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ id,
+ </if>
+ <if test="clusterName != null">
+ cluster_name,
+ </if>
+ <if test="taskName != null">
+ task_name,
+ </if>
+ <if test="sinkType != null">
+ sink_type,
+ </if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ <if test="id != null">
+ #{id,jdbcType=INTEGER},
+ </if>
+ <if test="clusterName != null">
+ #{clusterName,jdbcType=VARCHAR},
+ </if>
+ <if test="taskName != null">
+ #{taskName,jdbcType=VARCHAR},
+ </if>
+ <if test="sinkType != null">
+ #{sinkType,jdbcType=VARCHAR},
+ </if>
+ </trim>
+ </insert>
+ <update id="updateByPrimaryKeySelective"
parameterType="org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity">
+ update sort_cluster_config
+ <set>
+ <if test="clusterName != null">
+ cluster_name = #{clusterName,jdbcType=VARCHAR},
+ </if>
+ <if test="taskName != null">
+ task_name = #{taskName,jdbcType=VARCHAR},
+ </if>
+ <if test="sinkType != null">
+ sink_type = #{sinkType,jdbcType=VARCHAR},
+ </if>
+ </set>
+ where id = #{id,jdbcType=INTEGER}
+ </update>
+ <update id="updateByPrimaryKey"
parameterType="org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity">
+ update sort_cluster_config
+ set cluster_name = #{clusterName,jdbcType=VARCHAR},
+ task_name = #{taskName,jdbcType=VARCHAR},
+ sink_type = #{sinkType,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+ </update>
+ <select id="selectTasksByClusterName" parameterType="java.lang.String"
resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from sort_cluster_config
+ where cluster_name = #{clusterName, jdbcType=VARCHAR}
+ </select>
+</mapper>
\ No newline at end of file
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortClusterConfigService.java
similarity index 52%
copy from
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
copy to
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortClusterConfigService.java
index f287939..75d75ac 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
+++
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/SortClusterConfigService.java
@@ -15,27 +15,21 @@
* limitations under the License.
*/
-package org.apache.inlong.manager.service.core.impl;
+package org.apache.inlong.manager.service.core;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
-import org.apache.inlong.manager.service.core.SortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
+import org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity;
+
+import java.util.List;
/**
- * Sort service implementation.
+ * Sort cluster config service.
*/
-@Slf4j
-@Service
-public class SortServiceImpl implements SortService {
-
- private static final Logger LOGGER =
LoggerFactory.getLogger(SortServiceImpl.class);
+public interface SortClusterConfigService {
- @Override
- public SortClusterConfigResponse getClusterConfig(String clusterName,
String md5) {
- LOGGER.info("start getClusterConfig");
- return SortClusterConfigResponse.builder().build();
- }
+ /**
+ * Select list of task by cluster name.
+ * @param clusterName Name of sort cluster.
+ * @return List of tasks, including task name and sink type.
+ */
+ List<SortClusterConfgiEntity> selectTasksByClusterName(String clusterName);
}
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterConfigServiceImpl.java
similarity index 61%
copy from
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
copy to
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterConfigServiceImpl.java
index f287939..1c1cb89 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
+++
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortClusterConfigServiceImpl.java
@@ -18,24 +18,26 @@
package org.apache.inlong.manager.service.core.impl;
import lombok.extern.slf4j.Slf4j;
-import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
-import org.apache.inlong.manager.service.core.SortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity;
+import org.apache.inlong.manager.dao.mapper.SortClusterConfgiEntityMapper;
+import org.apache.inlong.manager.service.core.SortClusterConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
* Sort service implementation.
*/
@Slf4j
@Service
-public class SortServiceImpl implements SortService {
+public class SortClusterConfigServiceImpl implements SortClusterConfigService {
- private static final Logger LOGGER =
LoggerFactory.getLogger(SortServiceImpl.class);
+ @Autowired
+ private SortClusterConfgiEntityMapper sortClusterConfgiEntityMapper;
@Override
- public SortClusterConfigResponse getClusterConfig(String clusterName,
String md5) {
- LOGGER.info("start getClusterConfig");
- return SortClusterConfigResponse.builder().build();
+ public List<SortClusterConfgiEntity> selectTasksByClusterName(String
clusterName) {
+ return
sortClusterConfgiEntityMapper.selectTasksByClusterName(clusterName);
}
}
diff --git
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
index f287939..1fc9d4a 100644
---
a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
+++
b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortServiceImpl.java
@@ -18,12 +18,18 @@
package org.apache.inlong.manager.service.core.impl;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.apache.inlong.manager.common.pojo.sort.SortClusterConfigResponse;
+import org.apache.inlong.manager.dao.entity.SortClusterConfgiEntity;
+import org.apache.inlong.manager.service.core.SortClusterConfigService;
import org.apache.inlong.manager.service.core.SortService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
+
/**
* Sort service implementation.
*/
@@ -33,9 +39,30 @@ public class SortServiceImpl implements SortService {
private static final Logger LOGGER =
LoggerFactory.getLogger(SortServiceImpl.class);
+ @Autowired
+ private SortClusterConfigService sortClusterConfigService;
+
@Override
public SortClusterConfigResponse getClusterConfig(String clusterName,
String md5) {
LOGGER.info("start getClusterConfig");
- return SortClusterConfigResponse.builder().build();
+
+ if (StringUtils.isBlank(clusterName)) {
+ String errMsg = "Blank cluster name";
+ LOGGER.info(errMsg);
+ return SortClusterConfigResponse.builder()
+ .msg(errMsg).build();
+ }
+
+ List<SortClusterConfgiEntity> tasks =
sortClusterConfigService.selectTasksByClusterName(clusterName);
+ if (tasks == null || tasks.isEmpty()) {
+ String errMsg = "There is not any task for cluster" + clusterName;
+ LOGGER.info(errMsg);
+ return SortClusterConfigResponse.builder()
+ .msg(errMsg).build();
+ }
+
+ return SortClusterConfigResponse.builder()
+ .msg("success").build();
}
+
}
diff --git a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
index 1713247..49c503b 100644
--- a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
+++ b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
@@ -1132,5 +1132,18 @@ CREATE TABLE `db_collector_detail_task`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='db collector detail task table';
+-- ----------------------------
+-- Table structure for sort_cluster_config
+-- ----------------------------
+DROP TABLE IF EXISTS `sort_cluster_config`;
+CREATE TABLE `sort_cluster_config`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Incremental
primary key',
+ `cluster_name` varchar(128) NOT NULL COMMENT 'Cluster name',
+ `task_name` varchar(128) NOT NULL COMMENT 'Task name',
+ `sink_type` varchar(128) NOT NULL COMMENT 'Type of sink',
+ PRIMARY KEY (`id`)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4 COMMENT ='Sort cluster config table';
SET FOREIGN_KEY_CHECKS = 1;
diff --git
a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
index 8c1277f..9eac27a 100644
---
a/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
+++
b/inlong-manager/manager-web/src/test/java/org/apache/inlong/manager/web/controller/openapi/SortControllerTest.java
@@ -60,4 +60,15 @@ public class SortControllerTest {
.andExpect(status().isOk())
.andDo(print());
}
+
+ @Test
+ public void testEmptyClusterNameWhenGet() throws Exception {
+ RequestBuilder request =
+ get("/openapi/sort/getClusterConfig")
+ .param("clusterName", " ")
+ .param("md5", "testMd5");
+ mockMvc.perform(request)
+ .andExpect(status().isOk())
+ .andDo(print());
+ }
}
\ No newline at end of file