This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push: new fc49533 CLOUDSTACK-9986: Use host table to iterate for zone/cluster metrics (#2353) fc49533 is described below commit fc49533a8e3b52d1be296022832231ad22e40bd0 Author: Rohit Yadav <ro...@apache.org> AuthorDate: Fri Dec 15 17:17:17 2017 +0530 CLOUDSTACK-9986: Use host table to iterate for zone/cluster metrics (#2353) The host_view may contain duplicate entries when hosts have tags. Changing the host_view may cause unseen regressions so to fix the issues we've modified the zone/cluster metrics code to use the `host` table (hostdao) to iterate through the list of hosts in a cluster during zone/cluster metrics listing. Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> --- .../apache/cloudstack/metrics/MetricsServiceImpl.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java b/plugins/metrics/src/org/apache/cloudstack/metrics/MetricsServiceImpl.java index 981e652..8b76a17 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 class MetricsServiceImpl extends ComponentLifecycleBase implements Metric 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 class MetricsServiceImpl extends ComponentLifecycleBase implements Metric 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())); } } -- To stop receiving notification emails like this one, please contact ['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].