@@ -189,13 +189,6 @@ protected MetricsServiceImpl() {
189189 super ();
190190 }
191191
192- private Double findRatioValue (final String value ) {
193- if (value != null ) {
194- return Double .valueOf (value );
195- }
196- return 1.0 ;
197- }
198-
199192 private void updateHostMetrics (final HostMetrics hostMetrics , final HostJoinVO host ) {
200193 hostMetrics .addCpuAllocated (host .getCpuReservedCapacity () + host .getCpuUsedCapacity ());
201194 hostMetrics .addMemoryAllocated (host .getMemReservedCapacity () + host .getMemUsedCapacity ());
@@ -768,14 +761,10 @@ public List<ClusterMetricsResponse> listClusterMetrics(Pair<List<ClusterResponse
768761 if (AllowListMetricsComputation .value ()) {
769762 List <Ternary <Long , Long , Long >> cpuList = new ArrayList <>();
770763 List <Ternary <Long , Long , Long >> memoryList = new ArrayList <>();
771- for (final Host host : hostDao .findByClusterId (clusterId )) {
772- if (host == null || host .getType () != Host .Type .Routing ) {
773- continue ;
774- }
775- updateHostMetrics (hostMetrics , hostJoinDao .findById (host .getId ()));
776- HostJoinVO hostJoin = hostJoinDao .findById (host .getId ());
777- cpuList .add (new Ternary <>(hostJoin .getCpuUsedCapacity (), hostJoin .getCpuReservedCapacity (), hostJoin .getCpus () * hostJoin .getSpeed ()));
778- memoryList .add (new Ternary <>(hostJoin .getMemUsedCapacity (), hostJoin .getMemReservedCapacity (), hostJoin .getTotalMemory ()));
764+ for (final HostJoinVO host : hostJoinDao .findByClusterId (clusterId , Host .Type .Routing )) {
765+ updateHostMetrics (hostMetrics , host );
766+ cpuList .add (new Ternary <>(host .getCpuUsedCapacity (), host .getCpuReservedCapacity (), host .getCpus () * host .getSpeed ()));
767+ memoryList .add (new Ternary <>(host .getMemUsedCapacity (), host .getMemReservedCapacity (), host .getTotalMemory ()));
779768 }
780769 try {
781770 Double imbalance = ClusterDrsAlgorithm .getClusterImbalance (clusterId , cpuList , memoryList , null );
@@ -956,11 +945,8 @@ public List<ZoneMetricsResponse> listZoneMetrics(List<ZoneResponse> zoneResponse
956945 if (cluster == null ) {
957946 continue ;
958947 }
959- for (final Host host : hostDao .findByClusterId (cluster .getId ())) {
960- if (host == null || host .getType () != Host .Type .Routing ) {
961- continue ;
962- }
963- updateHostMetrics (hostMetrics , hostJoinDao .findById (host .getId ()));
948+ for (final HostJoinVO host : hostJoinDao .findByClusterId (cluster .getId (), Host .Type .Routing )) {
949+ updateHostMetrics (hostMetrics , host );
964950 }
965951 }
966952 } else {
0 commit comments