virajjasani commented on a change in pull request #3182:
URL: https://github.com/apache/hbase/pull/3182#discussion_r622272806



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
##########
@@ -4220,6 +4229,12 @@ private void getProcedureResult(long procId, 
CompletableFuture<Void> future, int
           "Balancer Decision logs are not maintained by HRegionServer");
       }
       return getBalancerDecisions(limit);

Review comment:
       I think we can introduce switch/case here:
   ```
       switch (logType) {
         case "SLOW_LOG":
         case "LARGE_LOG":
           if (ServerType.MASTER.equals(serverType)) {
             throw new IllegalArgumentException("Slow/Large logs are not 
maintained by HMaster");
           }
           return getSlowLogResponses(filterParams, serverNames, limit, 
logType);
         case "BALANCER_DECISION":
           if (ServerType.REGION_SERVER.equals(serverType)) {
             throw new IllegalArgumentException(
               "Balancer Decision logs are not maintained by HRegionServer");
           }
           return getBalancerDecisions(limit);
         case "BALANCER_REJECTION":
           if (ServerType.REGION_SERVER.equals(serverType)) {
             throw new IllegalArgumentException(
               "Balancer Rejection logs are not maintained by HRegionServer");
           }
           return getBalancerRejections(limit);
       }
   
   ```

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
##########
@@ -221,10 +225,15 @@ public synchronized void setConf(Configuration conf) {
     curFunctionCosts= new Double[costFunctions.size()];
     tempFunctionCosts= new Double[costFunctions.size()];
 
-    boolean isBalancerDecisionRecording = getConf()
+    isBalancerDecisionRecording = getConf()

Review comment:
       This looks better

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/namequeues/impl/BalancerRejectionQueueService.java
##########
@@ -0,0 +1,138 @@
+/*
+ *
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.namequeues.impl;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.client.BalancerRejection;
+import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer;
+import org.apache.hadoop.hbase.namequeues.BalancerRejectionDetails;
+import org.apache.hadoop.hbase.namequeues.BalancerRejectionDetails;
+import org.apache.hadoop.hbase.namequeues.NamedQueuePayload;
+import org.apache.hadoop.hbase.namequeues.NamedQueueService;
+import org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest;
+import org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RecentLogs;
+import org.apache.hadoop.hbase.util.GsonUtil;
+import org.apache.hbase.thirdparty.com.google.common.collect.EvictingQueue;
+import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
+import org.apache.hbase.thirdparty.com.google.common.collect.Queues;
+import org.apache.hbase.thirdparty.com.google.gson.Gson;
+import org.apache.hbase.thirdparty.com.google.gson.JsonSerializer;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
+import java.util.stream.Collectors;

Review comment:
       nit: reorganize imports? some of them are not being used.

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
##########
@@ -351,6 +364,21 @@ protected boolean needsBalance(TableName tableName, 
BalancerClusterState cluster
 
     boolean balanced = total <= 0 || sumMultiplier <= 0 ||
         (sumMultiplier > 0 && (total / sumMultiplier) < minCostNeedBalance);
+    if(balanced && isBalancerRejectionRecording){
+      String reason;
+      if (total <= 0) {
+        reason = 
"(cost1*multiplier1)+(cost2*multiplier2)+...+(costn*multipliern) = " + total + 
" <= 0";
+      } else if (sumMultiplier <= 0) {
+        reason = "sumMultiplier = " + sumMultiplier + " <= 0";
+      } else if ((total / sumMultiplier) < minCostNeedBalance) {
+        reason =
+          
"[(cost1*multiplier1)+(cost2*multiplier2)+...+(costn*multipliern)]/sumMultiplier
 = " + (total
+            / sumMultiplier) + " <= minCostNeedBalance(" + minCostNeedBalance 
+ ")";
+      } else {
+        reason = "Unknown reason, please check the code for bugs";

Review comment:
       Do we need this `else` block?




-- 
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:
[email protected]


Reply via email to