mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-06 13:51:08 +08:00
kafka-manager 2.0
This commit is contained in:
54
kafka-manager-dao/src/main/resources/mapper/AccountDao.xml
Normal file
54
kafka-manager-dao/src/main/resources/mapper/AccountDao.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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">
|
||||
|
||||
<mapper namespace="AccountDao">
|
||||
<resultMap id="AccountMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="username" column="username" />
|
||||
<result property="password" column="password" />
|
||||
<result property="role" column="role" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<![CDATA[
|
||||
REPLACE account
|
||||
(username, password, role)
|
||||
VALUES
|
||||
(#{username}, #{password}, #{role})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.lang.String">
|
||||
DELETE FROM account WHERE username = #{username}
|
||||
</delete>
|
||||
|
||||
<update id="updateByName" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<![CDATA[
|
||||
UPDATE account SET
|
||||
password=#{password},
|
||||
role=#{role}
|
||||
WHERE username=#{username}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<select id="getByName" parameterType="java.lang.String" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE username = #{username}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="searchByNamePrefix" parameterType="java.lang.String" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE username like CONCAT(#{prefix},'%')
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
65
kafka-manager-dao/src/main/resources/mapper/AppDao.xml
Normal file
65
kafka-manager-dao/src/main/resources/mapper/AppDao.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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">
|
||||
<mapper namespace="AppDao">
|
||||
<resultMap id="AppMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="appId" column="app_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="password" column="password"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="applicant" column="applicant"/>
|
||||
<result property="principals" column="principals"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="modifyTime" column="modify_time"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
INSERT INTO app
|
||||
(app_id, `name`, password, `type`, applicant, principals, description)
|
||||
VALUES
|
||||
(#{appId}, #{name}, #{password}, #{type}, #{applicant}, #{principals}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.lang.String" >
|
||||
DELETE FROM app WHERE `name`=#{appName};
|
||||
</delete>
|
||||
|
||||
<select id="getByPrincipal" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE principals like CONCAT('%',#{principal},'%')
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE app_id = #{appId}
|
||||
</select>
|
||||
|
||||
<select id="getByName" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="AppMap">
|
||||
SELECT * FROM app
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
UPDATE app SET
|
||||
`name`=#{name},
|
||||
`type`=#{type},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
principals=#{principals}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE modify_time >= #{afterTime}
|
||||
</select>
|
||||
|
||||
<select id="listNewAll" resultMap="AppMap">
|
||||
SELECT * FROM app
|
||||
</select>
|
||||
</mapper>
|
||||
48
kafka-manager-dao/src/main/resources/mapper/AuthorityDao.xml
Normal file
48
kafka-manager-dao/src/main/resources/mapper/AuthorityDao.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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">
|
||||
<mapper namespace="AuthorityDao">
|
||||
<resultMap id="AuthorityMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
|
||||
<result column="app_id" jdbcType="VARCHAR" property="appId" />
|
||||
<result column="access" jdbcType="INTEGER" property="access" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO">
|
||||
REPLACE INTO authority
|
||||
(cluster_id, topic_name, app_id, access)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{appId}, #{access})
|
||||
</insert>
|
||||
|
||||
<select id="getAuthority" parameterType="java.util.Map" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
<trim>
|
||||
<if test="appId!=null">
|
||||
AND app_id=#{appId}
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<select id="getAuthorityByTopic" parameterType="java.util.Map" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
WHERE cluster_id=#{clusterId} AND (topic_name=#{topicName} OR topic_name='*')
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority WHERE app_id=#{appId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority WHERE modify_time >= #{afterTime}
|
||||
</select>
|
||||
</mapper>
|
||||
39
kafka-manager-dao/src/main/resources/mapper/BrokerDao.xml
Normal file
39
kafka-manager-dao/src/main/resources/mapper/BrokerDao.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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">
|
||||
<mapper namespace="BrokerDao">
|
||||
<resultMap id="BrokerDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_id" property="brokerId" />
|
||||
<result column="host" property="host" />
|
||||
<result column="port" property="port" />
|
||||
<result column="timestamp" property="timestamp" />
|
||||
<result column="max_avg_bytes_in" property="maxAvgBytesIn" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerDO">
|
||||
REPLACE broker
|
||||
(cluster_id, broker_id, host, port, timestamp, max_avg_bytes_in, status)
|
||||
VALUES
|
||||
(#{clusterId}, #{brokerId}, #{host}, #{port}, #{timestamp}, #{maxAvgBytesIn}, #{status})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.util.Map">
|
||||
DELETE FROM broker WHERE cluster_id = #{clusterId} AND broker_id = #{brokerId}
|
||||
</delete>
|
||||
|
||||
<select id="getDead" parameterType="java.lang.Long" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker WHERE cluster_id = #{clusterId} AND status = -1
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker WHERE cluster_id = #{clusterId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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">
|
||||
<mapper namespace="BrokerMetricsDao">
|
||||
<resultMap id="BrokerMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerMetricsDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="brokerId" column="broker_id" />
|
||||
<result property="metrics" column="metrics" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO broker_metrics (cluster_id, broker_id, metrics, gmt_create
|
||||
)
|
||||
VALUES
|
||||
<foreach item="BrokerMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{BrokerMetricsDO.clusterId}, #{BrokerMetricsDO.brokerId}, #{BrokerMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getBrokerMetrics" parameterType="java.util.Map" resultMap="BrokerMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM broker_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND broker_id = #{brokerId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
ORDER BY gmt_create ASC
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM broker_metrics WHERE gmt_create < #{endTime} LIMIT 1000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
51
kafka-manager-dao/src/main/resources/mapper/ClusterDao.xml
Normal file
51
kafka-manager-dao/src/main/resources/mapper/ClusterDao.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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">
|
||||
<mapper namespace="ClusterDao">
|
||||
<resultMap id="ClusterMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO">
|
||||
<id column="id" property="id" />
|
||||
<id column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="cluster_name" property="clusterName" />
|
||||
<result column="zookeeper" property="zookeeper" />
|
||||
<result column="bootstrap_servers" property="bootstrapServers" />
|
||||
<result column="mode" property="mode" />
|
||||
<result column="security_properties" property="securityProperties" />
|
||||
<result column="kafka_version" property="kafkaVersion" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO cluster (
|
||||
cluster_name, zookeeper, bootstrap_servers, mode, security_properties
|
||||
) VALUES (
|
||||
#{clusterName}, #{zookeeper}, #{bootstrapServers}, #{mode}, #{securityProperties}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO">
|
||||
UPDATE cluster SET
|
||||
cluster_name=#{clusterName},
|
||||
bootstrap_servers=#{bootstrapServers},
|
||||
mode=#{mode},
|
||||
security_properties=#{securityProperties},
|
||||
status=#{status}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster WHERE status = 1
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster ORDER BY status DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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">
|
||||
<mapper namespace="ClusterMetricsDao">
|
||||
<resultMap id="ClusterMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="metrics" column="metrics" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getClusterMetrics" parameterType="java.util.Map" resultMap="ClusterMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM cluster_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND gmt_create BETWEEN #{startTime}
|
||||
AND #{endTime} ORDER BY gmt_create ASC
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO cluster_metrics
|
||||
(cluster_id, metrics, gmt_create)
|
||||
VALUES
|
||||
<foreach item="ClusterMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{ClusterMetricsDO.clusterId}, #{ClusterMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM cluster_metrics WHERE gmt_create < #{endTime} LIMIT 200
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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">
|
||||
<mapper namespace="ClusterTaskDao">
|
||||
<resultMap id="ClusterTaskMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO">
|
||||
<id column="id" property="id" />
|
||||
<id column="task_status" property="taskStatus" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
|
||||
<result column="uuid" property="uuid" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="task_type" property="taskType" />
|
||||
<result column="kafka_package" property="kafkaPackage" />
|
||||
<result column="kafka_package_md5" property="kafkaPackageMd5" />
|
||||
<result column="server_properties" property="serverProperties" />
|
||||
<result column="server_properties_md5" property="serverPropertiesMd5" />
|
||||
<result column="agent_task_id" property="agentTaskId" />
|
||||
<result column="agent_rollback_task_id" property="agentRollbackTaskId" />
|
||||
<result column="host_list" property="hostList" />
|
||||
<result column="pause_host_list" property="pauseHostList" />
|
||||
<result column="rollback_host_list" property="rollbackHostList" />
|
||||
<result column="rollback_pause_host_list" property="rollbackPauseHostList" />
|
||||
<result column="operator" property="operator" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO cluster_tasks (
|
||||
uuid,
|
||||
cluster_id,
|
||||
task_type,
|
||||
kafka_package,
|
||||
kafka_package_md5,
|
||||
server_properties,
|
||||
server_properties_md5,
|
||||
agent_task_id,
|
||||
agent_rollback_task_id,
|
||||
host_list,
|
||||
pause_host_list,
|
||||
rollback_host_list,
|
||||
rollback_pause_host_list,
|
||||
operator
|
||||
) VALUES (
|
||||
#{uuid},
|
||||
#{clusterId},
|
||||
#{taskType},
|
||||
#{kafkaPackage},
|
||||
#{kafkaPackageMd5},
|
||||
#{serverProperties},
|
||||
#{serverPropertiesMd5},
|
||||
#{agentTaskId},
|
||||
#{agentRollbackTaskId},
|
||||
#{hostList},
|
||||
#{pauseHostList},
|
||||
#{rollbackHostList},
|
||||
#{rollbackPauseHostList},
|
||||
#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="ClusterTaskMap">
|
||||
SELECT * FROM cluster_tasks where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ClusterTaskMap">
|
||||
SELECT * FROM cluster_tasks ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
<select id="updateTaskState" parameterType="java.util.Map">
|
||||
UPDATE cluster_tasks SET task_status=#{taskStatus} WHERE id=#{taskId}
|
||||
</select>
|
||||
|
||||
<select id="updateRollback" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO">
|
||||
UPDATE cluster_tasks SET
|
||||
agent_rollback_task_id=#{agentRollbackTaskId},
|
||||
rollback_host_list=#{rollbackHostList},
|
||||
rollback_pause_host_list=#{rollbackPauseHostList}
|
||||
WHERE id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
41
kafka-manager-dao/src/main/resources/mapper/ConfigDao.xml
Normal file
41
kafka-manager-dao/src/main/resources/mapper/ConfigDao.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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">
|
||||
<mapper namespace="ConfigDao">
|
||||
<resultMap id="ConfigMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
<result property="configKey" column="config_key" />
|
||||
<result property="configValue" column="config_value" />
|
||||
<result property="configDescription" column="config_description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
INSERT INTO config (
|
||||
config_key, config_value, config_description
|
||||
) VALUES (
|
||||
#{configKey}, #{configValue}, #{configDescription}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByKey" parameterType="java.lang.String">
|
||||
DELETE FROM config WHERE config_key = #{configKey}
|
||||
</delete>
|
||||
|
||||
<select id="updateByKey" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
UPDATE config SET
|
||||
config_value=#{configValue},
|
||||
config_description=#{configDescription}
|
||||
WHERE config_key=#{configKey}
|
||||
</select>
|
||||
|
||||
<select id="getByKey" parameterType="java.lang.String" resultMap="ConfigMap">
|
||||
SELECT * FROM config WHERE config_key = #{configKey}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ConfigMap">
|
||||
SELECT * FROM config ORDER BY gmt_modify DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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">
|
||||
<mapper namespace="ControllerDao">
|
||||
<resultMap id="ControllerMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ControllerDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_id" property="brokerId" />
|
||||
<result column="host" property="host" />
|
||||
<result column="timestamp" property="timestamp" />
|
||||
<result column="version" property="version" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ControllerDO">
|
||||
INSERT INTO controller (
|
||||
cluster_id, broker_id, host, timestamp, version
|
||||
) VALUES (
|
||||
#{clusterId}, #{brokerId}, #{host}, #{timestamp}, #{version}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="ControllerMap">
|
||||
SELECT * FROM controller WHERE cluster_id=#{clusterId} ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
<mapper namespace="GatewayConfigDao">
|
||||
<resultMap id="GatewayConfigMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="type" property="type" />
|
||||
<result column="name" property="name" />
|
||||
<result column="value" property="value" />
|
||||
<result column="version" property="version" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getByConfigType" parameterType="java.lang.String" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE `type`=#{configType}
|
||||
</select>
|
||||
|
||||
<select id="getByConfigTypeAndName" parameterType="java.util.Map" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE `type`=#{configType} AND `name`=#{configName}
|
||||
</select>
|
||||
</mapper>
|
||||
20
kafka-manager-dao/src/main/resources/mapper/HeartbeatDao.xml
Normal file
20
kafka-manager-dao/src/main/resources/mapper/HeartbeatDao.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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">
|
||||
<mapper namespace="HeartbeatDao">
|
||||
<resultMap id="HeartbeatMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="modifyTime" column="modify_time" />
|
||||
<result property="ip" column="ip" />
|
||||
<result property="hostname" column="hostname" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
|
||||
REPLACE heartbeat (ip, hostname) VALUES (#{ip}, #{hostname})
|
||||
</insert>
|
||||
|
||||
<select id="selectActiveHosts" parameterType="java.util.Date" resultMap="HeartbeatMap">
|
||||
SELECT * FROM heartbeat WHERE modify_time >= #{afterTime} ORDER BY modify_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
29
kafka-manager-dao/src/main/resources/mapper/KafkaAclDao.xml
Normal file
29
kafka-manager-dao/src/main/resources/mapper/KafkaAclDao.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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">
|
||||
<mapper namespace="KafkaAclDao">
|
||||
<resultMap id="KafkaAclMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="access" property="access" />
|
||||
<result column="operation" property="operation" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO">
|
||||
INSERT INTO kafka_acl
|
||||
(app_id, cluster_id, topic_name, access, operation)
|
||||
VALUES
|
||||
( #{appId}, #{clusterId}, #{topicName}, #{access}, #{operation})
|
||||
</insert>
|
||||
|
||||
<select id="getKafkaAcls" parameterType="java.util.Map" resultMap="KafkaAclMap">
|
||||
SELECT * FROM kafka_acl WHERE cluster_id=#{clusterId} AND create_time>=#{startTime} AND #{endTime}>=create_time
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="KafkaAclMap">
|
||||
SELECT * FROM kafka_acl ORDER BY create_time ASC
|
||||
</select>
|
||||
</mapper>
|
||||
56
kafka-manager-dao/src/main/resources/mapper/KafkaBillDao.xml
Normal file
56
kafka-manager-dao/src/main/resources/mapper/KafkaBillDao.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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">
|
||||
<mapper namespace="KafkaBillDao">
|
||||
<resultMap id="KafkaBillMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaBillDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="principal" property="principal" />
|
||||
<result column="quota" property="quota" />
|
||||
<result column="cost" property="cost" />
|
||||
<result column="gmt_day" property="gmtDay" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaBillDO" >
|
||||
REPLACE INTO kafka_bill (
|
||||
cluster_id,
|
||||
topic_name,
|
||||
principal,
|
||||
quota,
|
||||
cost,
|
||||
gmt_day
|
||||
)
|
||||
VALUES (
|
||||
#{clusterId},
|
||||
#{topicName},
|
||||
#{principal},
|
||||
#{quota},
|
||||
#{cost},
|
||||
#{gmtDay}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByPrincipal" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE principal=#{principal}
|
||||
AND gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByTimeBetween" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByGmtDay" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE gmt_day=#{gmtDay}
|
||||
</select>
|
||||
</mapper>
|
||||
60
kafka-manager-dao/src/main/resources/mapper/KafkaFileDao.xml
Normal file
60
kafka-manager-dao/src/main/resources/mapper/KafkaFileDao.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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">
|
||||
<mapper namespace="KafkaFileDao">
|
||||
<resultMap id="KafkaFileMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="file_name" property="fileName" />
|
||||
<result column="file_md5" property="fileMd5" />
|
||||
<result column="file_type" property="fileType" />
|
||||
<result column="description" property="description" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into kafka_file (
|
||||
cluster_id, file_name, file_md5,
|
||||
file_type, description, operator
|
||||
)
|
||||
values (
|
||||
#{clusterId}, #{fileName}, #{fileMd5},
|
||||
#{fileType}, #{description}, #{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
delete from kafka_file where id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO">
|
||||
UPDATE kafka_file
|
||||
SET file_md5=#{fileMd5},
|
||||
file_name=#{fileName},
|
||||
operator=#{operator},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
gmt_modify=now()
|
||||
where id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="list" resultMap="KafkaFileMap">
|
||||
select * from kafka_file order by gmt_modify desc
|
||||
</select>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="KafkaFileMap">
|
||||
select * from kafka_file where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getFileByFileName" parameterType="java.lang.String" resultMap="KafkaFileMap">
|
||||
select * from kafka_file where file_name=#{fileName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
29
kafka-manager-dao/src/main/resources/mapper/KafkaUserDao.xml
Normal file
29
kafka-manager-dao/src/main/resources/mapper/KafkaUserDao.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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">
|
||||
<mapper namespace="KafkaUserDao">
|
||||
<resultMap id="KafkaUserMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="password" property="password" />
|
||||
<result column="user_type" property="userType" />
|
||||
<result column="operation" property="operation" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getKafkaUsers" parameterType="java.util.Map" resultMap="KafkaUserMap">
|
||||
SELECT * FROM kafka_user WHERE create_time>=#{startTime} AND #{endTime}>=create_time
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO">
|
||||
INSERT INTO kafka_user
|
||||
(app_id, password, user_type, operation)
|
||||
VALUES
|
||||
(#{appId}, #{password}, #{userType}, #{operation})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="KafkaUserMap">
|
||||
SELECT * FROM kafka_user
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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">
|
||||
<mapper namespace="LogicalClusterDao">
|
||||
<resultMap id="LogicalClusterMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="name" property="name" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="region_list" property="regionList" />
|
||||
<result column="mode" property="mode" />
|
||||
<result column="description" property="description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
INSERT INTO logical_cluster
|
||||
(name, app_id, cluster_id, region_list, mode, description)
|
||||
VALUES
|
||||
(#{name}, #{appId}, #{clusterId}, #{regionList}, #{mode}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM logical_cluster WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
UPDATE logical_cluster SET
|
||||
<!-- name=#{name}, 不允许修改 name, 会影响到上报的数据 -->
|
||||
cluster_id=#{clusterId},
|
||||
region_list=#{regionList},
|
||||
description=#{description},
|
||||
app_id=#{appId},
|
||||
mode=#{mode}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="LogicalClusterMap">
|
||||
SELECT * FROM logical_cluster WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="LogicalClusterMap">
|
||||
SELECT * FROM logical_cluster WHERE cluster_id=#{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="LogicalClusterMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM logical_cluster
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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">
|
||||
<mapper namespace="MonitorRuleDao">
|
||||
<resultMap id="MonitorRuleMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="strategy_id" property="strategyId" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO" >
|
||||
INSERT INTO monitor_rule (
|
||||
strategy_id,
|
||||
app_id,
|
||||
name,
|
||||
operator
|
||||
)
|
||||
VALUES (
|
||||
#{strategyId},
|
||||
#{appId},
|
||||
#{name},
|
||||
#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long" >
|
||||
DELETE FROM monitor_rule WHERE id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="java.util.Map" >
|
||||
UPDATE monitor_rule
|
||||
SET
|
||||
app_id=#{appId},
|
||||
name=#{name},
|
||||
operator=#{operator}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByStrategyId" parameterType="java.lang.Long" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule WHERE strategy_id=#{strategyId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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">
|
||||
<mapper namespace="OperateRecordDao">
|
||||
<resultMap id="OperateRecordMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="module_id" property="moduleId" />
|
||||
<result column="operate_id" property="operateId" />
|
||||
<result column="resource" property="resource" />
|
||||
<result column="content" property="content" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO">
|
||||
insert into operate_record (
|
||||
module_id, operate_id, resource, content, operator
|
||||
)
|
||||
values (
|
||||
#{moduleId}, #{operateId}, #{resource}, #{content},#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryByCondt" parameterType="java.util.Map" resultMap="OperateRecordMap">
|
||||
select *
|
||||
from operate_record
|
||||
where
|
||||
module_id = #{moduleId}
|
||||
<trim>
|
||||
<if test="operateId!=null">
|
||||
and operate_id=#{operateId}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="operator!=null">
|
||||
and operator=#{operator}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="startTime!=null">
|
||||
and create_time>=#{startTime}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="endTime!=null">
|
||||
and #{endTime}>=create_time
|
||||
</if>
|
||||
</trim>
|
||||
order by id desc
|
||||
</select>
|
||||
</mapper>
|
||||
111
kafka-manager-dao/src/main/resources/mapper/OrderDao.xml
Normal file
111
kafka-manager-dao/src/main/resources/mapper/OrderDao.xml
Normal file
@@ -0,0 +1,111 @@
|
||||
<?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">
|
||||
<mapper namespace="OrderDao">
|
||||
<resultMap id="OrderMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="type" property="type" />
|
||||
<result column="title" property="title" />
|
||||
<result column="applicant" property="applicant" />
|
||||
<result column="description" property="description" />
|
||||
<result column="approver" property="approver" />
|
||||
<result column="gmt_handle" property="gmtHandle" />
|
||||
<result column="opinion" property="opinion" />
|
||||
<result column="extensions" property="extensions" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="directSaveHandled" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into work_order (
|
||||
status, type, title, applicant, description, extensions, approver, opinion
|
||||
)
|
||||
values (
|
||||
#{status}, #{type}, #{title}, #{applicant}, #{description}, #{extensions}, #{approver}, #{opinion}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
INSERT INTO work_order (
|
||||
type, title, applicant, description, extensions
|
||||
)
|
||||
VALUES (
|
||||
#{type}, #{title}, #{applicant}, #{description},#{extensions}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="list" resultMap="OrderMap">
|
||||
select * from work_order order by gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
select * from work_order where id=#{id}
|
||||
</select>
|
||||
|
||||
<update id="updateOrderStatusById" parameterType="java.util.Map">
|
||||
update work_order
|
||||
set status = #{status}, gmt_modify=now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateOrderById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
update work_order set
|
||||
approver = #{approver},
|
||||
gmt_handle=now(),
|
||||
opinion= #{opinion},
|
||||
status = #{status},
|
||||
extensions = #{extensions},
|
||||
gmt_modify=now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getByApplicantAndStatus" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select *
|
||||
from work_order
|
||||
where applicant=#{applicant}
|
||||
<trim>
|
||||
<if test="status!=null">
|
||||
and status=#{status}
|
||||
</if>
|
||||
</trim>
|
||||
order by status,gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByApproverAndStatus" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select *
|
||||
from work_order
|
||||
where approver=#{approver}
|
||||
<trim>
|
||||
<if test="status!=null">
|
||||
and status=#{status}
|
||||
</if>
|
||||
</trim>
|
||||
order by status,gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByStatus" parameterType="java.lang.Integer" resultMap="OrderMap">
|
||||
select * from work_order where status=#{status}
|
||||
order by gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByGmtHandle" parameterType="java.util.Date" resultMap="OrderMap">
|
||||
select * from work_order where gmt_handle >= #{startTime} and status = 1
|
||||
</select>
|
||||
|
||||
<update id="updateExtensionsById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
UPDATE work_order SET
|
||||
extensions=#{extensions},
|
||||
gmt_modify=now()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getByHandleTime" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select * from work_order where gmt_handle >= #{startTime} and #{endTime} >= gmt_handle
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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">
|
||||
<mapper namespace="ReassignTaskDao">
|
||||
<resultMap id="ReassignTaskDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ReassignTaskDO">
|
||||
<id property="id" column="id" />
|
||||
<id property="taskId" column="task_id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicName" column="topic_name" />
|
||||
<result property="partitions" column="partitions" />
|
||||
<result property="reassignmentJson" column="reassignment_json" />
|
||||
<result property="realThrottle" column="real_throttle" />
|
||||
<result property="maxThrottle" column="max_throttle" />
|
||||
<result property="minThrottle" column="min_throttle" />
|
||||
<result property="beginTime" column="begin_time" />
|
||||
<result property="originalRetentionTime" column="original_retention_time" />
|
||||
<result property="reassignRetentionTime" column="reassign_retention_time" />
|
||||
<result property="srcBrokers" column="src_brokers" />
|
||||
<result property="destBrokers" column="dest_brokers" />
|
||||
<result property="operator" column="operator" />
|
||||
<result property="description" column="description" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchCreate" parameterType="java.util.List">
|
||||
INSERT INTO reassign_task (
|
||||
task_id,
|
||||
cluster_id,
|
||||
topic_name,
|
||||
partitions,
|
||||
reassignment_json,
|
||||
real_throttle,
|
||||
max_throttle,
|
||||
min_throttle,
|
||||
begin_time,
|
||||
original_retention_time,
|
||||
reassign_retention_time,
|
||||
src_brokers,
|
||||
dest_brokers,
|
||||
description,
|
||||
operator
|
||||
)
|
||||
VALUES
|
||||
<foreach item="ReassignTaskDO" index="index" collection="list" separator=",">
|
||||
(
|
||||
#{ReassignTaskDO.taskId},
|
||||
#{ReassignTaskDO.clusterId},
|
||||
#{ReassignTaskDO.topicName},
|
||||
#{ReassignTaskDO.partitions},
|
||||
#{ReassignTaskDO.reassignmentJson},
|
||||
#{ReassignTaskDO.realThrottle},
|
||||
#{ReassignTaskDO.maxThrottle},
|
||||
#{ReassignTaskDO.minThrottle},
|
||||
#{ReassignTaskDO.beginTime},
|
||||
#{ReassignTaskDO.originalRetentionTime},
|
||||
#{ReassignTaskDO.reassignRetentionTime},
|
||||
#{ReassignTaskDO.srcBrokers},
|
||||
#{ReassignTaskDO.destBrokers},
|
||||
#{ReassignTaskDO.description},
|
||||
#{ReassignTaskDO.operator}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getByTaskId" parameterType="java.lang.Long" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE task_id=#{taskId}
|
||||
</select>
|
||||
|
||||
<select id="getSubTask" parameterType="java.lang.Long" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE id=#{subTaskId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE gmt_create > #{gmtCreate} ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="java.util.Map">
|
||||
UPDATE reassign_task
|
||||
SET
|
||||
reassignment_json=#{reassignmentJson},
|
||||
real_throttle=#{realThrottle},
|
||||
max_throttle=#{maxThrottle},
|
||||
min_throttle=#{minThrottle},
|
||||
begin_time=#{beginTime},
|
||||
status=#{status}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
</mapper>
|
||||
65
kafka-manager-dao/src/main/resources/mapper/RegionDao.xml
Normal file
65
kafka-manager-dao/src/main/resources/mapper/RegionDao.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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">
|
||||
<mapper namespace="RegionDao">
|
||||
<resultMap id="RegionMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="name" property="name" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_list" property="brokerList" />
|
||||
<result column="capacity" property="capacity" />
|
||||
<result column="real_used" property="realUsed" />
|
||||
<result column="estimate_used" property="estimateUsed" />
|
||||
<result column="description" property="description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
INSERT INTO region
|
||||
(name, cluster_id, broker_list, status, description)
|
||||
VALUES
|
||||
(#{name}, #{clusterId}, #{brokerList}, #{status}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM region WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
UPDATE region SET
|
||||
name=#{name},
|
||||
cluster_id=#{clusterId},
|
||||
broker_list=#{brokerList},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
status=#{status}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<update id="updateCapacityById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
UPDATE region SET
|
||||
capacity=#{capacity},
|
||||
real_used=#{realUsed},
|
||||
estimate_used=#{estimateUsed}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="RegionMap">
|
||||
SELECT * FROM region WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="RegionMap">
|
||||
SELECT * FROM region WHERE cluster_id=#{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="RegionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM region
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicAppMetricsDao">
|
||||
<resultMap id="TopicAppMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_app_metrics
|
||||
(cluster_id, topic_name, app_id, metrics, gmt_create)
|
||||
values
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.appId}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getTopicAppMetrics" parameterType="java.util.Map" resultMap="TopicAppMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_app_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_app_metrics WHERE gmt_create < #{endTime} LIMIT 3000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicConnectionDao">
|
||||
<resultMap id="TopicConnectionMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="clusterId" column="cluster_id"/>
|
||||
<result property="topicName" column="topic_name"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="appId" column="app_id"/>
|
||||
<result property="ip" column="ip"/>
|
||||
<result property="clientVersion" column="client_version"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO">
|
||||
REPLACE INTO topic_connections (
|
||||
cluster_id,
|
||||
topic_name,
|
||||
`type`,
|
||||
app_id,
|
||||
ip,
|
||||
client_version,
|
||||
create_time
|
||||
)
|
||||
VALUES (
|
||||
#{clusterId},
|
||||
#{topicName},
|
||||
#{type},
|
||||
#{appId},
|
||||
#{ip},
|
||||
#{clientVersion},
|
||||
#{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="TopicConnectionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_connections
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND create_time >= #{startTime} AND #{endTime} >= create_time
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.util.Map" resultMap="TopicConnectionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_connections
|
||||
WHERE app_id = #{appId}
|
||||
AND create_time >= #{startTime} AND #{endTime} >= create_time
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
64
kafka-manager-dao/src/main/resources/mapper/TopicDao.xml
Normal file
64
kafka-manager-dao/src/main/resources/mapper/TopicDao.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicDao">
|
||||
<resultMap id="TopicMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="peak_bytes_in" property="peakBytesIn" />
|
||||
<result column="description" property="description" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
INSERT INTO topic
|
||||
(cluster_id, topic_name, app_id, peak_bytes_in, description)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{appId}, #{peakBytesIn}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM topic WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.util.Map">
|
||||
DELETE FROM topic WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}
|
||||
</delete>
|
||||
|
||||
<update id="updateByName" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
UPDATE topic SET
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
app_id=#{appId}
|
||||
WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}
|
||||
</update>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</select>
|
||||
|
||||
<select id="getTopic" parameterType="java.util.Map" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId} AND topic_name = #{topicName} and app_id=#{appId}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE app_id = #{appId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="TopicMap">
|
||||
SELECT * FROM topic
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE gmt_modify >= #{afterTime}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicExpiredDao">
|
||||
<resultMap id="TopicExpiredMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="expired_day" property="expiredDay" />
|
||||
<result column="gmt_retain" property="gmtRetain" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO">
|
||||
REPLACE INTO topic_expired(
|
||||
cluster_id, topic_name, expired_day, gmt_retain, status
|
||||
) VALUES (
|
||||
#{clusterId}, #{topicName}, #{expiredDay}, #{gmtRetain}, #{status}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="modifyTopicExpiredTime" parameterType="java.util.Map">
|
||||
UPDATE topic_expired SET gmt_retain=#{gmtRetain} WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</update>
|
||||
|
||||
<select id="listAll" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired
|
||||
</select>
|
||||
|
||||
<select id="getExpiredTopics" parameterType="java.lang.Integer" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired WHERE expired_day >= #{expiredDay} AND now() >= gmt_retain
|
||||
</select>
|
||||
|
||||
<select id="getByTopic" parameterType="java.util.Map" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicMetricsDao">
|
||||
<resultMap id="TopicMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_metrics
|
||||
(cluster_id, topic_name, metrics, gmt_create)
|
||||
VALUES
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getTopicMetrics" parameterType="java.util.Map" resultMap="TopicMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getLatestTopicMetrics" parameterType="java.util.Map" resultMap="TopicMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_metrics
|
||||
WHERE cluster_id = #{clusterId} AND #{afterTime} <= gmt_create
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_metrics WHERE gmt_create < #{endTime} LIMIT 3000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicReportDao">
|
||||
<resultMap id="TopicReportMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicName" column="topic_name" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="modifyTime" column="modify_time" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO">
|
||||
<![CDATA[
|
||||
replace INTO topic_report
|
||||
(cluster_id, topic_name, start_time, end_time)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{startTime}, #{endTime})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByTopicName" parameterType="java.util.Map">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_report WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<select id="getNeedReportTopics" parameterType="java.util.Map" resultMap="TopicReportMap">
|
||||
<![CDATA[
|
||||
SELECT *
|
||||
FROM topic_report
|
||||
WHERE (cluster_id = #{clusterId}
|
||||
AND start_time <= #{now}
|
||||
And end_time >= #{now})
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getTopicReport" parameterType="java.util.Map" resultMap="TopicReportMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_report
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND now() BETWEEN start_time AND end_time
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicRequestMetricsDao">
|
||||
<resultMap id="TopicRequestMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_request_time_metrics
|
||||
(cluster_id, topic_name, metrics, gmt_create)
|
||||
values
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="add" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
INSERT INTO topic_request_time_metrics
|
||||
(id, cluster_id, topic_name, metrics, gmt_create)
|
||||
VALUES
|
||||
(#{id}, #{clusterId}, #{topicName}, #{metrics}, #{gmtCreate})
|
||||
</insert>
|
||||
|
||||
<select id="selectByTime" parameterType="java.util.Map" resultMap="TopicRequestMetricsMap">
|
||||
SELECT * FROM topic_request_time_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
ORDER BY gmt_create ASC
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_request_time_metrics WHERE gmt_create < #{endTime} LIMIT 2000
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBeforeId" parameterType="java.lang.Long">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_request_time_metrics WHERE id < #{id} LIMIT 20000
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<select id="getById" parameterType="java.util.Map" resultMap="TopicRequestMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_request_time_metrics WHERE id >= #{startId} AND id < #{endId}
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicStatisticsDao">
|
||||
<resultMap id="TopicStatisticsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicStatisticsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="offset_sum" property="offsetSum" />
|
||||
<result column="max_avg_bytes_in" property="maxAvgBytesIn" />
|
||||
<result column="gmt_day" property="gmtDay" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicStatisticsDO">
|
||||
REPLACE INTO topic_statistics
|
||||
(cluster_id, topic_name, offset_sum, max_avg_bytes_in, gmt_day)
|
||||
values
|
||||
(#{clusterId}, #{topicName}, #{offsetSum}, #{maxAvgBytesIn}, #{gmtDay})
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicAndDay" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_day=#{gmtDay}
|
||||
</select>
|
||||
|
||||
<select id="getTopicStatistic" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime}>=gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getTopicStatisticData" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND gmt_create>#{startTime}
|
||||
AND max_avg_bytes_in>#{minMaxAvgBytesIn}
|
||||
</select>
|
||||
|
||||
<select id="getTopicMaxAvgBytesIn" parameterType="java.util.Map" resultType="java.lang.Double">
|
||||
SELECT
|
||||
AVG(TEMP.max_avg_bytes_in) AS max_avg_bytes_in
|
||||
FROM (
|
||||
SELECT
|
||||
max_avg_bytes_in
|
||||
FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime}>=gmt_create
|
||||
limit #{maxAvgDay}
|
||||
)AS TEMP;
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_statistics WHERE gmt_create < #{endTime} LIMIT 2000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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">
|
||||
<mapper namespace="TopicThrottledMetricsDao">
|
||||
<resultMap id="TopicThrottledMetricsDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicThrottledMetricsDO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="cluster_id" property="clusterId"/>
|
||||
<result column="topic_name" property="topicName"/>
|
||||
<result column="app_id" property="appId"/>
|
||||
<result column="produce_throttled" property="produceThrottled"/>
|
||||
<result column="fetch_throttled" property="fetchThrottled"/>
|
||||
<result column="gmt_create" property="gmtCreate"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTopicThrottle" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT *
|
||||
FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="getAppIdThrottle" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT *
|
||||
FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO topic_throttled_metrics(
|
||||
cluster_id,
|
||||
topic_name,
|
||||
app_id,
|
||||
produce_throttled,
|
||||
fetch_throttled
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="topicThrottledMetricsDO" index="index" separator=",">(
|
||||
#{topicThrottledMetricsDO.clusterId},
|
||||
#{topicThrottledMetricsDO.topicName},
|
||||
#{topicThrottledMetricsDO.appId},
|
||||
#{topicThrottledMetricsDO.produceThrottled},
|
||||
#{topicThrottledMetricsDO.fetchThrottled}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getLatestTopicThrottledMetrics" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT * FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND gmt_create > #{afterTime}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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">
|
||||
<mapper namespace="DeprecatedKafkaAclDao">
|
||||
<resultMap id="DeprecatedKafkaAclMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaAclDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
|
||||
<result column="access" jdbcType="INTEGER" property="access" />
|
||||
<result column="operation" jdbcType="INTEGER" property="operation" />
|
||||
<result column="gm_create" jdbcType="TIMESTAMP" property="gmCreate" />
|
||||
<result column="gm_modify" jdbcType="TIMESTAMP" property="gmModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaAclDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO kafka_acl
|
||||
(cluster_id, topic_name, user_name, access, operation, gm_create, gm_modify)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{userName}, #{access}, #{operation}, #{gmCreate}, #{gmModify})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="DeprecatedKafkaAclMap">
|
||||
SELECT * FROM kafka_acl ORDER BY gm_create ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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">
|
||||
<mapper namespace="DeprecatedKafkaUserDao">
|
||||
<resultMap id="DeprecatedKafkaUserDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaUserDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="password" column="password"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="operation" column="operation"/>
|
||||
<result property="gmtCreate" column="gm_create"/>
|
||||
<result property="gmtModify" column="gm_modify"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaUserDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO kafka_user
|
||||
(`name`, password, user_type, operation, gm_create, gm_modify)
|
||||
VALUES
|
||||
(#{name}, #{password}, #{userType}, #{operation}, #{gmtCreate}, #{gmtModify})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="DeprecatedKafkaUserDOMap">
|
||||
SELECT * FROM kafka_user
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
18
kafka-manager-dao/src/main/resources/mybatis-config.xml
Normal file
18
kafka-manager-dao/src/main/resources/mybatis-config.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<settings>
|
||||
<setting name="mapUnderscoreToCamelCase" value="true" />
|
||||
|
||||
<setting name="vfsImpl" value="com.xiaojukeji.kafka.manager.vfs.SpringBootVFS" />
|
||||
|
||||
<setting name="lazyLoadingEnabled" value="true" />
|
||||
<setting name="aggressiveLazyLoading" value="false" />
|
||||
</settings>
|
||||
|
||||
<typeAliases>
|
||||
<package name="com.xiaojukeji.kafka.manager.common.entity.pojo"/>
|
||||
</typeAliases>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user