codelipenghui commented on code in PR #19154:
URL: https://github.com/apache/pulsar/pull/19154#discussion_r1071718092


##########
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:
   What does EMA mean? Is it better to add a description for "EMA"?



##########
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:
   Should the debug log be removed?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to