mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 03:42: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) {
|
||||
List<ConnectorPO> connectorPOS = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
|
||||
List<ConnectorPO> poList = connectorService.listByKafkaClusterIdFromDB(clusterPhyId);
|
||||
|
||||
if (CollectionUtils.isEmpty(connectorPOS)) {
|
||||
if (CollectionUtils.isEmpty(poList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return connectorPOS.subList(0, Math.min(topN, connectorPOS.size()))
|
||||
return poList.subList(0, Math.min(topN, poList.size()))
|
||||
.stream()
|
||||
.map( c -> new Tuple<>(c.getId(), c.getConnectorName()) )
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -185,7 +185,7 @@ public class TopicMetricServiceImpl extends BaseMetricService implements TopicMe
|
||||
Table<String/*metric*/, String/*topics*/, List<MetricPointVO>> retTable;
|
||||
if(CollectionUtils.isEmpty(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 );
|
||||
}else {
|
||||
retTable = topicMetricESDAO.listTopicMetricsByTopics(clusterId, metrics, aggType, topics, startTime, endTime);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ClusterConnectsController {
|
||||
@PostMapping(value = "clusters/{clusterPhyId}/connectors-metrics")
|
||||
@ResponseBody
|
||||
public Result<List<MetricMultiLinesVO>> getClusterPhyMetrics(@PathVariable Long clusterPhyId,
|
||||
@Validated @RequestBody MetricsConnectorsDTO dto) {
|
||||
@Validated @RequestBody MetricsConnectorsDTO dto) {
|
||||
return connectorMetricService.listConnectClusterMetricsFromES(clusterPhyId, dto);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user