This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 9692b67fd64 [improve] [pip] PIP-357: Correct the conf name in load
balance module. (#22824)
9692b67fd64 is described below
commit 9692b67fd64f7acf90a93bf9adc21fab61842555
Author: Wenzhi Feng <[email protected]>
AuthorDate: Fri Jun 7 14:29:15 2024 +0800
[improve] [pip] PIP-357: Correct the conf name in load balance module.
(#22824)
Co-authored-by: Kai Wang <[email protected]>
---
conf/broker.conf | 8 ++--
conf/standalone.conf | 8 ++--
deployment/terraform-ansible/templates/broker.conf | 8 ++--
.../apache/pulsar/broker/ServiceConfiguration.java | 47 +++++++++++++++++++++-
.../extensions/data/BrokerLoadData.java | 16 ++++----
.../impl/LeastResourceUsageWithWeight.java | 12 +++---
.../broker/loadbalance/impl/ThresholdShedder.java | 4 +-
.../ModularLoadManagerStrategyTest.java | 8 ++--
.../extensions/data/BrokerLoadDataTest.java | 12 +++---
.../strategy/LeastResourceUsageWithWeightTest.java | 4 +-
10 files changed, 85 insertions(+), 42 deletions(-)
diff --git a/conf/broker.conf b/conf/broker.conf
index 02e29402989..8fd266d609c 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -1393,13 +1393,13 @@
loadBalancerMsgThroughputMultiplierDifferenceShedderThreshold=4
# It only takes effect in the ThresholdShedder strategy.
loadBalancerHistoryResourcePercentage=0.9
-# The BandWithIn usage weight when calculating new resource usage.
+# The BandWidthIn usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
-loadBalancerBandwithInResourceWeight=1.0
+loadBalancerBandwidthInResourceWeight=1.0
-# The BandWithOut usage weight when calculating new resource usage.
+# The BandWidthOut usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
-loadBalancerBandwithOutResourceWeight=1.0
+loadBalancerBandwidthOutResourceWeight=1.0
# The CPU usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
diff --git a/conf/standalone.conf b/conf/standalone.conf
index 07d19c7bee9..6b261ce11c6 100644
--- a/conf/standalone.conf
+++ b/conf/standalone.conf
@@ -910,13 +910,13 @@ loadBalancerBrokerThresholdShedderPercentage=10
# It only takes effect in the ThresholdShedder strategy.
loadBalancerHistoryResourcePercentage=0.9
-# The BandWithIn usage weight when calculating new resource usage.
+# The BandWidthIn usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
-loadBalancerBandwithInResourceWeight=1.0
+loadBalancerBandwidthInResourceWeight=1.0
-# The BandWithOut usage weight when calculating new resource usage.
+# The BandWidthOut usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
-loadBalancerBandwithOutResourceWeight=1.0
+loadBalancerBandwidthOutResourceWeight=1.0
# The CPU usage weight when calculating new resource usage.
# It only takes effect in the ThresholdShedder strategy.
diff --git a/deployment/terraform-ansible/templates/broker.conf
b/deployment/terraform-ansible/templates/broker.conf
index 084d7f46ce1..ff367717402 100644
--- a/deployment/terraform-ansible/templates/broker.conf
+++ b/deployment/terraform-ansible/templates/broker.conf
@@ -953,13 +953,13 @@ loadBalancerBrokerThresholdShedderPercentage=10
# It only take effect in ThresholdShedder strategy.
loadBalancerHistoryResourcePercentage=0.9
-# The BandWithIn usage weight when calculating new resource usage.
+# The BandWidthIn usage weight when calculating new resourde usage.
# It only take effect in ThresholdShedder strategy.
-loadBalancerBandwithInResourceWeight=1.0
+loadBalancerBandwidthInResourceWeight=1.0
-# The BandWithOut usage weight when calculating new resource usage.
+# The BandWidthOut usage weight when calculating new resourde usage.
# It only take effect in ThresholdShedder strategy.
-loadBalancerBandwithOutResourceWeight=1.0
+loadBalancerBandwidthOutResourceWeight=1.0
# The CPU usage weight when calculating new resource usage.
# It only take effect in ThresholdShedder strategy.
diff --git
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index 204ea453bae..63ef6f3efe6 100644
---
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -2444,17 +2444,60 @@ public class ServiceConfiguration implements
PulsarConfiguration {
@FieldContext(
dynamic = true,
category = CATEGORY_LOAD_BALANCER,
- doc = "BandwithIn Resource Usage Weight"
+ doc = "BandwidthIn Resource Usage Weight"
+ )
+ private double loadBalancerBandwidthInResourceWeight = 1.0;
+
+ @FieldContext(
+ dynamic = true,
+ category = CATEGORY_LOAD_BALANCER,
+ doc = "BandwidthOut Resource Usage Weight"
+ )
+ private double loadBalancerBandwidthOutResourceWeight = 1.0;
+
+ @Deprecated
+ @FieldContext(
+ dynamic = true,
+ category = CATEGORY_LOAD_BALANCER,
+ doc = "BandwidthIn Resource Usage Weight, Deprecated: Use
loadBalancerBandwidthInResourceWeight"
)
private double loadBalancerBandwithInResourceWeight = 1.0;
+ @Deprecated
@FieldContext(
dynamic = true,
category = CATEGORY_LOAD_BALANCER,
- doc = "BandwithOut Resource Usage Weight"
+ doc = "BandwidthOut Resource Usage Weight, Deprecated: Use
loadBalancerBandwidthOutResourceWeight"
)
private double loadBalancerBandwithOutResourceWeight = 1.0;
+ /**
+ * Get the load balancer bandwidth in resource weight.
+ * To be compatible with the old configuration, we still support the old
configuration.
+ * If a configuration is not the default configuration, use that
configuration.
+ * If both the new and the old are configured different from the default
value, use the new one.
+ * @return
+ */
+ public double getLoadBalancerBandwidthInResourceWeight() {
+ if (loadBalancerBandwidthInResourceWeight != 1.0) {
+ return loadBalancerBandwidthInResourceWeight;
+ }
+ if (loadBalancerBandwithInResourceWeight != 1.0) {
+ return loadBalancerBandwithInResourceWeight;
+ }
+ return 1.0;
+ }
+
+ public double getLoadBalancerBandwidthOutResourceWeight() {
+ if (loadBalancerBandwidthOutResourceWeight != 1.0) {
+ return loadBalancerBandwidthOutResourceWeight;
+ }
+ if (loadBalancerBandwithOutResourceWeight != 1.0) {
+ return loadBalancerBandwithOutResourceWeight;
+ }
+ return 1.0;
+ }
+
@FieldContext(
dynamic = true,
category = CATEGORY_LOAD_BALANCER,
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java
index a8cb9e08294..95d89932ed9 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadData.java
@@ -69,8 +69,8 @@ public class BrokerLoadData {
* loadBalancerCPUResourceWeight,
* loadBalancerMemoryResourceWeight,
* loadBalancerDirectMemoryResourceWeight,
- * loadBalancerBandwithInResourceWeight, and
- * loadBalancerBandwithOutResourceWeight.
+ * loadBalancerBandwidthInResourceWeight, and
+ * loadBalancerBandwidthOutResourceWeight.
*
* The historical resource percentage is configured by
loadBalancerHistoryResourcePercentage.
*/
@@ -186,8 +186,8 @@ public class BrokerLoadData {
var weightedMax = getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight());
weightedMaxEMA = updatedAt == 0 ? weightedMax :
weightedMaxEMA * historyPercentage + (1 - historyPercentage) *
weightedMax;
}
@@ -220,9 +220,9 @@ public class BrokerLoadData {
public String toString(ServiceConfiguration conf) {
return String.format("cpu= %.2f%%, memory= %.2f%%, directMemory=
%.2f%%, "
- + "bandwithIn= %.2f%%, bandwithOut= %.2f%%, "
+ + "bandwidthIn= %.2f%%, bandwidthOut= %.2f%%, "
+ "cpuWeight= %f, memoryWeight= %f,
directMemoryWeight= %f, "
- + "bandwithInResourceWeight= %f,
bandwithOutResourceWeight= %f, "
+ + "bandwidthInResourceWeight= %f,
bandwidthOutResourceWeight= %f, "
+ "msgThroughputIn= %.2f, msgThroughputOut= %.2f,
msgRateIn= %.2f, msgRateOut= %.2f, "
+ "bundleCount= %d, "
+ "maxResourceUsage= %.2f%%, weightedMaxEMA= %.2f%%,
msgThroughputEMA= %.2f, "
@@ -233,8 +233,8 @@ public class BrokerLoadData {
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight(),
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight(),
msgThroughputIn, msgThroughputOut, msgRateIn, msgRateOut,
bundleCount,
maxResourceUsage * 100, weightedMaxEMA * 100, msgThroughputEMA,
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
index ab3e63e9d13..2baf58c9f05 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
@@ -68,8 +68,8 @@ public class LeastResourceUsageWithWeight implements
ModularLoadManagerStrategy
localData.getDirectMemory().percentUsage(),
localData.getBandwidthIn().percentUsage(),
localData.getBandwidthOut().percentUsage(),
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight());
}
if (log.isDebugEnabled()) {
@@ -99,8 +99,8 @@ public class LeastResourceUsageWithWeight implements
ModularLoadManagerStrategy
double resourceUsage =
brokerData.getLocalData().getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight());
historyUsage = historyUsage == null
? resourceUsage : historyUsage * historyPercentage + (1 -
historyPercentage) * resourceUsage;
if (log.isDebugEnabled()) {
@@ -110,8 +110,8 @@ public class LeastResourceUsageWithWeight implements
ModularLoadManagerStrategy
+ "OUT weight: {} ",
broker, historyUsage, historyPercentage,
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight());
}
brokerAvgResourceUsageWithWeight.put(broker, historyUsage);
return historyUsage;
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
index ffa16c09e9b..aa556cd0ca5 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
@@ -173,8 +173,8 @@ public class ThresholdShedder implements
LoadSheddingStrategy {
double resourceUsage = localBrokerData.getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
+ conf.getLoadBalancerBandwidthInResourceWeight(),
+ conf.getLoadBalancerBandwidthOutResourceWeight());
historyUsage = historyUsage == null
? resourceUsage : historyUsage * historyPercentage + (1 -
historyPercentage) * resourceUsage;
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java
index c64c9950a95..2b6bfb742eb 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java
@@ -88,8 +88,8 @@ public class ModularLoadManagerStrategyTest {
conf.setLoadBalancerCPUResourceWeight(1.0);
conf.setLoadBalancerMemoryResourceWeight(0.1);
conf.setLoadBalancerDirectMemoryResourceWeight(0.1);
- conf.setLoadBalancerBandwithInResourceWeight(1.0);
- conf.setLoadBalancerBandwithOutResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthInResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthOutResourceWeight(1.0);
conf.setLoadBalancerHistoryResourcePercentage(0.5);
conf.setLoadBalancerAverageResourceUsageDifferenceThresholdPercentage(5);
@@ -167,8 +167,8 @@ public class ModularLoadManagerStrategyTest {
conf.setLoadBalancerCPUResourceWeight(1.0);
conf.setLoadBalancerMemoryResourceWeight(0.1);
conf.setLoadBalancerDirectMemoryResourceWeight(0.1);
- conf.setLoadBalancerBandwithInResourceWeight(1.0);
- conf.setLoadBalancerBandwithOutResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthInResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthOutResourceWeight(1.0);
conf.setLoadBalancerHistoryResourcePercentage(0.5);
conf.setLoadBalancerAverageResourceUsageDifferenceThresholdPercentage(5);
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadDataTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadDataTest.java
index 85792a7ba93..295c157e359 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadDataTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/data/BrokerLoadDataTest.java
@@ -41,8 +41,8 @@ public class BrokerLoadDataTest {
conf.setLoadBalancerCPUResourceWeight(0.5);
conf.setLoadBalancerMemoryResourceWeight(0.5);
conf.setLoadBalancerDirectMemoryResourceWeight(0.5);
- conf.setLoadBalancerBandwithInResourceWeight(0.5);
- conf.setLoadBalancerBandwithOutResourceWeight(0.5);
+ conf.setLoadBalancerBandwidthInResourceWeight(0.5);
+ conf.setLoadBalancerBandwidthOutResourceWeight(0.5);
conf.setLoadBalancerHistoryResourcePercentage(0.75);
BrokerLoadData data = new BrokerLoadData();
@@ -108,9 +108,9 @@ public class BrokerLoadDataTest {
assertThat(data.getUpdatedAt(), greaterThanOrEqualTo(now));
assertEquals(data.getReportedAt(), 0l);
assertEquals(data.toString(conf), "cpu= 300.00%, memory= 100.00%,
directMemory= 2.00%, "
- + "bandwithIn= 3.00%, bandwithOut= 4.00%, "
+ + "bandwidthIn= 3.00%, bandwidthOut= 4.00%, "
+ "cpuWeight= 0.500000, memoryWeight= 0.500000,
directMemoryWeight= 0.500000, "
- + "bandwithInResourceWeight= 0.500000,
bandwithOutResourceWeight= 0.500000, "
+ + "bandwidthInResourceWeight= 0.500000,
bandwidthOutResourceWeight= 0.500000, "
+ "msgThroughputIn= 5.00, msgThroughputOut= 6.00, "
+ "msgRateIn= 7.00, msgRateOut= 8.00, bundleCount= 9, "
+ "maxResourceUsage= 300.00%, weightedMaxEMA= 187.50%,
msgThroughputEMA= 5.00, "
@@ -126,8 +126,8 @@ public class BrokerLoadDataTest {
conf.setLoadBalancerCPUResourceWeight(0.5);
conf.setLoadBalancerMemoryResourceWeight(0.5);
conf.setLoadBalancerDirectMemoryResourceWeight(0.5);
- conf.setLoadBalancerBandwithInResourceWeight(0.5);
- conf.setLoadBalancerBandwithOutResourceWeight(0.5);
+ conf.setLoadBalancerBandwidthInResourceWeight(0.5);
+ conf.setLoadBalancerBandwidthOutResourceWeight(0.5);
conf.setLoadBalancerHistoryResourcePercentage(0.75);
BrokerLoadData data = new BrokerLoadData();
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/LeastResourceUsageWithWeightTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/LeastResourceUsageWithWeightTest.java
index b1e09bf2f3a..5f3a08d493b 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/LeastResourceUsageWithWeightTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/strategy/LeastResourceUsageWithWeightTest.java
@@ -196,8 +196,8 @@ public class LeastResourceUsageWithWeightTest {
conf.setLoadBalancerCPUResourceWeight(1.0);
conf.setLoadBalancerMemoryResourceWeight(0.1);
conf.setLoadBalancerDirectMemoryResourceWeight(0.1);
- conf.setLoadBalancerBandwithInResourceWeight(1.0);
- conf.setLoadBalancerBandwithOutResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthInResourceWeight(1.0);
+ conf.setLoadBalancerBandwidthOutResourceWeight(1.0);
conf.setLoadBalancerHistoryResourcePercentage(0.5);
conf.setLoadBalancerAverageResourceUsageDifferenceThresholdPercentage(5);
var brokerLoadDataStore = new LoadDataStore<BrokerLoadData>() {