You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/04/28 14:16:34 UTC

[GitHub] [hbase] virajjasani commented on a change in pull request #3182: HBASE-25790 NamedQueue 'BalancerRejection' for recent history of balancer skipping

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



##########
File path: hbase-client/src/main/java/org/apache/hadoop/hbase/client/BalancerRejection.java
##########
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.client;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.hadoop.hbase.util.GsonUtil;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
+
+import org.apache.hbase.thirdparty.com.google.gson.Gson;
+import org.apache.hbase.thirdparty.com.google.gson.JsonSerializer;
+
+/**
+ * History of detail information that balancer movements was rejected
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+final public class BalancerRejection extends LogEntry {
+  //The reason why balancer was rejected
+  private final String reason;
+  private final List<String> costFuncInfoList;
+
+  // used to convert object to pretty printed format
+  // used by toJsonPrettyPrint()
+  private static final Gson GSON = GsonUtil.createGson()
+    .setPrettyPrinting()
+    .disableHtmlEscaping()
+    .registerTypeAdapter(BalancerRejection.class, (JsonSerializer<BalancerRejection>)
+      (balancerRejection, type, jsonSerializationContext) -> {
+        Gson gson = new Gson();
+        return gson.toJsonTree(balancerRejection);
+      }).create();
+
+  private BalancerRejection(String reason, List<String> costFuncInfoList) {
+    this.reason = reason;
+    if(costFuncInfoList == null){
+      this.costFuncInfoList = Collections.emptyList();
+    }
+    else {
+      this.costFuncInfoList = costFuncInfoList;
+    }
+  }
+
+  public String getReason() {
+    return reason;
+  }
+
+  public List<String> getCostFuncInfoList() {
+    return costFuncInfoList;
+  }
+
+  @Override
+  public String toString() {
+    return new ToStringBuilder(this)
+      .append("reason", reason)
+      .append("costFuncInfoList", costFuncInfoList.toString())
+      .toString();
+  }
+
+  @Override
+  public String toJsonPrettyPrint() {
+    return GSON.toJson(this);
+  }
+
+  public static class Builder {
+    private String reason;
+    private List<String> costFuncInfoList;
+
+    public Builder setReason(String reason) {
+      this.reason = reason;
+      return this;
+    }
+
+    public Builder addCostFuncInfo(String funcName, double cost, float multiplier){

Review comment:
       I think this method doesn't need to return anything. Let's make it this?
   ```
   public void addCostFuncInfo(String funcName, double cost, float multiplier)
   ```

##########
File path: hbase-shell/src/main/ruby/shell/commands/get_balancer_rejections.rb
##########
@@ -0,0 +1,49 @@
+#
+#
+# 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.
+
+# Retrieve latest balancer decisions maintained in memory by HMaster

Review comment:
       `decision` -> `rejection`

##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/namequeues/BalancerRejectionDetails.java
##########
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.hadoop.hbase.client.BalancerRejection;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Balancer decision details that would be passed on to ring buffer for history

Review comment:
       `decision` -> `rejection`




-- 
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:
users@infra.apache.org