wchevreuil commented on a change in pull request #677: HBASE-23073 Add an 
optional costFunction to balance regions according to a capacity rule
URL: https://github.com/apache/hbase/pull/677#discussion_r337922099
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/HeterogeneousRegionCountCostFunction.java
 ##########
 @@ -0,0 +1,306 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.hadoop.hbase.master.balancer;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is an optional Cost function designed to allow region count skew 
across RegionServers. A
+ * rule file is loaded from the local FS or HDFS before balancing. It contains 
lines of rules. A
+ * rule is composed of a regexp for hostname, and a limit. For example, we 
could have:
+ * <p>
+ * * rs[0-9] 200 * rs1[0-9] 50
+ * </p>
+ * RegionServers with hostname matching the first rules will have a limit of 
200, and the others 50.
+ * If there's no match, a default is set. The costFunction is trying to fill 
all RegionServers
+ * linearly, meaning that if the global usage is at 50%, then all 
RegionServers should hold half of
+ * their capacity in terms of regions. In order to use this CostFunction, you 
need to set the
+ * following options:
+ * <ul>
+ * <li>hbase.master.balancer.stochastic.additionalCostFunctions</li>
+ * <li>hbase.master.balancer.stochastic.heterogeneousRegionCountRulesFile</li>
+ * <li>hbase.master.balancer.stochastic.heterogeneousRegionCountDefault</li>
+ * </ul>
+ */
+@InterfaceAudience.Private
+public class HeterogeneousRegionCountCostFunction extends 
StochasticLoadBalancer.CostFunction {
+
+  /**
+   * configuration used for the path where the rule file is stored.
+   */
+  static final String HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_FILE =
+      "hbase.master.balancer.heterogeneousRegionCountRulesFile";
+  private static final Logger LOG =
+      LoggerFactory.getLogger(HeterogeneousRegionCountCostFunction.class);
+  /**
+   * Default rule to apply when the rule file is not found. Default to 200.
+   */
+  private static final String 
HBASE_MASTER_BALANCER_HETEROGENEOUS_RULES_DEFAULT =
+      "hbase.master.balancer.heterogeneousRegionCountDefault";
+  /**
+   * Cost for the function. Default to 500, can be changed.
+   */
+  private static final String REGION_COUNT_SKEW_COST_KEY =
+      "hbase.master.balancer.stochastic.heterogeneousRegionCountCost";
+  private static final float DEFAULT_REGION_COUNT_SKEW_COST = 5000;
 
 Review comment:
   Just a follow up: Javadoc message above mentions default as 500, while here 
we set 5000. You may want to fix either the comment or the variable initial 
value.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to