rhtyd closed pull request #2353: CLOUDSTACK-9986: Use host table to iterate for 
zone/cluster metrics
URL: https://github.com/apache/cloudstack/pull/2353
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java 
b/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java
index 981e652fb8f..8b76a1770a3 100644
--- a/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java
+++ b/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java
@@ -321,12 +321,15 @@ public InfrastructureResponse listInfrastructure() {
             final CapacityDaoImpl.SummedCapacity memoryCapacity = 
getCapacity((int) Capacity.CAPACITY_TYPE_MEMORY, null, clusterId);
             final Metrics metrics = new Metrics(cpuCapacity, memoryCapacity);
 
-            for (final HostJoinVO host: hostJoinDao.findByClusterId(clusterId, 
Host.Type.Routing)) {
+            for (final Host host: hostDao.findByClusterId(clusterId)) {
+                if (host == null || host.getType() != Host.Type.Routing) {
+                    continue;
+                }
                 if (host.getStatus() == Status.Up) {
                     metrics.incrUpResources();
                 }
                 metrics.incrTotalResources();
-                updateHostMetrics(metrics, host);
+                updateHostMetrics(metrics, hostJoinDao.findById(host.getId()));
             }
 
             metricsResponse.setState(clusterResponse.getAllocationState(), 
clusterResponse.getManagedState());
@@ -391,14 +394,20 @@ public InfrastructureResponse listInfrastructure() {
             final Metrics metrics = new Metrics(cpuCapacity, memoryCapacity);
 
             for (final Cluster cluster : 
clusterDao.listClustersByDcId(zoneId)) {
+                if (cluster == null) {
+                    continue;
+                }
                 metrics.incrTotalResources();
                 if (cluster.getAllocationState() == 
Grouping.AllocationState.Enabled
                         && cluster.getManagedState() == 
Managed.ManagedState.Managed) {
                     metrics.incrUpResources();
                 }
 
-                for (final HostJoinVO host: 
hostJoinDao.findByClusterId(cluster.getId(), Host.Type.Routing)) {
-                    updateHostMetrics(metrics, host);
+                for (final Host host: 
hostDao.findByClusterId(cluster.getId())) {
+                    if (host == null || host.getType() != Host.Type.Routing) {
+                        continue;
+                    }
+                    updateHostMetrics(metrics, 
hostJoinDao.findById(host.getId()));
                 }
             }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to