Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
timyuer committed Aug 27, 2024
1 parent 67ee0c0 commit 0fb65bb
Show file tree
Hide file tree
Showing 22 changed files with 128 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ List<HostComponentPO> findAllByClusterIdAndComponentNameAndHostnameIn(

List<HostComponentPO> findAllByClusterId(@Param("clusterId") Long clusterId);

HostComponentPO findByComponentPOComponentNameAndHostPOHostname(String componentName, String hostName);

List<HostComponentPO> findAllByClusterIdAndHostId(@Param("clusterId") Long clusterId, @Param("hostId") Long hostId);

List<HostComponentPO> findAllByClusterIdAndServiceId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
import lombok.EqualsAndHashCode;

import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.TableGenerator;
import jakarta.persistence.Transient;
Expand Down Expand Up @@ -113,12 +109,4 @@ public class HostComponentPO extends BasePO implements Serializable {
@Transient
@Column(name = "hostname")
private String hostname;

@ManyToOne
@JoinColumn(name = "host_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private HostPO hostPO;

@ManyToOne
@JoinColumn(name = "component_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private ComponentPO componentPO;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
, s.stack_name, s.stack_version
from
cluster r
left join stack s
inner join stack s
on r.stack_id = s.id
<where>
<if test="clusterId!=0">
Expand All @@ -74,7 +74,7 @@
, s.stack_name, s.stack_version
from
cluster r
left join stack s
inner join stack s
on r.stack_id = s.id
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
<include refid="baseColumnsV2">
<property name="alias" value="r"/>
</include>
,c.cluster_name, s.service_name
,c.cluster_name, s.service_name
from
component r
left join cluster c
inner join cluster c
on r.cluster_id = c.id
left join service s
on r.service_id = s.id
inner join service s
on r.service_id = s.id
<where>
<if test="clusterId != 0">
r.cluster_id = #{clusterId}
Expand All @@ -80,7 +80,7 @@
</if>
</where>
) r
left join (select * from service
inner join (select * from service
<where>
<if test="serviceNames != null">
service_name in
Expand All @@ -102,7 +102,7 @@
, s.service_name
from
component r
left join service s
inner join service s
on r.service_id = s.id and r.cluster_id = s.cluster_id
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</include>
from
host_component hc
left join (select * from component
inner join (select * from component
<where>
<if test="componentName != null">
component_name = #{componentName}
Expand All @@ -60,7 +60,7 @@
, c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
from
host_component hc
left join (select * from component
inner join (select * from component
<where>
<if test="clusterId != 0">
cluster_id = #{clusterId}
Expand All @@ -71,11 +71,11 @@
</where>
) c
on hc.component_id = c.id
left join service s
inner join service s
on c.service_id = s.id
left join cluster clus
inner join cluster clus
on c.cluster_id = clus.id
left join host ht
inner join host ht
on hc.host_id = ht.id
</select>

Expand All @@ -87,9 +87,9 @@
</include>
from
host_component hc
left join (select * from host
inner join (select * from host
<where>
<if test="hostname != 0">
<if test="hostname != null">
hostname = #{hostname}
</if>
<if test="clusterId != 0">
Expand All @@ -98,17 +98,48 @@
</where>
) h
on hc.host_id = h.id
left join (select * from component
inner join (select * from component
<where>
<if test="componentName != 0">
<if test="componentName != null">
component_name = #{componentName}
</if>
</where>
) c
on hc.component_id = c.id and h.cluster_id = c.cluster_id
limit 1
</select>

<select id="findAllByClusterIdAndComponentNameAndHostnameIn"
resultType="org.apache.bigtop.manager.dao.po.HostComponentPO">
select
<include refid="baseColumnsV2">
<property name="alias" value="hc"/>
</include>
, c.component_name
from
host_component hc
inner join (select * from host
<where>
<if test="hostnames != null">
hostname in
<foreach collection="hostnames" item="hostname" index="index" open="(" close=")" separator=",">
#{hostname}
</foreach>
</if>
<if test="clusterId != 0">
and cluster_id = #{clusterId}
</if>
</where>
) h
on hc.host_id = h.id
inner join (select * from component
<where>
<if test="componentName != 0">
component_name = #{componentName}
</if>
</where>
) c
on hc.component_id = c.id
on hc.component_id = c.id and h.cluster_id = c.cluster_id
</select>

<select id="findAllByClusterIdAndHostId"
Expand All @@ -120,13 +151,13 @@
, c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
from
host_component hc
left join component c
inner join component c
on hc.component_id = c.id
left join service s
inner join service s
on c.service_id = s.id
left join cluster clus
inner join cluster clus
on c.cluster_id = clus.id
left join (select * from host
inner join (select * from host
<where>
<if test="clusterId != 0">
cluster_id = #{clusterId}
Expand All @@ -148,19 +179,19 @@
, c.service_id, c.component_name, c.display_name, c.category, s.service_name, clus.cluster_name, ht.hostname
from
host_component hc
left join (select * from component
inner join (select * from component
<where>
<if test="clusterId != 0">
cluster_id = #{clusterId}
</if>
</where>
) c
on hc.component_id = c.id
left join service s
inner join service s
on c.service_id = s.id
left join cluster clus
inner join cluster clus
on c.cluster_id = clus.id
left join host ht
inner join host ht
on hc.host_id = ht.id
</select>

Expand All @@ -173,18 +204,18 @@
,st.stack_name,st.stack_version,ser.service_name,ser.service_user,clu.root,c.component_name,c.command_script,hst.hostname
from
host_component hc
left join host hst
inner join host hst
on hc.host_id = hst.id
left join
inner join
component c
on hc.component_id = c.id
left join
inner join
cluster clu
on c.cluster_id = clu.id
left join
inner join
service ser
on c.service_id=ser.id and c.cluster_id = ser.cluster_id
left join stack st
inner join stack st
on clu.stack_id = st.id
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
${alias}.id, ${alias}.hostname, ${alias}.ipv4, ${alias}.ipv6, ${alias}.os, ${alias}.arch, ${alias}.available_processors, ${alias}.free_memory_size, ${alias}.total_memory_size, ${alias}.free_disk, ${alias}.total_disk, ${alias}.state, ${alias}.cluster_id
</sql>

<select id="findByHostName" resultType="org.apache.bigtop.manager.dao.po.HostPO">
<select id="findByHostname" resultType="org.apache.bigtop.manager.dao.po.HostPO">
select
<include refid="baseColumns"/>
from
host
<where>
<if test="hostname!=null">
hostname=#{hostname}
<if test="hostname != null">
hostname = #{hostname}
</if>
</where>
limit 1
Expand All @@ -58,7 +58,7 @@
</if>
</where>
) h
left join
inner join
cluster clus
on h.cluster_id = clus.id
limit 1
Expand All @@ -73,7 +73,7 @@
,clus.cluster_name
from
host h
left join
inner join
(select * from cluster
<where>
<if test="clusterId != 0">
Expand All @@ -92,7 +92,7 @@
host
<where>
<if test="hostnames != null and hostnames.size() > 0">
cluster_id in
hostname in
<foreach collection="hostnames" item="hostname" index="index" open="(" close=")" separator=", ">
#{hostname}
</foreach>
Expand All @@ -104,7 +104,7 @@
insert into host (hostname, ipv4, ipv6, os, arch, available_processors, free_memory_size, total_memory_size, free_disk, total_disk, state, cluster_id)
values
<foreach collection='hosts' item='host' separator=','>
(#{host.hostname}, #{host.ipv4}, #{host.ipv6}, #{host.os}, #{host.arch}, #{host.available_processors}, #{host.free_memory_size}, #{host.total_memory_size}, #{host.free_disk}, #{host.total_disk}, #{host.state}, #{host.cluster_id})
(#{host.hostname}, #{host.ipv4}, #{host.ipv6}, #{host.os}, #{host.arch}, #{host.availableProcessors}, #{host.freeMemorySize}, #{host.totalMemorySize}, #{host.freeDisk}, #{host.totalDisk}, #{host.state}, #{host.clusterId})
</foreach>
</insert>

Expand Down
10 changes: 5 additions & 5 deletions bigtop-manager-dao/src/main/resources/mapper/mysql/JobMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
</if>
</where>
) h
left join stage st
inner join stage st
on h.id = st.job_id
left join task tk
inner join task tk
on tk.job_id = h.id and st.id = tk.stage_id
</select>

Expand All @@ -109,9 +109,9 @@
</if>
</where>
) h
left join stage st
inner join stage st
on h.id = st.job_id
left join task tk
inner join task tk
on tk.job_id = h.id and st.id = tk.stage_id
</select>

Expand All @@ -123,7 +123,7 @@
</include>
from
(select * from job where cluster_id is null) h
left join stage st
inner join stage st
on h.id = st.job_id
</select>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
</select>

<insert id="saveAll">
insert into repo (cluster_name, cluster_type, root, user_group, packages, repo_template, state, selected)
insert into repo (base_url, os, arch, repo_id, repo_name, cluster_id)
values
<foreach collection='clusters' item='cluster' separator=','>
(#{cluster.clusterName},#{cluster.clusterType},#{cluster.root},#{cluster.userGroup},#{cluster.packages},#{cluster.repoTemplate},#{cluster.state},#{cluster.selected})
(#{cluster.baseUrl},#{cluster.os},#{cluster.arch},#{cluster.repoId},#{cluster.repoName},#{cluster.clusterId})
</foreach>
</insert>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
</if>
</where>
) r
left join service s
inner join service s
on r.service_id = s.id
left join type_config tc
inner join type_config tc
on r.id = tc.service_config_id
order by version desc
</select>
Expand All @@ -87,9 +87,9 @@
</if>
</where>
) r
left join service s
inner join service s
on r.service_id = s.id
left join type_config tc
inner join type_config tc
on r.id = tc.service_config_id
limit 1
</select>
Expand All @@ -109,9 +109,9 @@
</if>
</where>
) r
left join service s
inner join service s
on r.service_id = s.id
left join type_config tc
inner join type_config tc
on r.id = tc.service_config_id
</select>

Expand Down
Loading

0 comments on commit 0fb65bb

Please sign in to comment.