NihalJain commented on code in PR #135: URL: https://github.com/apache/hbase-operator-tools/pull/135#discussion_r1303266290
########## hbase-hbck2/README.md: ########## @@ -156,13 +157,18 @@ Command: If -i or --inputFiles is specified, pass one or more input file names. Each file contains encoded region names, one per line. For example: $ HBCK2 assigns -i fileName1 fileName2 + If -b or --batchSize is specified, the command processes those many + regions at a time in a batch-ed manner; Consider using this option, + if the list of regions is huge, to avoid CallTimeoutException. + $ HBCK2 assigns -i fileName1 fileName2 -b 500 bypass [OPTIONS] [<PID>...|-i <INPUT_FILE>...] Options: -o,--override override if procedure is running/stuck -r,--recursive bypass parent and its children. SLOW! EXPENSIVE! -w,--lockWait milliseconds to wait before giving up; default=1 -i,--inputFiles take one or more input files of PID's + -b,--batchSize number of procedure to process in a batch Review Comment: Done! ########## 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: Done! -- 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: issues-unsubscr...@hbase.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org