You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/05/09 13:56:44 UTC

[GitHub] [pulsar] shibd commented on a diff in pull request #14971: [feature][broker] Add new load manager strategy for load manager to select broker having load below average.

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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org