HQebupt commented on code in PR #16281:
URL: https://github.com/apache/pulsar/pull/16281#discussion_r911706571
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategyTest.java:
##########
@@ -59,6 +60,42 @@ public void testLeastLongTermMessageRate() {
assertEquals(strategy.selectBroker(brokerDataMap.keySet(), bundleData,
loadData, conf), Optional.of("3"));
}
+ // Test that least resource usage with weight works correctly.
+ public void testLeastResourceUsageWithWeight() {
+ BundleData bundleData = new BundleData();
+ BrokerData brokerData1 = initBrokerData(10, 100);
+ BrokerData brokerData2 = initBrokerData(20, 100);
+ BrokerData brokerData4 = initBrokerData(40, 100);
+ LoadData loadData = new LoadData();
+ Map<String, BrokerData> brokerDataMap = loadData.getBrokerData();
+ brokerDataMap.put("1", brokerData1);
+ brokerDataMap.put("2", brokerData2);
+ brokerDataMap.put("4", brokerData4);
+ ServiceConfiguration conf = new ServiceConfiguration();
+ conf.setLoadBalancerBrokerThresholdShedderPercentage(10);
+ conf.setLoadBalancerCPUResourceWeight(1.0);
+ conf.setLoadBalancerMemoryResourceWeight(0.1);
+ conf.setLoadBalancerDirectMemoryResourceWeight(0.1);
+ conf.setLoadBalancerBandwithInResourceWeight(1.0);
+ conf.setLoadBalancerBandwithOutResourceWeight(1.0);
+
+ ModularLoadManagerStrategy strategy = new
LeastResourceUsageWithWeight();
+ assertEquals(strategy.selectBroker(brokerDataMap.keySet(), bundleData,
loadData, conf), Optional.of("1"));
+ }
+
Review Comment:
Sure.
--
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]