2023-01-14 21:02:18 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2023-08-04 22:22:47 +08:00
|
|
|
<mapper namespace="com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper">
|
2023-11-26 19:29:59 +08:00
|
|
|
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode">
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
|
|
|
<result column="group_name" jdbcType="VARCHAR" property="groupName"/>
|
|
|
|
<result column="host_id" jdbcType="VARCHAR" property="hostId"/>
|
|
|
|
<result column="host_ip" jdbcType="VARCHAR" property="hostIp"/>
|
|
|
|
<result column="host_port" jdbcType="INTEGER" property="hostPort"/>
|
|
|
|
<result column="expire_at" jdbcType="TIMESTAMP" property="expireAt"/>
|
|
|
|
<result column="node_type" jdbcType="TINYINT" property="nodeType"/>
|
|
|
|
<result column="context_path" jdbcType="VARCHAR" property="contextPath"/>
|
|
|
|
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs"/>
|
|
|
|
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
|
|
|
|
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt"/>
|
|
|
|
</resultMap>
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
|
|
|
|
</sql>
|
|
|
|
<insert id="insertOrUpdate" parameterType="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode"
|
|
|
|
useGeneratedKeys="true" keyProperty="id">
|
|
|
|
INSERT INTO server_node (group_name, host_id, host_ip, host_port,
|
|
|
|
expire_at, node_type, ext_attrs, context_path, create_dt)
|
|
|
|
VALUES (#{groupName}, #{hostId}, #{hostIp}, #{hostPort},
|
|
|
|
#{expireAt}, #{nodeType}, #{extAttrs}, #{contextPath}, #{createDt})
|
|
|
|
ON CONFLICT (host_id, host_ip) DO UPDATE SET expire_at = EXCLUDED.expire_at
|
|
|
|
|
|
|
|
</insert>
|
|
|
|
<delete id="deleteByExpireAt">
|
|
|
|
delete
|
|
|
|
from server_node
|
|
|
|
where expire_at <= #{endTime,jdbcType=TIMESTAMP}
|
|
|
|
</delete>
|
|
|
|
<select id="countActivePod"
|
|
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO">
|
|
|
|
SELECT node_type as nodeType, count(*) as total
|
2023-12-03 20:00:06 +08:00
|
|
|
from server_node where namespace_id in
|
|
|
|
<foreach collection="namespaceIds" item="namespaceId" separator="," open="(" close=")">
|
|
|
|
#{namespaceId}
|
|
|
|
</foreach>
|
2023-11-26 19:29:59 +08:00
|
|
|
GROUP BY node_type
|
|
|
|
</select>
|
2023-01-09 15:54:07 +08:00
|
|
|
</mapper>
|