kcm修复&连接信息接口修复

This commit is contained in:
zengqiao
2020-11-15 16:50:59 +08:00
parent 3ffb4b8990
commit f84d250134
13 changed files with 577 additions and 186 deletions

View File

@@ -311,6 +311,19 @@ public class PhysicalClusterMetadataManager {
return metadataMap.get(brokerId);
}
public static BrokerMetadata getBrokerMetadata(Long clusterId, String hostname) {
Map<Integer, BrokerMetadata> metadataMap = BROKER_METADATA_MAP.get(clusterId);
if (metadataMap == null) {
return null;
}
for (BrokerMetadata brokerMetadata: metadataMap.values()) {
if (brokerMetadata.getHost().equals(hostname)) {
return brokerMetadata;
}
}
return null;
}
public static Map<String, List<String>> getBrokerHostKafkaRoleMap(Long clusterId) {
Map<String, List<String>> hostRoleMap = new HashMap<>();
ControllerData controllerData = CONTROLLER_DATA_MAP.get(clusterId);

View File

@@ -1,7 +1,7 @@
package com.xiaojukeji.kafka.manager.service.service.gateway;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import com.xiaojukeji.kafka.manager.common.entity.dto.gateway.TopicConnectionDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO;
import java.util.Date;
import java.util.List;
@@ -11,7 +11,7 @@ import java.util.List;
* @date 20/4/13
*/
public interface TopicConnectionService {
int batchAdd(List<TopicConnectionDTO> dtoList);
int batchAdd(List<TopicConnectionDO> doList);
/**
* 查询连接信息

View File

@@ -2,7 +2,6 @@ package com.xiaojukeji.kafka.manager.service.service.gateway.impl;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import com.xiaojukeji.kafka.manager.common.entity.dto.gateway.TopicConnectionDTO;
import com.xiaojukeji.kafka.manager.common.constant.KafkaConstant;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.dao.gateway.TopicConnectionDao;
@@ -28,23 +27,16 @@ public class TopicConnectionServiceImpl implements TopicConnectionService {
private TopicConnectionDao topicConnectionDao;
@Override
public int batchAdd(List<TopicConnectionDTO> dtoList) {
if (ValidateUtils.isEmptyList(dtoList)) {
public int batchAdd(List<TopicConnectionDO> doList) {
if (ValidateUtils.isEmptyList(doList)) {
return 0;
}
int count = 0;
for (TopicConnectionDTO dto: dtoList) {
for (TopicConnectionDO connectionDO: doList) {
try {
TopicConnectionDO topicConnectionDO = new TopicConnectionDO();
topicConnectionDO.setClusterId(dto.getClusterId());
topicConnectionDO.setTopicName(dto.getTopicName());
topicConnectionDO.setType(dto.getType());
topicConnectionDO.setAppId(dto.getAppId());
topicConnectionDO.setIp(dto.getIp());
topicConnectionDO.setClientVersion(dto.getClientVersion());
count += topicConnectionDao.replace(topicConnectionDO);
count += topicConnectionDao.replace(connectionDO);
} catch (Exception e) {
LOGGER.error("replace topic connections failed, data:{}.", dto);
LOGGER.error("replace topic connections failed, data:{}.", connectionDO);
}
}
return count;