mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-02 02:02:13 +08:00
init
This commit is contained in:
40
dao/src/main/resources/mapper/AccountDao.xml
Normal file
40
dao/src/main/resources/mapper/AccountDao.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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="AccountDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="username" column="username" />
|
||||
<result property="password" column="password" />
|
||||
<result property="role" column="role" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.AccountDO">
|
||||
<![CDATA[
|
||||
REPLACE account
|
||||
(username, password, role, status)
|
||||
VALUES
|
||||
(#{username}, #{password}, #{role}, #{status})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.lang.String">
|
||||
DELETE FROM account WHERE username = #{username}
|
||||
</delete>
|
||||
|
||||
<select id="getByName" parameterType="java.lang.String" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE username = #{username} AND status=0
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE status = 0
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
57
dao/src/main/resources/mapper/AlarmRuleDao.xml
Normal file
57
dao/src/main/resources/mapper/AlarmRuleDao.xml
Normal file
@@ -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="AlarmRuleDao">
|
||||
<resultMap id="AlarmRuleMap" type="AlarmRuleDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<id column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
<result column="alarm_name" jdbcType="VARCHAR" property="alarmName" />
|
||||
<result column="strategy_expressions" jdbcType="VARCHAR" property="strategyExpressions" />
|
||||
<result column="strategy_filters" jdbcType="VARCHAR" property="strategyFilters" />
|
||||
<result column="strategy_actions" jdbcType="VARCHAR" property="strategyActions" />
|
||||
<result column="principals" jdbcType="VARCHAR" property="principals" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.AlarmRuleDO">
|
||||
<![CDATA[
|
||||
INSERT INTO alarm_rule
|
||||
(alarm_name, strategy_expressions, strategy_filters, strategy_actions, principals)
|
||||
VALUES (
|
||||
#{alarmName}, #{strategyExpressions}, #{strategyFilters}, #{strategyActions}, #{principals})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
<![CDATA[
|
||||
DELETE FROM alarm_rule WHERE id = #{id}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.AlarmRuleDO">
|
||||
<![CDATA[
|
||||
UPDATE alarm_rule SET
|
||||
alarm_name=#{alarmName},
|
||||
strategy_expressions=#{strategyExpressions},
|
||||
strategy_filters=#{strategyFilters},
|
||||
strategy_actions=#{strategyActions},
|
||||
principals=#{principals},
|
||||
status=#{status}
|
||||
WHERE id = #{id}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<select id="getByOption" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.query.AlarmRuleQueryOption" resultMap="AlarmRuleMap">
|
||||
SELECT * FROM alarm_rule where status >= 0
|
||||
<trim>
|
||||
<if test="id != null">
|
||||
AND id=#{id}
|
||||
</if>
|
||||
<if test="alarmName != null">
|
||||
AND alarm_name=#{alarmName}
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
30
dao/src/main/resources/mapper/BrokerDao.xml
Normal file
30
dao/src/main/resources/mapper/BrokerDao.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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="BrokerDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="broker_id" jdbcType="BIGINT" property="brokerId" />
|
||||
<result column="host" jdbcType="VARCHAR" property="host" />
|
||||
<result column="port" jdbcType="INTEGER" property="port" />
|
||||
<result column="timestamp" jdbcType="BIGINT" property="timestamp" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="BrokerDO">
|
||||
REPLACE broker
|
||||
(cluster_id, broker_id, host, port, timestamp, status)
|
||||
VALUES
|
||||
(#{clusterId}, #{brokerId}, #{host}, #{port}, #{timestamp}, #{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>
|
||||
</mapper>
|
||||
48
dao/src/main/resources/mapper/BrokerMetricsDao.xml
Normal file
48
dao/src/main/resources/mapper/BrokerMetricsDao.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="BrokerMetricsDao">
|
||||
<resultMap id="BrokerMetricsMap" type="BrokerMetrics">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="brokerId" column="broker_id" />
|
||||
<result property="bytesInPerSec" column="bytes_in" />
|
||||
<result property="bytesOutPerSec" column="bytes_out" />
|
||||
<result property="messagesInPerSec" column="messages_in" />
|
||||
<result property="bytesRejectedPerSec" column="bytes_rejected" />
|
||||
<result property="failFetchRequestPerSec" column="fail_fetch_request" />
|
||||
<result property="failProduceRequestPerSec" column="fail_produce_request" />
|
||||
<result property="fetchConsumerRequestPerSec" column="fetch_consumer_request" />
|
||||
<result property="produceRequestPerSec" column="produce_request" />
|
||||
<result property="requestHandlerAvgIdlePercent" column="request_handler_idl_percent" />
|
||||
<result property="networkProcessorAvgIdlePercent" column="network_processor_idl_percent" />
|
||||
<result property="requestQueueSize" column="request_queue_size" />
|
||||
<result property="responseQueueSize" column="response_queue_size" />
|
||||
<result property="logFlushRateAndTimeMs" column="log_flush_time" />
|
||||
<result property="totalTimeProduceMean" column="total_time_produce_mean" />
|
||||
<result property="totalTimeProduce99Th" column="total_time_produce_99th" />
|
||||
<result property="totalTimeFetchConsumerMean" column="total_time_fetch_consumer_mean" />
|
||||
<result property="totalTimeFetchConsumer99Th" column="total_time_fetch_consumer_99th" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO broker_metrics (cluster_id, broker_id, bytes_in, bytes_out, messages_in, bytes_rejected, fail_fetch_request, fail_produce_request, fetch_consumer_request, produce_request, request_handler_idl_percent, network_processor_idl_percent, request_queue_size, response_queue_size, log_flush_time, total_time_produce_mean, total_time_produce_99th, total_time_fetch_consumer_mean, total_time_fetch_consumer_99th, gmt_create)
|
||||
VALUES
|
||||
<foreach item="BrokerMetrics" index="index" collection="list" separator=",">
|
||||
(#{BrokerMetrics.clusterId}, #{BrokerMetrics.brokerId}, #{BrokerMetrics.bytesInPerSec}, #{BrokerMetrics.bytesOutPerSec}, #{BrokerMetrics.messagesInPerSec}, #{BrokerMetrics.bytesRejectedPerSec}, #{BrokerMetrics.failFetchRequestPerSec}, #{BrokerMetrics.failProduceRequestPerSec}, #{BrokerMetrics.fetchConsumerRequestPerSec}, #{BrokerMetrics.produceRequestPerSec}, #{BrokerMetrics.requestHandlerAvgIdlePercent}, #{BrokerMetrics.networkProcessorAvgIdlePercent}, #{BrokerMetrics.requestQueueSize}, #{BrokerMetrics.responseQueueSize}, #{BrokerMetrics.logFlushRateAndTimeMs}, #{BrokerMetrics.totalTimeProduceMean}, #{BrokerMetrics.totalTimeProduce99Th}, #{BrokerMetrics.totalTimeFetchConsumerMean}, #{BrokerMetrics.totalTimeFetchConsumer99Th}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getBrokerMetricsByInterval" 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>
|
||||
59
dao/src/main/resources/mapper/ClusterDao.xml
Normal file
59
dao/src/main/resources/mapper/ClusterDao.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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="ClusterDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<id column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
|
||||
<result column="cluster_name" jdbcType="VARCHAR" property="clusterName" />
|
||||
<result column="zookeeper" jdbcType="VARCHAR" property="zookeeper" />
|
||||
<result column="bootstrap_servers" jdbcType="VARCHAR" property="bootstrapServers" />
|
||||
<result column="kafka_version" jdbcType="VARCHAR" property="kafkaVersion" />
|
||||
<result column="alarm_flag" jdbcType="INTEGER" property="alarmFlag" />
|
||||
<result column="security_protocol" jdbcType="VARCHAR" property="securityProtocol" />
|
||||
<result column="sasl_mechanism" jdbcType="VARCHAR" property="saslMechanism" />
|
||||
<result column="sasl_jaas_config" jdbcType="VARCHAR" property="saslJaasConfig" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.ClusterDO" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO cluster (
|
||||
cluster_name, zookeeper, bootstrap_servers, kafka_version, alarm_flag,
|
||||
security_protocol, sasl_mechanism, sasl_jaas_config
|
||||
) VALUES (
|
||||
#{clusterName}, #{zookeeper}, #{bootstrapServers}, #{kafkaVersion}, #{alarmFlag},
|
||||
#{securityProtocol}, #{saslMechanism}, #{saslJaasConfig}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM cluster id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.ClusterDO">
|
||||
UPDATE cluster SET
|
||||
cluster_name=#{clusterName},
|
||||
zookeeper=#{zookeeper},
|
||||
bootstrap_servers=#{bootstrapServers},
|
||||
kafka_version=#{kafkaVersion},
|
||||
alarm_flag=#{alarmFlag},
|
||||
security_protocol=#{securityProtocol},
|
||||
sasl_mechanism=#{saslMechanism},
|
||||
sasl_jaas_config=#{saslJaasConfig}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getByOption" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.query.ClusterQueryOption" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster where status >= 0
|
||||
<trim>
|
||||
<if test="id != null">
|
||||
AND id=#{id}
|
||||
</if>
|
||||
<if test="clusterName != null">
|
||||
AND cluster_name=#{clusterName}
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
</mapper>
|
||||
37
dao/src/main/resources/mapper/ClusterMetricsDao.xml
Normal file
37
dao/src/main/resources/mapper/ClusterMetricsDao.xml
Normal file
@@ -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="ClusterMetricsDao">
|
||||
<resultMap id="ClusterMetricsMap" type="ClusterMetricsDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicNum" column="topic_num" />
|
||||
<result property="partitionNum" column="partition_num" />
|
||||
<result property="brokerNum" column="broker_num" />
|
||||
<result property="bytesInPerSec" column="bytes_in" />
|
||||
<result property="bytesOutPerSec" column="bytes_out" />
|
||||
<result property="bytesRejectedPerSec" column="bytes_rejected" />
|
||||
<result property="messagesInPerSec" column="messages_in" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getClusterMetricsByInterval" 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, topic_num, partition_num, broker_num, bytes_in, bytes_out, bytes_rejected, messages_in, gmt_create)
|
||||
VALUES
|
||||
<foreach item="ClusterMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{ClusterMetricsDO.clusterId}, #{ClusterMetricsDO.topicNum}, #{ClusterMetricsDO.partitionNum}, #{ClusterMetricsDO.brokerNum}, #{ClusterMetricsDO.bytesInPerSec}, #{ClusterMetricsDO.bytesOutPerSec}, #{ClusterMetricsDO.bytesRejectedPerSec}, #{ClusterMetricsDO.messagesInPerSec}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM cluster_metrics WHERE gmt_create < #{endTime} LIMIT 100
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
28
dao/src/main/resources/mapper/ControllerDao.xml
Normal file
28
dao/src/main/resources/mapper/ControllerDao.xml
Normal file
@@ -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="ControllerDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="broker_id" jdbcType="INTEGER" property="brokerId" />
|
||||
<result column="host" jdbcType="VARCHAR" property="host" />
|
||||
<result column="timestamp" jdbcType="BIGINT" property="timestamp" />
|
||||
<result column="version" jdbcType="INTEGER" property="version" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.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>
|
||||
46
dao/src/main/resources/mapper/MigrationTaskDao.xml
Normal file
46
dao/src/main/resources/mapper/MigrationTaskDao.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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="MigrationTaskDao">
|
||||
<resultMap id="MigrationTaskDOMap" type="MigrationTaskDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicName" column="topic_name" />
|
||||
<result property="reassignmentJson" column="reassignment_json" />
|
||||
<result property="throttle" column="real_throttle" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="addMigrationTask" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.MigrationTaskDO">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
<![CDATA[
|
||||
INSERT INTO migration_task
|
||||
(cluster_id, topic_name, reassignment_json, real_throttle, operator, description, status)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{reassignmentJson}, #{throttle}, #{operator}, #{description}, #{status})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="MigrationTaskDOMap">
|
||||
SELECT * FROM migration_task WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="MigrationTaskDOMap">
|
||||
SELECT * FROM migration_task ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<select id="getByStatus" parameterType="java.lang.Integer" resultMap="MigrationTaskDOMap">
|
||||
SELECT * FROM migration_task WHERE status=#{status}
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="java.util.Map">
|
||||
UPDATE migration_task
|
||||
SET
|
||||
real_throttle=#{throttle},
|
||||
status=#{status}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
</mapper>
|
||||
21
dao/src/main/resources/mapper/OperationHistoryDao.xml
Normal file
21
dao/src/main/resources/mapper/OperationHistoryDao.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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="OperationHistoryDao">
|
||||
<resultMap id="OperationHistoryMap" type="OperationHistoryDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="operation" property="operation" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.OperationHistoryDO">
|
||||
INSERT INTO operation_history (
|
||||
cluster_id, topic_name, operator, operation)
|
||||
VALUES (
|
||||
#{clusterId}, #{topicName}, #{operator}, #{operation}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
56
dao/src/main/resources/mapper/OrderPartitionDao.xml
Normal file
56
dao/src/main/resources/mapper/OrderPartitionDao.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="OrderPartitionDao">
|
||||
<resultMap id="OrderPartitionMap" type="OrderPartitionDO">
|
||||
<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_id" property="clusterId" />
|
||||
<result column="cluster_name" property="clusterName" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="applicant" property="applicant" />
|
||||
<result column="peak_bytes_in" property="peakBytesIn" />
|
||||
<result column="description" property="description" />
|
||||
<result column="order_status" property="orderStatus" />
|
||||
<result column="approver" property="approver" />
|
||||
<result column="opinion" property="opinion" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.OrderPartitionDO">
|
||||
INSERT INTO order_partition (
|
||||
cluster_id, cluster_name, topic_name, applicant,
|
||||
peak_bytes_in, description, order_status)
|
||||
VALUES (
|
||||
#{clusterId}, #{clusterName}, #{topicName}, #{applicant},
|
||||
#{peakBytesIn}, #{description}, #{orderStatus}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM order_partition WHERE id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.OrderPartitionDO">
|
||||
UPDATE order_partition SET
|
||||
cluster_id=#{clusterId},
|
||||
cluster_name=#{clusterName},
|
||||
topic_name=#{topicName},
|
||||
applicant=#{applicant},
|
||||
peak_bytes_in=#{peakBytesIn},
|
||||
description=#{description},
|
||||
order_status=#{orderStatus},
|
||||
approver=#{approver},
|
||||
opinion=#{opinion}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="OrderPartitionMap">
|
||||
SELECT * FROM order_partition WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="OrderPartitionMap">
|
||||
SELECT * FROM order_partition ORDER BY gmt_create DESC
|
||||
</select>
|
||||
</mapper>
|
||||
75
dao/src/main/resources/mapper/OrderTopicDao.xml
Normal file
75
dao/src/main/resources/mapper/OrderTopicDao.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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="OrderTopicDao">
|
||||
<resultMap id="OrderTopicMap" type="OrderTopicDO">
|
||||
<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_id" property="clusterId" />
|
||||
<result column="cluster_name" property="clusterName" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="retention_time" property="retentionTime" />
|
||||
<result column="partition_num" property="partitionNum" />
|
||||
<result column="replica_num" property="replicaNum" />
|
||||
<result column="regions" property="regions" />
|
||||
<result column="brokers" property="brokers" />
|
||||
<result column="applicant" property="applicant" />
|
||||
<result column="principals" property="principals" />
|
||||
<result column="peak_bytes_in" property="peakBytesIn" />
|
||||
<result column="description" property="description" />
|
||||
<result column="order_status" property="orderStatus" />
|
||||
<result column="approver" property="approver" />
|
||||
<result column="opinion" property="opinion" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.OrderTopicDO">
|
||||
INSERT INTO order_topic (
|
||||
cluster_id, cluster_name, topic_name,
|
||||
retention_time, partition_num, replica_num,
|
||||
applicant, peak_bytes_in, description, principals
|
||||
)
|
||||
VALUES (
|
||||
#{clusterId}, #{clusterName}, #{topicName},
|
||||
#{retentionTime}, #{partitionNum}, #{replicaNum},
|
||||
#{applicant}, #{peakBytesIn}, #{description}, #{principals}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM order_topic WHERE id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.OrderTopicDO">
|
||||
UPDATE order_topic SET
|
||||
cluster_id=#{clusterId},
|
||||
cluster_name=#{clusterName},
|
||||
topic_name=#{topicName},
|
||||
retention_time=#{retentionTime},
|
||||
partition_num=#{partitionNum},
|
||||
replica_num=#{replicaNum},
|
||||
regions=#{regions},
|
||||
brokers=#{brokers},
|
||||
applicant=#{applicant},
|
||||
principals=#{principals},
|
||||
peak_bytes_in=#{peakBytesIn},
|
||||
description=#{description},
|
||||
order_status=#{orderStatus},
|
||||
approver=#{approver},
|
||||
opinion=#{opinion}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="OrderTopicMap">
|
||||
SELECT * FROM order_topic WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="OrderTopicMap">
|
||||
SELECT * FROM order_topic ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<select id="getByUsername" parameterType="java.lang.String" resultMap="OrderTopicMap">
|
||||
SELECT * FROM order_topic WHERE applicant=#{username} ORDER BY gmt_create DESC
|
||||
</select>
|
||||
</mapper>
|
||||
51
dao/src/main/resources/mapper/RegionDao.xml
Normal file
51
dao/src/main/resources/mapper/RegionDao.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="RegionDao">
|
||||
<resultMap id="RegionMap" type="RegionDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="region_name" jdbcType="VARCHAR" property="regionName" />
|
||||
<result column="broker_list" jdbcType="VARCHAR" property="brokerList" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="operator" jdbcType="VARCHAR" property="operator" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.RegionDO">
|
||||
REPLACE region
|
||||
(region_name, cluster_id, broker_list, description, operator)
|
||||
VALUES
|
||||
(#{regionName}, #{clusterId}, #{brokerList}, #{description}, #{operator})
|
||||
</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.po.RegionDO">
|
||||
UPDATE region SET
|
||||
region_name=#{regionName},
|
||||
cluster_id=#{clusterId},
|
||||
broker_list=#{brokerList},
|
||||
description=#{description},
|
||||
operator=#{operator},
|
||||
status=#{status},
|
||||
level=#{level}
|
||||
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">
|
||||
SELECT * FROM region
|
||||
</select>
|
||||
</mapper>
|
||||
41
dao/src/main/resources/mapper/TopicDao.xml
Normal file
41
dao/src/main/resources/mapper/TopicDao.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="TopicDao">
|
||||
<resultMap id="TopicMap" type="TopicDO">
|
||||
<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="principals" jdbcType="VARCHAR" property="principals" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.po.TopicDO">
|
||||
REPLACE topic
|
||||
(cluster_id, topic_name, principals, description, status)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{principals}, #{description}, #{status})
|
||||
</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>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="TopicMap">
|
||||
SELECT * FROM topic
|
||||
</select>
|
||||
</mapper>
|
||||
35
dao/src/main/resources/mapper/TopicFavoriteDao.xml
Normal file
35
dao/src/main/resources/mapper/TopicFavoriteDao.xml
Normal file
@@ -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="TopicFavoriteDao">
|
||||
<resultMap id="TopicFavoriteMap" type="TopicFavoriteDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
|
||||
<result column="username" jdbcType="VARCHAR" property="username" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
REPLACE topic_favorite (cluster_id, topic_name, username)
|
||||
VALUES
|
||||
<foreach item="TopicFavoriteDO" index="index" collection="list" separator=",">
|
||||
(#{TopicFavoriteDO.clusterId}, #{TopicFavoriteDO.topicName}, #{TopicFavoriteDO.username})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM topic_favorite WHERE id=#{id}
|
||||
</delete>
|
||||
|
||||
<select id="getByUserName" parameterType="java.lang.String" resultMap="TopicFavoriteMap">
|
||||
SELECT * FROM topic_favorite WHERE username=#{username}
|
||||
</select>
|
||||
|
||||
<select id="getByUserNameAndClusterId" parameterType="java.util.Map" resultMap="TopicFavoriteMap">
|
||||
SELECT * FROM topic_favorite WHERE username=#{username} AND cluster_id=#{clusterId}
|
||||
</select>
|
||||
</mapper>
|
||||
37
dao/src/main/resources/mapper/TopicMetricsDao.xml
Normal file
37
dao/src/main/resources/mapper/TopicMetricsDao.xml
Normal file
@@ -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="TopicMetricsDao">
|
||||
<resultMap id="TopicMetricsMap" type="TopicMetrics">
|
||||
<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="bytes_in" jdbcType="DOUBLE" property="bytesInPerSec" />
|
||||
<result column="bytes_out" jdbcType="DOUBLE" property="bytesOutPerSec" />
|
||||
<result column="messages_in" jdbcType="DOUBLE" property="messagesInPerSec" />
|
||||
<result column="bytes_rejected" jdbcType="DOUBLE" property="bytesRejectedPerSec" />
|
||||
<result column="total_produce_requests" jdbcType="DOUBLE" property="totalProduceRequestsPerSec" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_metrics
|
||||
(cluster_id, topic_name, messages_in, bytes_in, bytes_out, bytes_rejected, total_produce_requests, gmt_create)
|
||||
values
|
||||
<foreach item="TopicMetrics" index="index" collection="list" separator=",">
|
||||
(#{TopicMetrics.clusterId}, #{TopicMetrics.topicName}, #{TopicMetrics.messagesInPerSec}, #{TopicMetrics.bytesInPerSec}, #{TopicMetrics.bytesOutPerSec}, #{TopicMetrics.bytesRejectedPerSec}, #{TopicMetrics.totalProduceRequestsPerSec}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getTopicMetricsByInterval" 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>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_metrics WHERE gmt_create < #{endTime} LIMIT 2000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user