mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-04 11:52:07 +08:00
[Optimize]优化Sonar代码扫描结果
This commit is contained in:
@@ -392,13 +392,13 @@ public class ConnectorMetricServiceImpl extends BaseConnectorMetricService imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Tuple<Long, String>> listTopNConnectorList(Long clusterPhyId, Integer topN) {
|
private List<Tuple<Long, String>> listTopNConnectorList(Long clusterPhyId, Integer topN) {
|
||||||
List<ConnectorPO> connectorPOS = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
|
List<ConnectorPO> poList = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(connectorPOS)) {
|
if (CollectionUtils.isEmpty(poList)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectorPOS.subList(0, Math.min(topN, connectorPOS.size()))
|
return poList.subList(0, Math.min(topN, poList.size()))
|
||||||
.stream()
|
.stream()
|
||||||
.map( c -> new Tuple<>(c.getId(), c.getConnectorName()) )
|
.map( c -> new Tuple<>(c.getId(), c.getConnectorName()) )
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class TopicMetricServiceImpl extends BaseMetricService implements TopicMe
|
|||||||
Table<String/*metric*/, String/*topics*/, List<MetricPointVO>> retTable;
|
Table<String/*metric*/, String/*topics*/, List<MetricPointVO>> retTable;
|
||||||
if(CollectionUtils.isEmpty(topics)) {
|
if(CollectionUtils.isEmpty(topics)) {
|
||||||
//如果 es 中获取不到topN的topic就使用从数据库中获取的topics
|
//如果 es 中获取不到topN的topic就使用从数据库中获取的topics
|
||||||
List<String> defaultTopics = listTopNTopics(clusterId, topN);
|
List<String> defaultTopics = this.listTopNTopics(clusterId, topN);
|
||||||
retTable = topicMetricESDAO.listTopicMetricsByTopN(clusterId, defaultTopics, metrics, aggType, topN, startTime, endTime );
|
retTable = topicMetricESDAO.listTopicMetricsByTopN(clusterId, defaultTopics, metrics, aggType, topN, startTime, endTime );
|
||||||
}else {
|
}else {
|
||||||
retTable = topicMetricESDAO.listTopicMetricsByTopics(clusterId, metrics, aggType, topics, startTime, endTime);
|
retTable = topicMetricESDAO.listTopicMetricsByTopics(clusterId, metrics, aggType, topics, startTime, endTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user