siddharthteotia commented on a change in pull request #4446: Add support in the 
rebalancer for the user to provide minimum number of serving replicas
URL: https://github.com/apache/incubator-pinot/pull/4446#discussion_r307189940
 
 

 ##########
 File path: 
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/RebalanceCommand.java
 ##########
 @@ -0,0 +1,114 @@
+/**
+ * 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.pinot.tools.admin.command;
+
+import org.apache.pinot.tools.Command;
+import org.apache.pinot.tools.PinotTableRebalancer;
+import org.kohsuke.args4j.Option;
+
+
+/**
+ * A sub-command for pinot-admin tool to rebalance a specific table
+ */
+public class RebalanceCommand extends AbstractBaseAdminCommand implements 
Command {
+
+  @Option(name = "-zkAddress", required = true, metaVar = "<http>", usage = 
"HTTP address of Zookeeper.")
+  private String _zkAddress;
+
+  @Option(name = "-clusterName", required = true, metaVar = "<String>", usage 
= "Pinot cluster name.")
+  private String _clusterName;
+
+  @Option(name = "-tableName", required = true, metaVar = "<String>", usage = 
"Name of the table to rebalance (e.g. myTable_OFFLINE)")
+  private String _tableName;
+
+  @Option(name = "-tableType", required = true, metaVar = "<String>", usage = 
"Type of table (OFFLINE or REALTIME)")
+  private String _tableType;
+
+  @Option(name = "-dryRun", required = false, metaVar = "<boolean>", usage = 
"Dry Run (just get the target ideal state without rebalancing)")
+  private boolean _dryRun;
+
+  @Option(name = "-includeConsuming", required = false, metaVar = "<boolean>", 
usage = "Should include consuming segments? Applicable only for realtime 
tables")
+  private boolean _includeConsuming;
+
+  @Option(name = "-noDowntime", required = false, metaVar = "<boolean>", usage 
= "Rebalance without downtime?")
+  private boolean _noDowntime;
+
+  @Option(name = "-minReplicasToKeepUpForNoDowntime", required = false, 
metaVar = "<int>", usage = "Minimum number of serving replicas that will be 
kept up for no downtime rebalancing")
+  private int _minReplicasForNoDowntime;
+
+  @Option(name = "-help", required = false, help = true, aliases = {"-h", 
"--h", "--help"}, usage = "Print this message.")
+  private boolean _help;
+
+  public boolean getHelp() {
+    return _help;
+  }
+
+  @Override
+  public String getName() {
+    return "rebalanceTable";
+  }
+
+  @Override
+  public boolean execute()
+      throws Exception {
+    final PinotTableRebalancer tableRebalancer =
+        new PinotTableRebalancer(_zkAddress, _clusterName, _dryRun, 
_noDowntime, _includeConsuming,
+            _minReplicasForNoDowntime);
+    return tableRebalancer.rebalance(_tableName, _tableType);
+  }
+
+  @Override
+  public String description() {
+    final String description =
+        "Rebalances segments of a table. " + "By default, rebalancing is done 
with downtime where there is no guarantee"
+            + "of any existing serving replica being alive for serving 
queries. "
+            + "Use the -nodowntime option to rebalance without downtime. It 
takes"
+            + "care of keeping at least 1 serving replica alive while 
rebalancing. "
+            + "For better QPS, use the -minReplicasForNoDowntime <val> option 
along with"
+            + "-nodowntime to ensure that rebalancer keeps at least the 
required number of "
+            + "replicas alive for each segment while segments are being moved 
between hosts";
+    return description;
+  }
+
+  @Override
+  public void printUsage() {
 
 Review comment:
   printUsage() is overriden to also print some example usage of 
RebalanceCommand. So I let it print each option along with description by 
calling super.printUsage() and then print some sample usages.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to