|
| 1 | +diff --git a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java |
| 2 | +index 6025a41d69..e73587306e 100644 |
| 3 | +--- a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java |
| 4 | ++++ b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java |
| 5 | +@@ -768,19 +768,15 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements |
| 6 | + List<Ternary<Long, Long, Long>> cpuList = new ArrayList<>(); |
| 7 | + List<Ternary<Long, Long, Long>> memoryList = new ArrayList<>(); |
| 8 | + |
| 9 | +- for (final Host host: hostDao.findByClusterId(clusterId)) { |
| 10 | +- if (host == null || host.getType() != Host.Type.Routing) { |
| 11 | +- continue; |
| 12 | +- } |
| 13 | ++ for (final HostJoinVO host: hostJoinDao.findByClusterId(clusterId, Host.Type.Routing)) { |
| 14 | + if (host.getStatus() == Status.Up) { |
| 15 | + hostMetrics.incrUpResources(); |
| 16 | + } |
| 17 | + hostMetrics.incrTotalResources(); |
| 18 | +- HostJoinVO hostJoin = hostJoinDao.findById(host.getId()); |
| 19 | +- updateHostMetrics(hostMetrics, hostJoin); |
| 20 | ++ updateHostMetrics(hostMetrics, host); |
| 21 | + |
| 22 | +- cpuList.add(new Ternary<>(hostJoin.getCpuUsedCapacity(), hostJoin.getCpuReservedCapacity(), hostJoin.getCpus() * hostJoin.getSpeed())); |
| 23 | +- memoryList.add(new Ternary<>(hostJoin.getMemUsedCapacity(), hostJoin.getMemReservedCapacity(), hostJoin.getTotalMemory())); |
| 24 | ++ cpuList.add(new Ternary<>(host.getCpuUsedCapacity(), host.getCpuReservedCapacity(), host.getCpus() * host.getSpeed())); |
| 25 | ++ memoryList.add(new Ternary<>(host.getMemUsedCapacity(), host.getMemReservedCapacity(), host.getTotalMemory())); |
| 26 | + } |
| 27 | + |
| 28 | + try { |
| 29 | +@@ -953,10 +949,7 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements |
| 30 | + hostMetrics.incrUpResources(); |
| 31 | + } |
| 32 | + |
| 33 | +- for (final Host host: hostDao.findByClusterId(cluster.getId())) { |
| 34 | +- if (host == null || host.getType() != Host.Type.Routing) { |
| 35 | +- continue; |
| 36 | +- } |
| 37 | ++ for (final HostJoinVO host: hostJoinDao.findByClusterId(cluster.getId(), Host.Type.Routing)) { |
| 38 | + updateHostMetrics(hostMetrics, hostJoinDao.findById(host.getId())); |
| 39 | + } |
| 40 | + } |
0 commit comments