Skip to content

Commit

Permalink
[fix][broker] Remove useless load items
Browse files Browse the repository at this point in the history
  • Loading branch information
315157973 committed Feb 18, 2023
1 parent fe547c7 commit c3b2c20
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private double updateAndGetMaxResourceUsageWithWeight(String broker, BrokerData
}
double resourceUsage = brokerData.getLocalData().getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
conf.getLoadBalancerBandwithInResourceWeight(),
conf.getLoadBalancerBandwithOutResourceWeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private double updateAvgResourceUsage(String broker, LocalBrokerData localBroker
brokerAvgResourceUsage.get(broker);
double resourceUsage = localBrokerData.getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(), conf.getLoadBalancerDirectMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
conf.getLoadBalancerBandwithInResourceWeight(),
conf.getLoadBalancerBandwithOutResourceWeight());
historyUsage = historyUsage == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ public String printResourceUsage() {
bandwidthOut.percentUsage());
}

public double getMaxResourceUsageWithWeight(final double cpuWeight, final double memoryWeight,
public double getMaxResourceUsageWithWeight(final double cpuWeight,
final double directMemoryWeight, final double bandwidthInWeight,
final double bandwidthOutWeight) {
return max(cpu.percentUsage() * cpuWeight, memory.percentUsage() * memoryWeight,
return max(cpu.percentUsage() * cpuWeight,
directMemory.percentUsage() * directMemoryWeight, bandwidthIn.percentUsage() * bandwidthInWeight,
bandwidthOut.percentUsage() * bandwidthOutWeight) / 100;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ public void testLocalBrokerDataDeserialization() {
public void testMaxResourceUsage() {
LocalBrokerData data = new LocalBrokerData();
data.setCpu(new ResourceUsage(1.0, 100.0));
data.setMemory(new ResourceUsage(800.0, 200.0));
data.setDirectMemory(new ResourceUsage(2.0, 100.0));
data.setBandwidthIn(new ResourceUsage(3.0, 100.0));
data.setBandwidthOut(new ResourceUsage(4.0, 100.0));

double epsilon = 0.00001;
double weight = 0.5;
// skips memory usage
assertEquals(data.getMaxResourceUsage(), 0.04, epsilon);
assertEquals(data.getMaxResourceUsage(), data.getBandwidthOut().percentUsage() / 100, epsilon);

assertEquals(
data.getMaxResourceUsageWithWeight(
weight, weight, weight, weight, weight), 2.0, epsilon);
assertEquals(data.getMaxResourceUsageWithWeight(weight, weight, weight, weight),
data.getBandwidthOut().percentUsage() * weight / 100, epsilon);
}

/*
Expand Down

0 comments on commit c3b2c20

Please # to comment.