[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16292394#comment-16292394
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9986:
--------------------------------------------

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:
us...@infra.apache.org


> Consider overcommit ratios with total/threshold values in Metrics View
> ----------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9986
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9986
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Rohit Yadav
>            Assignee: Rohit Yadav
>             Fix For: Future, 4.9.3.0
>
>
> On code analysis and discussions, I found that overcommit ratios are used 
> with the allocated values, instead they should be used/compared with the 
> total/threshold values during comparison for determining where the allocated 
> values have gone beyond the thresholds (considering overcommit ratios) or not.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to