shibd commented on code in PR #14971:
URL: https://github.com/apache/pulsar/pull/14971#discussion_r868044198


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java:
##########
@@ -55,11 +58,18 @@ Optional<String> selectBroker(Set<String> candidates, 
BundleData bundleToAssign,
      */
     static ModularLoadManagerStrategy create(final ServiceConfiguration conf) {
         try {
-            // Only one strategy at the moment.
-            return new LeastLongTermMessageRate(conf);
+            Class<?> loadManagerStrategyClass = 
Class.forName(conf.getLoadBalancerLoadManagerStrategy());
+            Object loadManagerStrategyInstance = 
loadManagerStrategyClass.getDeclaredConstructor().newInstance();
+            if (loadManagerStrategyInstance instanceof 
ModularLoadManagerStrategy) {
+                return (ModularLoadManagerStrategy) 
loadManagerStrategyInstance;
+            } else {
+                LOG.error("Create load manager strategy failed.");
+                throw new IllegalArgumentException("Invalid load balancer load 
manager strategy: "
+                        + conf.getLoadBalancerLoadManagerStrategy());
+            }
         } catch (Exception e) {
-            // Ignore
+            LOG.error("Error when trying to create load manager strategy: ", 
e);

Review Comment:
   Suggestion append log: “Will use default strategy: LeastLongTermMessageRate”



-- 
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