NihalJain commented on code in PR #135:
URL: 
https://github.com/apache/hbase-operator-tools/pull/135#discussion_r1303241904


##########
hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java:
##########
@@ -450,42 +461,82 @@ List<Future<List<String>>> 
addMissingRegionsInMetaForTables(String... nameSpaceO
   }
 
   List<Long> assigns(Hbck hbck, String[] args) throws IOException {
+    // Init
     Options options = new Options();
     Option override = Option.builder("o").longOpt("override").build();
     Option inputFile = Option.builder("i").longOpt("inputFiles").build();
+    Option batchOpt = 
Option.builder("b").longOpt("batchSize").hasArg().type(Integer.class).build();
     options.addOption(override);
     options.addOption(inputFile);
-    // Parse command-line.
+    options.addOption(batchOpt);
+
+    // Parse command-line
     CommandLine commandLine = getCommandLine(args, options);
     if (commandLine == null) {
       return null;
     }
+
+    int batchSize = getBatchSize(batchOpt, commandLine);
     boolean overrideFlag = commandLine.hasOption(override.getOpt());
     boolean inputFileFlag = commandLine.hasOption(inputFile.getOpt());
+
     List<String> argList = commandLine.getArgList();
-    return hbck.assigns(getFromArgsOrFiles(argList, inputFileFlag), 
overrideFlag);
+    List<String> regionList = getFromArgsOrFiles(argList, inputFileFlag);
+
+    // Process here
+    if (batchSize == NO_BATCH_SIZE) {
+      return hbck.assigns(regionList, overrideFlag);
+    } else {
+      List<Long> pidList = new ArrayList<>(argList.size());
+      final List<List<String>> batch = Lists.partition(regionList, batchSize);
+      for (int i = 0; i < batch.size(); i++) {
+        LOG.info("Processing batch #" + i);
+        pidList.addAll(hbck.assigns(batch.get(i), overrideFlag));
+      }
+      return pidList;
+    }
   }
 
   List<Long> unassigns(Hbck hbck, String[] args) throws IOException {
+    // Init
     Options options = new Options();
     Option override = Option.builder("o").longOpt("override").build();
     Option inputFile = Option.builder("i").longOpt("inputFiles").build();
+    Option batchOpt = 
Option.builder("b").longOpt("batchSize").hasArg().type(Integer.class).build();
     options.addOption(override);
     options.addOption(inputFile);
-    // Parse command-line.
+    options.addOption(batchOpt);
+
+    // Parse command-line
     CommandLine commandLine = getCommandLine(args, options);
     if (commandLine == null) {
       return null;
     }
+
     boolean overrideFlag = commandLine.hasOption(override.getOpt());
     boolean inputFileFlag = commandLine.hasOption(inputFile.getOpt());
+    int batchSize = getBatchSize(batchOpt, commandLine);
+
     List<String> argList = commandLine.getArgList();

Review Comment:
   this variable is redundant now, can be removed!



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to