phsm commented on code in PR #10613:
URL: https://github.com/apache/cloudstack/pull/10613#discussion_r2011519630


##########
plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java:
##########
@@ -764,14 +757,13 @@ public List<ClusterMetricsResponse> 
listClusterMetrics(Pair<List<ClusterResponse
             if (AllowListMetricsComputation.value()) {
                 List<Ternary<Long, Long, Long>> cpuList = new ArrayList<>();
                 List<Ternary<Long, Long, Long>> memoryList = new ArrayList<>();
-                for (final Host host : hostDao.findByClusterId(clusterId)) {
-                    if (host == null || host.getType() != Host.Type.Routing) {
+                for (final HostJoinVO host : 
hostJoinDao.findByClusterId(clusterId, Host.Type.Routing)) {
+                    if (host == null) {

Review Comment:
   The null-check was already there, so I preserved it. But  I guess you're 
right, as the search criteria specifies the host type, cluster id etc. I don't 
think there will be a null host that has non-null type and clusterid.
   
   Updated the commit with the removed null-check.



##########
plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java:
##########
@@ -950,11 +942,11 @@ public List<ZoneMetricsResponse> 
listZoneMetrics(List<ZoneResponse> zoneResponse
                     if (cluster == null) {
                         continue;
                     }
-                    for (final Host host: 
hostDao.findByClusterId(cluster.getId())) {
-                        if (host == null || host.getType() != 
Host.Type.Routing) {
+                    for (final HostJoinVO host: 
hostJoinDao.findByClusterId(cluster.getId(), Host.Type.Routing)) {
+                        if (host == null) {

Review Comment:
   Updated the commit with the removed null-check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to