mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-10 00:42:07 +08:00
修复因DB中Broker信息不存在导致TotalLogSize指标获取时抛空指针问题
This commit is contained in:
@@ -751,8 +751,8 @@ public class ClusterMetricServiceImpl extends BaseMetricService implements Clust
|
|||||||
private Result<ClusterMetrics> getMetricFromKafkaByTotalTopics(Long clusterId, String metric, String topicMetric){
|
private Result<ClusterMetrics> getMetricFromKafkaByTotalTopics(Long clusterId, String metric, String topicMetric){
|
||||||
List<Topic> topics = topicService.listTopicsFromCacheFirst(clusterId);
|
List<Topic> topics = topicService.listTopicsFromCacheFirst(clusterId);
|
||||||
|
|
||||||
float metricsSum = 0f;
|
float sumMetricValue = 0f;
|
||||||
for(Topic topic : topics){
|
for(Topic topic : topics) {
|
||||||
Result<List<TopicMetrics>> ret = topicMetricService.collectTopicMetricsFromKafkaWithCacheFirst(
|
Result<List<TopicMetrics>> ret = topicMetricService.collectTopicMetricsFromKafkaWithCacheFirst(
|
||||||
clusterId,
|
clusterId,
|
||||||
topic.getTopicName(),
|
topic.getTopicName(),
|
||||||
@@ -763,14 +763,15 @@ public class ClusterMetricServiceImpl extends BaseMetricService implements Clust
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TopicMetrics> topicMetrics = ret.getData();
|
for (TopicMetrics metrics : ret.getData()) {
|
||||||
for (TopicMetrics metrics : topicMetrics) {
|
if(metrics.isBBrokerAgg()) {
|
||||||
if(metrics.isBBrokerAgg()){
|
Float metricValue = metrics.getMetric(topicMetric);
|
||||||
metricsSum += Double.valueOf(metrics.getMetrics().get(topicMetric));
|
sumMetricValue += (metricValue == null? 0f: metricValue);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.buildSuc(initWithMetrics(clusterId, metric, metricsSum));
|
return Result.buildSuc(initWithMetrics(clusterId, metric, sumMetricValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ public class KafkaJMXClient extends AbstractClusterLoadedChangedHandler {
|
|||||||
lambdaQueryWrapper.eq(BrokerPO::getStatus, Constant.ALIVE);
|
lambdaQueryWrapper.eq(BrokerPO::getStatus, Constant.ALIVE);
|
||||||
|
|
||||||
BrokerPO brokerPO = brokerDAO.selectOne(lambdaQueryWrapper);
|
BrokerPO brokerPO = brokerDAO.selectOne(lambdaQueryWrapper);
|
||||||
|
if (brokerPO == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return Broker.buildFrom(brokerPO);
|
return Broker.buildFrom(brokerPO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user