Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
mappers.StreamSourceEntityMapper.xml Maven / Gradle / Ivy
<?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.StreamSourceEntityMapper">
<resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/>
<result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/>
<result column="source_type" jdbcType="VARCHAR" property="sourceType"/>
<result column="source_name" jdbcType="VARCHAR" property="sourceName"/>
<result column="task_map_id" jdbcType="INTEGER" property="taskMapId"/>
<result column="agent_ip" jdbcType="VARCHAR" property="agentIp"/>
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
<result column="data_node_name" jdbcType="VARCHAR" property="dataNodeName"/>
<result column="inlong_cluster_name" jdbcType="VARCHAR" property="inlongClusterName"/>
<result column="inlong_cluster_node_group" jdbcType="VARCHAR" property="inlongClusterNodeGroup"/>
<result column="serialization_type" jdbcType="VARCHAR" property="serializationType"/>
<result column="snapshot" jdbcType="LONGVARCHAR" property="snapshot"/>
<result column="report_time" jdbcType="TIMESTAMP" property="reportTime"/>
<result column="data_time_zone" jdbcType="VARCHAR" property="dataTimeZone"/>
<result column="ext_params" jdbcType="LONGVARCHAR" property="extParams"/>
<result column="version" jdbcType="INTEGER" property="version"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="previous_status" jdbcType="INTEGER" property="previousStatus"/>
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
<result column="creator" jdbcType="VARCHAR" property="creator"/>
<result column="modifier" jdbcType="VARCHAR" property="modifier"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
</resultMap>
<sql id="Base_Column_List">
id, inlong_group_id, inlong_stream_id, source_type, source_name, task_map_id, agent_ip, uuid,
data_node_name, inlong_cluster_name, inlong_cluster_node_group, serialization_type, snapshot, report_time,
data_time_zone, ext_params, version, status, previous_status, is_deleted, creator, modifier, create_time, modify_time
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id"
parameterType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
insert into stream_source (inlong_group_id, inlong_stream_id,
source_type, source_name, task_map_id, agent_ip,
uuid, data_node_name, inlong_cluster_name, inlong_cluster_node_group,
serialization_type, snapshot, report_time,
data_time_zone, ext_params, status,
previous_status, creator, modifier)
values (#{inlongGroupId,jdbcType=VARCHAR}, #{inlongStreamId,jdbcType=VARCHAR},
#{sourceType,jdbcType=VARCHAR}, #{sourceName,jdbcType=VARCHAR}, #{taskMapId,jdbcType=INTEGER},
#{agentIp,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}, #{dataNodeName,jdbcType=VARCHAR},
#{inlongClusterName,jdbcType=VARCHAR}, #{inlongClusterNodeGroup,jdbcType=VARCHAR},
#{serializationType,jdbcType=VARCHAR}, #{snapshot,jdbcType=LONGVARCHAR},#{modifyTime,jdbcType=TIMESTAMP},
#{dataTimeZone,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR}, #{status,jdbcType=INTEGER},
#{previousStatus,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
</insert>
<select id="selectById" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where id = #{id,jdbcType=INTEGER}
and is_deleted = 0
</select>
<select id="selectByTaskMapId" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where task_map_id = #{taskMapId,jdbcType=INTEGER}
and is_deleted = 0
</select>
<select id="selectByIdForUpdate" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where id = #{id,jdbcType=INTEGER}
and is_deleted = 0
for update
</select>
<select id="selectForAgentTask" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where id = #{id,jdbcType=INTEGER}
for update
</select>
<select id="selectOneByTaskMapIdAndAgentIp" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where task_map_id = #{taskMapId,jdbcType=INTEGER}
and agent_ip = #{agentIp, jdbcType=VARCHAR}
and is_deleted = 0
limit 1
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(1)
from stream_source
<where>
is_deleted = 0
<if test="groupId != null and groupId != ''">
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
</if>
<if test="streamId != null and streamId != ''">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="selectDataAddTaskCount" resultType="java.lang.Integer">
select count(1)
from stream_source
<where>
<if test="groupId != null and groupId != ''">
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
</if>
<if test="streamId != null and streamId != ''">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
and task_map_id is not NULL
</where>
</select>
<select id="selectByCondition"
parameterType="org.apache.inlong.manager.pojo.source.SourcePageRequest"
resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="request.inlongGroupId != null and request.inlongGroupId != ''">
and inlong_group_id = #{request.inlongGroupId, jdbcType=VARCHAR}
</if>
<if test="request.inlongStreamId != null and request.inlongStreamId != ''">
and inlong_stream_id = #{request.inlongStreamId, jdbcType=VARCHAR}
</if>
<if test="request.sourceType != null and request.sourceType != ''">
and source_type = #{request.sourceType, jdbcType=VARCHAR}
</if>
<if test="request.dataNodeName != null and request.dataNodeName != ''">
and data_node_name = #{request.dataNodeName, jdbcType=VARCHAR}
</if>
<if test="request.inlongClusterName != null and request.inlongClusterName != ''">
and inlong_cluster_name = #{request.inlongClusterName, jdbcType=VARCHAR}
</if>
<if test="request.keyword != null and request.keyword != ''">
and (
inlong_group_id like CONCAT('%', #{request.keyword}, '%')
or inlong_stream_id like CONCAT('%', #{request.keyword}, '%')
or source_name like CONCAT('%', #{request.keyword}, '%')
)
</if>
<if test="request.status != null and request.status != ''">
and status = #{request.status, jdbcType=INTEGER}
</if>
<if test="request.statusList != null and request.statusList.size() > 0">
and status in
<foreach collection="request.statusList" item="status" index="index" open="(" close=")" separator=",">
#{status}
</foreach>
</if>
and task_map_id is NULL
</where>
<choose>
<when test="request.orderField != null and request.orderField != '' and request.orderType != null and request.orderType != ''">
order by ${request.orderField} ${request.orderType}
</when>
<otherwise>
order by create_time desc
</otherwise>
</choose>
</select>
<select id="selectByAgentIp" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
where is_deleted = 0
and agent_ip = #{agentIp, jdbcType=VARCHAR}
</select>
<select id="selectByRelatedId" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
<if test="streamId != null and streamId != ''">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
<if test="sourceName != null and sourceName != ''">
and source_name = #{sourceName, jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="selectByStatus" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="statusList != null and statusList.size()>0">
and status in
<foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
limit #{limit, jdbcType=INTEGER}
</where>
</select>
<select id="selectByStatusAndType" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="statusList != null and statusList.size()>0">
and status in
<foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypeList != null and sourceTypeList.size()>0">
and source_type in
<foreach item="item" index="index" collection="sourceTypeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
limit #{limit, jdbcType=INTEGER}
</where>
</select>
<select id="selectByAgentIpAndCluster" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="statusList != null and statusList.size()>0">
and status in
<foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypeList != null and sourceTypeList.size()>0">
and source_type in
<foreach item="item" index="index" collection="sourceTypeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="agentIp != null and agentIp != ''">
and agent_ip = #{agentIp, jdbcType=VARCHAR}
</if>
and inlong_cluster_name = #{clusterName, jdbcType=VARCHAR}
</where>
</select>
<select id="selectTemplateSourceByCluster" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="statusList != null and statusList.size()>0">
and status in
<foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypeList != null and sourceTypeList.size()>0">
and source_type in
<foreach item="item" index="index" collection="sourceTypeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and agent_ip is NULL
and task_map_id is NULL
and inlong_cluster_name = #{clusterName, jdbcType=VARCHAR}
</where>
</select>
<select id="selectByStatusAndCluster" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
(inlong_cluster_name = #{clusterName, jdbcType=VARCHAR})
and (find_in_set( #{agentIp, jdbcType=VARCHAR}, agent_ip) or agent_ip ='All')
and `status` in
<foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="uuid != null and uuid != ''">
and uuid = #{uuid, jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="selectByGroupIds" resultType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
select
<include refid="Base_Column_List"/>
from stream_source
<where>
is_deleted = 0
<if test="groupIdList != null and groupIdList.size()>0">
and inlong_group_id in
<foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and task_map_id is NULL
</where>
</select>
<select id="selectSourceType" resultType="java.lang.String">
select distinct (source_type)
from stream_source
<where>
is_deleted = 0
<if test="groupId != null and groupId != ''">
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
</if>
<if test="streamId != null and streamId != ''">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
for update
</where>
</select>
<select id="selectNeedUpdateIdsByClusterAndDataNode" resultType="java.lang.Integer">
select id
from stream_source
<where>
status not in (99, 110)
and is_deleted = 0
<if test="clusterName != null">
and inlong_cluster_name = #{clusterName, jdbcType=VARCHAR}
</if>
<if test="nodeName != null">
and data_node_name = #{nodeName, jdbcType=VARCHAR}
</if>
<if test="sourceType != null">
and source_type = #{sourceType, jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="selectHeartbeatTimeoutIds" resultType="java.lang.Integer">
select id
from stream_source
<where>
is_deleted = 0
and status = 105
<if test="sourceTypeList != null and sourceTypeList.size()>0">
and source_type in
<foreach item="item" index="index" collection="sourceTypeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="agentIp != null and agentIp != ''">
and agent_ip = #{agentIp, jdbcType=VARCHAR}
</if>
and inlong_cluster_name = #{clusterName, jdbcType=VARCHAR}
</where>
</select>
<update id="updateByPrimaryKeySelective" parameterType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
update stream_source
<set>
<if test="inlongGroupId != null">
inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR},
</if>
<if test="inlongStreamId != null">
inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR},
</if>
<if test="sourceType != null">
source_type = #{sourceType,jdbcType=VARCHAR},
</if>
<if test="sourceName != null">
source_name = #{sourceName,jdbcType=VARCHAR},
</if>
<if test="agentIp != null">
agent_ip = #{agentIp,jdbcType=VARCHAR},
</if>
<if test="uuid != null">
uuid = #{uuid,jdbcType=VARCHAR},
</if>
<if test="dataNodeName != null">
data_node_name = #{dataNodeName,jdbcType=VARCHAR},
</if>
<if test="inlongClusterName != null">
inlong_cluster_name = #{inlongClusterName,jdbcType=INTEGER},
</if>
<if test="inlongClusterNodeGroup != null">
inlong_cluster_node_group = #{inlongClusterNodeGroup,jdbcType=INTEGER},
</if>
<if test="serializationType != null">
serialization_type = #{serializationType,jdbcType=VARCHAR},
</if>
<if test="snapshot != null">
snapshot = #{snapshot,jdbcType=LONGVARCHAR},
</if>
<if test="reportTime != null">
report_time = #{reportTime,jdbcType=TIMESTAMP},
</if>
<if test="dataTimeZone != null">
data_time_zone = #{dataTimeZone,jdbcType=VARCHAR},
</if>
<if test="extParams != null">
ext_params = #{extParams,jdbcType=LONGVARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="previousStatus != null">
previous_status = #{previousStatus,jdbcType=INTEGER},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted,jdbcType=INTEGER},
</if>
<if test="creator != null">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="modifier != null">
modifier = #{modifier,jdbcType=VARCHAR},
</if>
version = #{version,jdbcType=INTEGER} + 1
</set>
where id = #{id,jdbcType=INTEGER}
and version = #{version,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
update stream_source
set inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR},
inlong_stream_id = #{inlongStreamId,jdbcType=VARCHAR},
source_type = #{sourceType,jdbcType=VARCHAR},
source_name = #{sourceName,jdbcType=VARCHAR},
agent_ip = #{agentIp,jdbcType=VARCHAR},
uuid = #{uuid,jdbcType=VARCHAR},
data_node_name = #{dataNodeName,jdbcType=VARCHAR},
inlong_cluster_name = #{inlongClusterName,jdbcType=VARCHAR},
inlong_cluster_node_group = #{inlongClusterNodeGroup,jdbcType=VARCHAR},
serialization_type = #{serializationType,jdbcType=VARCHAR},
snapshot = #{snapshot,jdbcType=LONGVARCHAR},
report_time = #{reportTime,jdbcType=TIMESTAMP},
data_time_zone = #{dataTimeZone,jdbcType=VARCHAR},
ext_params = #{extParams,jdbcType=LONGVARCHAR},
version = #{version,jdbcType=INTEGER} + 1,
status = #{status,jdbcType=INTEGER},
previous_status = #{previousStatus,jdbcType=INTEGER},
is_deleted = #{isDeleted,jdbcType=INTEGER},
creator = #{creator,jdbcType=VARCHAR},
modifier = #{modifier,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
and version = #{version,jdbcType=INTEGER}
</update>
<update id="updateStatus">
update stream_source
set previous_status = status,
status = #{nextStatus, jdbcType=INTEGER}
<if test="changeTime == false">
, modify_time = modify_time
</if>
where id = #{id, jdbcType=INTEGER}
</update>
<update id="updateStatusByRelatedId">
update stream_source
set previous_status = status,
status = #{nextStatus, jdbcType=INTEGER}
<where>
is_deleted = 0
and status != 101
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
<if test="streamId != null">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
and source_type != 'AUTO_PUSH'
</where>
</update>
<update id="updateIpAndUuid">
update stream_source
set agent_ip = #{agentIp,jdbcType=VARCHAR},
uuid = #{uuid,jdbcType=VARCHAR}
<if test="changeTime == false">
, modify_time = modify_time
</if>
where id = #{id, jdbcType=INTEGER}
</update>
<update id="updateSnapshot" parameterType="org.apache.inlong.manager.dao.entity.StreamSourceEntity">
update stream_source
set snapshot = #{snapshot,jdbcType=LONGVARCHAR},
report_time = #{reportTime,jdbcType=TIMESTAMP},
modify_time = modify_time
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusByIds">
update stream_source
<set>
previous_status = status,
status = #{status, jdbcType=INTEGER},
<if test="operator != null and operator !=''">
modifier = #{operator, jdbcType=VARCHAR},
</if>
version = version + 1
</set>
<where>
is_deleted = 0
<if test="idList != null and idList.size() > 0">
and id in
<foreach item="item" index="index" collection="idList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</update>
<update id="rollbackTimeoutStatusByIds">
update stream_source
<set>
status = previous_status,
previous_status = 105,
<if test="operator != null and operator !=''">
modifier = #{operator, jdbcType=VARCHAR},
</if>
version = version + 1
</set>
<where>
is_deleted = 0
and status = 105
<if test="idList != null and idList.size() > 0">
and id in
<foreach item="item" index="index" collection="idList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</update>
<update id="updateStatusToTimeout">
update stream_source
<set>
previous_status = status,
status = 105
</set>
<where>
is_deleted = 0
and modify_time <= DATE_ADD(NOW(), INTERVAL -#{beforeSeconds, jdbcType=INTEGER} SECOND)
and status not in (101, 102, 104, 105, 110)
</where>
</update>
<update id="updateStatusByDeleted">
update stream_source
<set>
previous_status = status,
status = 201,
</set>
<where>
is_deleted != 0
and status not in (99, 201, 301)
</where>
</update>
<update id="logicalDeleteByTimeout">
update stream_source
<set>
is_deleted = id,
status = 99
</set>
<where>
is_deleted = 0
and task_map_id is not null
and modify_time <= DATE_ADD(NOW(), INTERVAL -#{retentionDays, jdbcType=INTEGER} DAY)
</where>
</update>
<update id="logicalDeleteByRelatedId">
update stream_source
<set>
is_deleted = id,
previous_status = status,
status = #{status, jdbcType=INTEGER},
version = version + 1
</set>
where is_deleted = 0
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</update>
<update id="logicalDeleteByIds">
update stream_source
<set>
is_deleted = id,
previous_status = status,
status = #{status, jdbcType=INTEGER},
version = version + 1
</set>
where id in
<foreach item="item" index="index" collection="idList" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<update id="logicalDeleteByAgentIp">
update stream_source
<set>
is_deleted = id,
previous_status = status,
status = #{status, jdbcType=INTEGER},
version = version + 1
</set>
where is_deleted = 0
and agent_ip = #{agentIp, jdbcType=VARCHAR}
and task_map_id is not null
<if test="targetStatus != null">
and status = #{targetStatus, jdbcType=INTEGER}
</if>
</update>
<delete id="deleteByRelatedId">
delete
from stream_source
where
is_deleted = 0
and inlong_group_id = #{groupId, jdbcType=VARCHAR}
<if test="streamId != null and streamId != ''">
and inlong_stream_id = #{streamId, jdbcType=VARCHAR}
</if>
</delete>
<delete id="deleteByInlongGroupIds">
delete
from stream_source
where inlong_group_id in
<foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
</mapper>