This is an automated email from the ASF dual-hosted git repository.

wangzheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git


The following commit(s) were added to refs/heads/master by this push:
     new fd5a5fb  HBASE-28935 [HBCK2] filesystem command always report region 
hole and doesn't exit automatically (#147)
fd5a5fb is described below

commit fd5a5fb90755949a90c502c76de8313130403fa3
Author: haosen chen <[email protected]>
AuthorDate: Tue Nov 19 10:32:51 2024 +0800

    HBASE-28935 [HBCK2] filesystem command always report region hole and 
doesn't exit automatically (#147)
    
    Co-authored-by: haosenchen <[email protected]>
---
 hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java     | 6 ++++++
 hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java    | 6 +++++-
 .../src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java | 7 +++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java 
b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
index d2f63f9..d49cea5 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
@@ -77,6 +77,12 @@ public class FileSystemFsck implements Closeable {
        * hbaseFsck.setFixHdfsOrphans(fix); hbaseFsck.setFixHdfsHoles(fix);
        * hbaseFsck.setFixHdfsOverlaps(fix); hbaseFsck.setFixTableOrphans(fix);
        */
+      if (!tables.isEmpty()) {
+        
tables.stream().map(TableName::valueOf).forEach(hbaseFsck::includeTable);
+      }
+      if (!tableDirs.isEmpty()) {
+        tableDirs.forEach(hbaseFsck::includeTableDir);
+      }
       hbaseFsck.offlineHbck();
     } catch (ClassNotFoundException | InterruptedException e) {
       throw new IOException(e);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java 
b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
index 2fb31f2..860b736 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
@@ -374,7 +374,7 @@ public class HBaseFsck extends Configured implements 
Closeable {
   private static ExecutorService createThreadPool(Configuration conf) {
     int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
     return new ScheduledThreadPoolExecutor(numThreads,
-      new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d")
+      new ThreadFactoryBuilder().setNameFormat("hbasefsck-%d").setDaemon(true)
         
.setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
   }
 
@@ -4990,6 +4990,10 @@ public class HBaseFsck extends Configured implements 
Closeable {
     return new HashSet<>(tablesIncluded);
   }
 
+  public void includeTableDir(Path tableDir) {
+    tableDirs.add(tableDir);
+  }
+
   /**
    * We are interested in only those tables that have not changed their state 
in hbase:meta during
    * the last few seconds specified by hbase.admin.fsck.timelag
diff --git 
a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java 
b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
index ec56b94..3dd8f05 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java
@@ -32,6 +32,9 @@ import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.util.Properties;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -61,6 +64,10 @@ public class TestHBCKCommandLineParsing {
   @Before
   public void before() throws Exception {
     this.hbck2 = new HBCK2(TEST_UTIL.getConfiguration());
+    if (!TEST_UTIL.getAdmin().tableExists(TableName.valueOf("table"))) {
+      
TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf("table"))
+        .setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).build());
+    }
   }
 
   @Test

Reply via email to