joshelser commented on a change in pull request #45: HBASE-23371 [HBCK2] 
Provide client side method for removing ghost regions in meta.
URL: 
https://github.com/apache/hbase-operator-tools/pull/45#discussion_r369679651
 
 

 ##########
 File path: hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
 ##########
 @@ -191,76 +189,63 @@ int setRegionState(ClusterConnection connection, String 
region,
     return report;
   }
 
-  List<String> addMissingRegionsInMeta(List<Path> regionsPath) throws 
IOException {
-    List<String> reAddedRegionsEncodedNames = new ArrayList<>();
+  Map<TableName, List<String>> extraRegionsInMeta(String[] args)
+      throws Exception {
+    Options options = new Options();
+    Option fixOption = Option.builder("f").longOpt("fix").build();
+    options.addOption(fixOption);
+    // Parse command-line.
+    CommandLineParser parser = new DefaultParser();
+    CommandLine commandLine;
+    commandLine = parser.parse(options, args, false);
+    boolean fix = commandLine.hasOption(fixOption.getOpt());
+    Map<TableName, List<String>> result = new HashMap<>();
     try (final FsRegionsMetaRecoverer fsRegionsMetaRecoverer =
-        new FsRegionsMetaRecoverer(this.conf)) {
-      for(Path regionPath : regionsPath){
-        fsRegionsMetaRecoverer.putRegionInfoFromHdfsInMeta(regionPath);
-        reAddedRegionsEncodedNames.add(regionPath.getName());
+      new FsRegionsMetaRecoverer(this.conf)) {
+      List<String> namespacesTables = 
formatNameSpaceTableParam(commandLine.getArgs());
+      Map<TableName, List<RegionInfo>> reportMap =
+        fsRegionsMetaRecoverer.reportTablesExtraRegions(namespacesTables);
+      final List<String> toFix = new ArrayList<>();
+      reportMap.entrySet().forEach( e -> {
+          result.put(e.getKey(),
+            
e.getValue().stream().map(r->r.getEncodedName()).collect(Collectors.toList()));
+          if(fix && e.getValue().size()>0){
+            toFix.add(e.getKey().getNameWithNamespaceInclAsString());
 
 Review comment:
   Answered elsewhere -- string is used to send both table name or namespace

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

Reply via email to