mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-04 11:52:07 +08:00
增加Topic同步任务&Bug修复
This commit is contained in:
@@ -22,4 +22,6 @@ public interface TopicDao {
|
||||
List<TopicDO> listAll();
|
||||
|
||||
TopicDO getTopic(Long clusterId, String topicName, String appId);
|
||||
|
||||
TopicDO removeTopicInCache(Long clusterId, String topicName);
|
||||
}
|
||||
@@ -37,4 +37,8 @@ public interface AuthorityDao {
|
||||
List<AuthorityDO> listAll();
|
||||
|
||||
Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority();
|
||||
|
||||
void removeAuthorityInCache(Long clusterId, String topicName);
|
||||
|
||||
int deleteAuthorityByTopic(Long clusterId, String topicName);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,4 +13,14 @@ public interface GatewayConfigDao {
|
||||
List<GatewayConfigDO> getByConfigType(String configType);
|
||||
|
||||
GatewayConfigDO getByConfigTypeAndName(String configType, String configName);
|
||||
|
||||
List<GatewayConfigDO> list();
|
||||
|
||||
int insert(GatewayConfigDO gatewayConfigDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(GatewayConfigDO gatewayConfigDO);
|
||||
|
||||
GatewayConfigDO getById(Long id);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AuthorityDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -86,6 +87,32 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
return AUTHORITY_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAuthorityInCache(Long clusterId, String topicName) {
|
||||
AUTHORITY_MAP.forEach((appId, map) -> {
|
||||
map.forEach((id, subMap) -> {
|
||||
if (id.equals(clusterId)) {
|
||||
subMap.remove(topicName);
|
||||
if (subMap.isEmpty()) {
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (map.isEmpty()) {
|
||||
AUTHORITY_MAP.remove(appId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAuthorityByTopic(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
return sqlSession.delete("AuthorityDao.deleteByTopic", params);
|
||||
}
|
||||
|
||||
|
||||
private void updateAuthorityCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -35,4 +35,29 @@ public class GatewayConfigDaoImpl implements GatewayConfigDao {
|
||||
params.put("configName", configName);
|
||||
return sqlSession.selectOne("GatewayConfigDao.getByConfigTypeAndName", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GatewayConfigDO> list() {
|
||||
return sqlSession.selectList("GatewayConfigDao.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(GatewayConfigDO gatewayConfigDO) {
|
||||
return sqlSession.insert("GatewayConfigDao.insert", gatewayConfigDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("GatewayConfigDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(GatewayConfigDO gatewayConfigDO) {
|
||||
return sqlSession.update("GatewayConfigDao.updateById", gatewayConfigDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayConfigDO getById(Long id) {
|
||||
return sqlSession.selectOne("GatewayConfigDao.getById", id);
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,11 @@ public class TopicDaoImpl implements TopicDao {
|
||||
return sqlSession.selectOne("TopicDao.getTopic", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicDO removeTopicInCache(Long clusterId, String topicName) {
|
||||
return TOPIC_MAP.getOrDefault(clusterId, new HashMap<>(0)).remove(topicName);
|
||||
}
|
||||
|
||||
private void updateTopicCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -45,4 +45,9 @@
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority WHERE modify_time >= #{afterTime}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByTopic" parameterType="java.util.Map">
|
||||
DELETE FROM authority WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -19,4 +19,38 @@
|
||||
<select id="getByConfigTypeAndName" parameterType="java.util.Map" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE `type`=#{configType} AND `name`=#{configName}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||
<![CDATA[
|
||||
INSERT INTO gateway_config
|
||||
(`type`, name, value, version)
|
||||
VALUES
|
||||
(#{type}, #{name}, #{value}, #{version})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
<![CDATA[
|
||||
DELETE FROM gateway_config WHERE id=#{id}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||
<![CDATA[
|
||||
UPDATE gateway_config SET
|
||||
`type`=#{type},
|
||||
`name`=#{name},
|
||||
`value`=#{value},
|
||||
`version`=#{version}
|
||||
WHERE id=#{id}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user