Skip to content

Commit

Permalink
BIGTOP-4306: Add unique name to cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinw66 committed Dec 18, 2024
1 parent 0ed48bb commit 3781c75
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
@Data
public class ClusterInfo {

private String name;

private String userGroup;

private String rootDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class ClusterPO extends BasePO implements Serializable {
@Column(name = "name")
private String name;

@Column(name = "display_name")
private String displayName;

@Column(name = "desc")
private String desc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<mapper namespace="org.apache.bigtop.manager.dao.repository.ClusterDao">

<sql id="baseColumns">
id, name, `desc`, type, user_group, root_dir, status
id, name, display_name, `desc`, type, user_group, root_dir, status
</sql>
<sql id="baseColumnsV2">
${alias}.id, ${alias}.name, ${alias}.`desc`, ${alias}.type, ${alias}.user_group, ${alias}.root_dir, ${alias}.status
${alias}.id, ${alias}.name, ${alias}.display_name, ${alias}.`desc`, ${alias}.type, ${alias}.user_group, ${alias}.root_dir, ${alias}.status
</sql>

<select id="findDetailsById" resultType="org.apache.bigtop.manager.dao.po.ClusterPO">
Expand Down
15 changes: 5 additions & 10 deletions bigtop-manager-dao/src/main/resources/mapper/mysql/HostMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>, c.name as cluster_name, count(comp.id) as component_num
</include>, c.display_name as cluster_name, count(comp.id) as component_num
from host h
left join cluster c on h.cluster_id = c.id
left join component comp on h.id = comp.host_id
Expand All @@ -65,7 +65,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>, c.name as cluster_name, count(comp.id) as component_num
</include>, c.display_name as cluster_name, count(comp.id) as component_num
from host h
left join cluster c on h.cluster_id = c.id
left join component comp on h.id = comp.host_id
Expand Down Expand Up @@ -93,18 +93,13 @@
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>
,clus.name as cluster_name
,clus.display_name as cluster_name
from
host h
inner join
(select * from cluster
<where>
<if test="clusterId != 0">
id = #{clusterId}
</if>
</where>
) clus
left join cluster clus
on h.cluster_id = clus.id
where h.cluster_id = #{clusterId}
</select>

<select id="findAllByHostnames"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<mapper namespace="org.apache.bigtop.manager.dao.repository.ClusterDao">

<sql id="baseColumns">
id, name, "desc", type, user_group, root_dir, status
id, name, display_name, "desc", type, user_group, root_dir, status
</sql>
<sql id="baseColumnsV2">
${alias}.id, ${alias}.name, ${alias}."desc", ${alias}.type, ${alias}.user_group, ${alias}.root_dir, ${alias}.status
${alias}.id, ${alias}.name, ${alias}.display_name, ${alias}."desc", ${alias}.type, ${alias}.user_group, ${alias}.root_dir, ${alias}.status
</sql>

<select id="findDetailsById" resultType="org.apache.bigtop.manager.dao.po.ClusterPO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>, c.name as cluster_name, count(comp.id) as component_num
</include>, c.display_name as cluster_name, count(comp.id) as component_num
from host h
left join cluster c on h.cluster_id = c.id
left join component comp on h.id = comp.host_id
Expand All @@ -65,7 +65,7 @@
select
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>, c.name as cluster_name, count(comp.id) as component_num
</include>, c.display_name as cluster_name, count(comp.id) as component_num
from host h
left join cluster c on h.cluster_id = c.id
left join component comp on h.id = comp.host_id
Expand Down Expand Up @@ -93,11 +93,12 @@
<include refid="baseColumnsV2">
<property name="alias" value="h"/>
</include>
,clus.name as cluster_name
,clus.display_name as cluster_name
from
host h
left join cluster clus
on h.cluster_id = clus.id
where h.cluster_id = #{clusterId}
</select>

<select id="findAllByHostnames"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void genFullCaches() {
List<HostPO> hostPOList = hostDao.findByIds(hostIds);

clusterInfo = new ClusterInfo();
clusterInfo.setName(clusterPO.getName());
clusterInfo.setUserGroup(clusterPO.getUserGroup());
clusterInfo.setRootDir(clusterPO.getRootDir());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class ClusterDTO {

private String name;

private String displayName;

private String desc;

private Integer type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class ClusterCommandDTO {

private String name;

private String displayName;

private String desc;

private Integer type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class ClusterCommandReq {
@Schema(example = "c1")
private String name;

@NotEmpty
@Schema(example = "c1")
private String displayName;

@Schema(example = "desc")
private String desc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class ClusterVO {

private String name;

private String displayName;

private String desc;

private Integer type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ CREATE TABLE `user`
CREATE TABLE `cluster`
(
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) DEFAULT NULL COMMENT 'Cluster Name',
`name` VARCHAR(255) DEFAULT NULL COMMENT 'Unique Name',
`display_name` VARCHAR(255) DEFAULT NULL COMMENT 'Display Name',
`desc` VARCHAR(255) DEFAULT NULL COMMENT 'Cluster Description',
`type` INTEGER DEFAULT 1 COMMENT '1-Physical Machine, 2-Kubernetes',
`user_group` VARCHAR(255),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CREATE TABLE cluster
(
id BIGINT CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY,
name VARCHAR(255) DEFAULT NULL,
display_name VARCHAR(255) DEFAULT NULL,
"desc" VARCHAR(255) DEFAULT NULL,
type INT CHECK (cluster.type > 0) DEFAULT 1,
user_group VARCHAR(255),
Expand All @@ -68,7 +69,8 @@ CREATE TABLE cluster
CONSTRAINT uk_name UNIQUE (name)
);

COMMENT ON COLUMN cluster.name IS 'Cluster Name';
COMMENT ON COLUMN cluster.name IS 'Unique Name';
COMMENT ON COLUMN cluster.display_name IS 'Display Name';
COMMENT ON COLUMN cluster."desc" IS 'Cluster Description';
COMMENT ON COLUMN cluster.type IS '1-Physical Machine, 2-Kubernetes';
COMMENT ON COLUMN cluster.status IS '1-healthy, 2-unhealthy, 3-unknown';
Expand Down

0 comments on commit 3781c75

Please sign in to comment.