heesung-sn commented on code in PR #19154:
URL: https://github.com/apache/pulsar/pull/19154#discussion_r1072701722
##
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java:
##
@@ -95,17 +124,35 @@ private void updateSystemResourceUsage(final ResourceUsage
cpu, final ResourceUs
this.bandwidthOut = bandwidthOut;
}
-public double getMaxResourceUsage() {
-return LocalBrokerData.max(cpu.percentUsage(),
directMemory.percentUsage(), bandwidthIn.percentUsage(),
+private void updateFeatures(ServiceConfiguration conf) {
+updateMaxResourceUsage();
+updateWeightedMaxEMA(conf);
+}
+
+private void updateMaxResourceUsage() {
+maxResourceUsage = LocalBrokerData.max(cpu.percentUsage(),
directMemory.percentUsage(),
+bandwidthIn.percentUsage(),
bandwidthOut.percentUsage()) / 100;
}
-public double getMaxResourceUsageWithWeight(final double cpuWeight, final
double memoryWeight,
+private double getMaxResourceUsageWithWeight(final double cpuWeight, final
double memoryWeight,
final double
directMemoryWeight, final double bandwidthInWeight,
final double
bandwidthOutWeight) {
return LocalBrokerData.max(cpu.percentUsage() * cpuWeight,
memory.percentUsage() * memoryWeight,
directMemory.percentUsage() * directMemoryWeight,
bandwidthIn.percentUsage() * bandwidthInWeight,
bandwidthOut.percentUsage() * bandwidthOutWeight) / 100;
}
+
+private void updateWeightedMaxEMA(ServiceConfiguration conf) {
Review Comment:
It is an exponential moving average. Updated the comment for the
weightedMaxEMA variable.
##
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/LeastResourceUsageWithWeight.java:
##
@@ -80,40 +74,6 @@ private double getMaxResourceUsageWithWeight(final String
broker, final BrokerLo
return maxUsageWithWeight;
}
-/**
- * Update and get the max resource usage with weight of broker according
to the service configuration.
- *
- * @param broker The broker name.
- * @param brokerData The broker load data.
- * @param conf The service configuration.
- * @param debugMode The debug mode to print computed load states and
decision information.
- * @return the max resource usage with weight of broker
- */
-private double updateAndGetMaxResourceUsageWithWeight(String broker,
BrokerLoadData brokerData,
- ServiceConfiguration
conf, boolean debugMode) {
-final double historyPercentage =
conf.getLoadBalancerHistoryResourcePercentage();
-Double historyUsage = brokerAvgResourceUsageWithWeight.get(broker);
-double resourceUsage = brokerData.getMaxResourceUsageWithWeight(
-conf.getLoadBalancerCPUResourceWeight(),
-conf.getLoadBalancerMemoryResourceWeight(),
-conf.getLoadBalancerDirectMemoryResourceWeight(),
-conf.getLoadBalancerBandwithInResourceWeight(),
-conf.getLoadBalancerBandwithOutResourceWeight());
-historyUsage = historyUsage == null
-? resourceUsage : historyUsage * historyPercentage + (1 -
historyPercentage) * resourceUsage;
-if (debugMode) {
-log.info(
-"Broker {} get max resource usage with weight: {}, history
resource percentage: {}%, CPU weight: "
-+ "{}, MEMORY weight: {}, DIRECT MEMORY weight:
{}, BANDWIDTH IN weight: {}, BANDWIDTH "
-+ "OUT weight: {} ",
-broker, historyUsage, historyPercentage,
conf.getLoadBalancerCPUResourceWeight(),
-conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
-conf.getLoadBalancerBandwithInResourceWeight(),
-conf.getLoadBalancerBandwithOutResourceWeight());
-}
Review Comment:
No. I think we can keep this.
Added BrokerLoadData.toString() and added the debug log.
```
else if (debugMode) {
log.info("Broker {} load data:{{}}", broker,
brokerLoadData.toString(conf));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org