@@ -188,13 +188,6 @@ protected MetricsServiceImpl() {
188188 super ();
189189 }
190190
191- private Double findRatioValue (final String value ) {
192- if (value != null ) {
193- return Double .valueOf (value );
194- }
195- return 1.0 ;
196- }
197-
198191 private void updateHostMetrics (final HostMetrics hostMetrics , final HostJoinVO host ) {
199192 hostMetrics .addCpuAllocated (host .getCpuReservedCapacity () + host .getCpuUsedCapacity ());
200193 hostMetrics .addMemoryAllocated (host .getMemReservedCapacity () + host .getMemUsedCapacity ());
@@ -764,14 +757,10 @@ public List<ClusterMetricsResponse> listClusterMetrics(Pair<List<ClusterResponse
764757 if (AllowListMetricsComputation .value ()) {
765758 List <Ternary <Long , Long , Long >> cpuList = new ArrayList <>();
766759 List <Ternary <Long , Long , Long >> memoryList = new ArrayList <>();
767- for (final Host host : hostDao .findByClusterId (clusterId )) {
768- if (host == null || host .getType () != Host .Type .Routing ) {
769- continue ;
770- }
771- updateHostMetrics (hostMetrics , hostJoinDao .findById (host .getId ()));
772- HostJoinVO hostJoin = hostJoinDao .findById (host .getId ());
773- cpuList .add (new Ternary <>(hostJoin .getCpuUsedCapacity (), hostJoin .getCpuReservedCapacity (), hostJoin .getCpus () * hostJoin .getSpeed ()));
774- memoryList .add (new Ternary <>(hostJoin .getMemUsedCapacity (), hostJoin .getMemReservedCapacity (), hostJoin .getTotalMemory ()));
760+ for (final HostJoinVO host : hostJoinDao .findByClusterId (clusterId , Host .Type .Routing )) {
761+ updateHostMetrics (hostMetrics , host );
762+ cpuList .add (new Ternary <>(host .getCpuUsedCapacity (), host .getCpuReservedCapacity (), host .getCpus () * host .getSpeed ()));
763+ memoryList .add (new Ternary <>(host .getMemUsedCapacity (), host .getMemReservedCapacity (), host .getTotalMemory ()));
775764 }
776765 try {
777766 Double imbalance = ClusterDrsAlgorithm .getClusterImbalance (clusterId , cpuList , memoryList , null );
@@ -950,11 +939,8 @@ public List<ZoneMetricsResponse> listZoneMetrics(List<ZoneResponse> zoneResponse
950939 if (cluster == null ) {
951940 continue ;
952941 }
953- for (final Host host : hostDao .findByClusterId (cluster .getId ())) {
954- if (host == null || host .getType () != Host .Type .Routing ) {
955- continue ;
956- }
957- updateHostMetrics (hostMetrics , hostJoinDao .findById (host .getId ()));
942+ for (final HostJoinVO host : hostJoinDao .findByClusterId (cluster .getId (), Host .Type .Routing )) {
943+ updateHostMetrics (hostMetrics , host );
958944 }
959945 }
960946 } else {
0 commit comments