From c75bcb411d524ba959d744ff565dc9f6d96eb76a Mon Sep 17 00:00:00 2001 From: Xiang-Jun Sun Date: Thu, 18 May 2023 09:44:54 +0800 Subject: [PATCH] [COST] fix `BrokerDiskSpaceCost` (#1757) --- .../org/astraea/common/cost/BrokerDiskSpaceCost.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/astraea/common/cost/BrokerDiskSpaceCost.java b/common/src/main/java/org/astraea/common/cost/BrokerDiskSpaceCost.java index e524e1a31f..c9925fa301 100644 --- a/common/src/main/java/org/astraea/common/cost/BrokerDiskSpaceCost.java +++ b/common/src/main/java/org/astraea/common/cost/BrokerDiskSpaceCost.java @@ -83,9 +83,8 @@ static boolean brokerDiskUsageSizeOverflow( (Long) after .replicaStream(id) - .filter(r -> before.replicaStream(id).noneMatch(r::equals)) - .map(Replica::size) - .mapToLong(y -> y) + .filter(r -> !before.replicas(r.topicPartition()).contains(r)) + .mapToLong(Replica::size) .sum(); if ((beforeSize + addedSize) > brokerMoveCostLimit.getOrDefault(id, DataSize.Byte.of(Long.MAX_VALUE)).bytes()) @@ -115,9 +114,8 @@ static boolean brokerPathDiskUsageSizeOverflow( (Long) after .replicaStream(brokerPaths.getKey()) - .filter(r -> before.replicaStream(brokerPaths.getKey()).noneMatch(r::equals)) - .map(Replica::size) - .mapToLong(y -> y) + .filter(r -> !before.replicas(r.topicPartition()).contains(r)) + .mapToLong(Replica::size) .sum(); if ((beforeSize + addedSize) > diskMoveCostLimit.getOrDefault(brokerPath, DataSize.Byte.of(Long.MAX_VALUE)).bytes())