From 7cd7116762055e7a11133f30f22c5e682c1e9558 Mon Sep 17 00:00:00 2001
From: fuweng11 <76141879+fuweng11@users.noreply.github.com>
Date: Mon, 24 Apr 2023 18:29:02 +0800
Subject: [PATCH] [INLONG-7890][Manager] Add checks for unmodifiable
data_node_name and cluster_name (#7891)
---
.../manager/dao/entity/DataNodeEntity.java | 1 +
.../dao/entity/InlongClusterEntity.java | 1 +
.../mappers/DataNodeEntityMapper.xml | 43 +++++++-----
.../mappers/InlongClusterEntityMapper.xml | 58 ++++++++-------
.../manager/pojo/cluster/ClusterInfo.java | 3 +
.../pojo/cluster/ClusterPageRequest.java | 3 +
.../manager/pojo/cluster/ClusterRequest.java | 8 ++-
.../manager/pojo/node/DataNodeInfo.java | 3 +
.../pojo/node/DataNodePageRequest.java | 4 +-
.../manager/pojo/node/DataNodeRequest.java | 6 +-
.../cluster/InlongClusterServiceImpl.java | 17 +++++
.../service/node/DataNodeServiceImpl.java | 20 ++++++
.../cluster/InlongClusterServiceTest.java | 2 +-
.../core/impl/DataNodeServiceTest.java | 2 +-
.../resources/h2/apache_inlong_manager.sql | 70 ++++++++++---------
.../manager-web/sql/apache_inlong_manager.sql | 70 ++++++++++---------
.../manager-web/sql/changes-1.7.0.sql | 6 ++
.../web/controller/StreamSinkController.java | 2 +-
.../controller/DataNodeControllerTest.java | 2 +-
19 files changed, 199 insertions(+), 122 deletions(-)
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/DataNodeEntity.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/DataNodeEntity.java
index 99dc757adc0..d503beb438b 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/DataNodeEntity.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/DataNodeEntity.java
@@ -31,6 +31,7 @@ public class DataNodeEntity implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
+ private String displayName;
private String type;
private String url;
private String username;
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/InlongClusterEntity.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/InlongClusterEntity.java
index bb39a21aba2..98d150d0bbb 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/InlongClusterEntity.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/entity/InlongClusterEntity.java
@@ -32,6 +32,7 @@ public class InlongClusterEntity implements Serializable {
private Integer id;
private String name;
+ private String displayName;
private String type;
private String url;
private String clusterTags;
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
index 0015debbfeb..ec88eb7c274 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
@@ -23,6 +23,7 @@
+
@@ -39,20 +40,21 @@
- id, name, type, url, username, token, ext_params, description, in_charges, status, is_deleted,
+ id, name, display_name, type, url, username, token, ext_params, description, in_charges, status, is_deleted,
creator, modifier, create_time, modify_time, version
- insert into data_node (id, name, type,
+ insert into data_node (id, name, display_name, type,
url, username, token,
ext_params, description, in_charges,
status, creator, modifier)
- values (#{id, jdbcType=INTEGER}, #{name, jdbcType=VARCHAR}, #{type, jdbcType=VARCHAR},
- #{url, jdbcType=VARCHAR}, #{username, jdbcType=VARCHAR}, #{token, jdbcType=VARCHAR},
- #{extParams,jdbcType=LONGVARCHAR}, #{description, jdbcType=VARCHAR}, #{inCharges, jdbcType=VARCHAR},
- #{status, jdbcType=INTEGER}, #{creator, jdbcType=VARCHAR}, #{modifier, jdbcType=VARCHAR})
+ values (#{id, jdbcType=INTEGER}, #{name, jdbcType=VARCHAR}, #{displayName,jdbcType=VARCHAR},
+ #{type, jdbcType=VARCHAR}, #{url, jdbcType=VARCHAR}, #{username, jdbcType=VARCHAR},
+ #{token, jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR}, #{description, jdbcType=VARCHAR},
+ #{inCharges, jdbcType=VARCHAR}, #{status, jdbcType=INTEGER}, #{creator, jdbcType=VARCHAR},
+ #{modifier, jdbcType=VARCHAR})
update data_node
- set name = #{name, jdbcType=VARCHAR},
- type = #{type, jdbcType=VARCHAR},
- url = #{url, jdbcType=VARCHAR},
- username = #{username, jdbcType=VARCHAR},
- token = #{token, jdbcType=VARCHAR},
- ext_params = #{extParams, jdbcType=LONGVARCHAR},
- description = #{description,jdbcType=VARCHAR},
- in_charges = #{inCharges, jdbcType=VARCHAR},
- status = #{status, jdbcType=INTEGER},
- is_deleted = #{isDeleted, jdbcType=INTEGER},
- modifier = #{modifier, jdbcType=VARCHAR},
- version = #{version, jdbcType=INTEGER} + 1
+ set name = #{name, jdbcType=VARCHAR},
+ display_name = #{displayName, jdbcType=VARCHAR},
+ type = #{type, jdbcType=VARCHAR},
+ url = #{url, jdbcType=VARCHAR},
+ username = #{username, jdbcType=VARCHAR},
+ token = #{token, jdbcType=VARCHAR},
+ ext_params = #{extParams, jdbcType=LONGVARCHAR},
+ description = #{description,jdbcType=VARCHAR},
+ in_charges = #{inCharges, jdbcType=VARCHAR},
+ status = #{status, jdbcType=INTEGER},
+ is_deleted = #{isDeleted, jdbcType=INTEGER},
+ modifier = #{modifier, jdbcType=VARCHAR},
+ version = #{version, jdbcType=INTEGER} + 1
where id = #{id, jdbcType=INTEGER}
and version = #{version, jdbcType=INTEGER}
@@ -136,6 +140,9 @@
name = #{name, jdbcType=VARCHAR},
+
+ display_name = #{displayName, jdbcType=VARCHAR},
+
type = #{type, jdbcType=VARCHAR},
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
index 22ced8ba328..e95cf6de36f 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
@@ -23,6 +23,7 @@
+
@@ -41,35 +42,35 @@
- id, name, type, url, cluster_tags, ext_tag, token, ext_params, description, heartbeat,
+ id, name, display_name, type, url, cluster_tags, ext_tag, token, ext_params, description, heartbeat,
in_charges, status, is_deleted, creator, modifier, create_time, modify_time, version
- insert into inlong_cluster (id, name, type,
+ insert into inlong_cluster (id, name, display_name, type,
url, cluster_tags, ext_tag,
token, ext_params, description,
heartbeat, in_charges,
status, creator, modifier)
- values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
- #{url,jdbcType=VARCHAR}, #{clusterTags,jdbcType=VARCHAR}, #{extTag,jdbcType=VARCHAR},
- #{token,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR}, #{description, jdbcType=VARCHAR},
- #{heartbeat,jdbcType=LONGVARCHAR}, #{inCharges,jdbcType=VARCHAR},
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{displayName,jdbcType=VARCHAR},
+ #{type,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{clusterTags,jdbcType=VARCHAR},
+ #{extTag,jdbcType=VARCHAR}, #{token,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR},
+ #{description, jdbcType=VARCHAR}, #{heartbeat,jdbcType=LONGVARCHAR}, #{inCharges,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
- insert into inlong_cluster (id, name, type,
+ insert into inlong_cluster (id, name, display_name, type,
url, cluster_tags, ext_tag,
token, ext_params, heartbeat,
in_charges, status,
creator, modifier)
- values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
- #{url,jdbcType=VARCHAR}, #{clusterTags,jdbcType=VARCHAR}, #{extTag,jdbcType=VARCHAR},
- #{token,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR}, #{heartbeat,jdbcType=LONGVARCHAR},
- #{inCharges,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{displayName,jdbcType=VARCHAR},
+ #{type,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{clusterTags,jdbcType=VARCHAR},
+ #{extTag,jdbcType=VARCHAR},#{token,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR},
+ #{heartbeat,jdbcType=LONGVARCHAR}, #{inCharges,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
#{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
ON DUPLICATE KEY UPDATE cluster_tags = VALUES(cluster_tags),
ext_tag = VALUES(ext_tag),
@@ -155,6 +156,7 @@
and (name like CONCAT('%', #{keyword}, '%')
+ or display_name like CONCAT('%', #{keyword}, '%')
or cluster_tags like CONCAT('%', #{keyword}, '%')
or ext_tag like CONCAT('%', #{keyword}, '%')
)
@@ -182,7 +184,7 @@
order by modify_time desc
-