Skip to content

Commit

Permalink
fix(s3stream): initialize broker capacity to ignored value (#526)
Browse files Browse the repository at this point in the history
Signed-off-by: Shichao Nie <[email protected]>
  • Loading branch information
SCNieh authored Dec 8, 2023
1 parent 2d99924 commit 79a67d2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

public class BrokerUpdater {
private static final Logger LOGGER = LoggerFactory.getLogger(BrokerUpdater.class);
private static final Double IGNORED_CAPACITY_VALUE = -1.0;
private final Lock lock = new ReentrantLock();
private final Broker broker;

Expand All @@ -51,6 +52,7 @@ public static class Broker {

public Broker(int brokerId) {
this.brokerId = brokerId;
Arrays.fill(this.brokerCapacity, IGNORED_CAPACITY_VALUE);
}

public Broker(Broker other) {
Expand Down Expand Up @@ -101,7 +103,10 @@ public void addLoad(Resource resource, double delta) {

public double utilizationFor(Resource resource) {
double capacity = capacity(resource);
if (capacity == 0) {
if (capacity == IGNORED_CAPACITY_VALUE) {
return 0.0;
}
if (capacity == 0.0) {
return Double.MAX_VALUE;
}
return load(resource) / capacity(resource);
Expand Down

0 comments on commit 79a67d2

Please sign in to comment.