mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-07 23:28:24 +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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user