You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/11/23 10:31:51 UTC

[hbase] branch master updated: HBASE-26475 The flush and compact methods in HTU should skip processing secondary replicas (#3868)

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

zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c48248  HBASE-26475 The flush and compact methods in HTU should skip processing secondary replicas (#3868)
1c48248 is described below

commit 1c48248ef86cd72b11ed0e26710f4fd057e8b818
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Tue Nov 23 18:31:18 2021 +0800

    HBASE-26475 The flush and compact methods in HTU should skip processing secondary replicas (#3868)
    
    Signed-off-by: Xiaolin Ha <ha...@apache.org>
---
 .../hadoop/hbase/SingleProcessHBaseCluster.java    | 12 +++++++++--
 .../apache/hadoop/hbase/HBaseTestingUtility.java   |  4 ----
 .../org/apache/hadoop/hbase/MiniHBaseCluster.java  | 24 ++++++++++++++--------
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
index 7109175..af30b58 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
@@ -27,6 +27,7 @@ import java.util.Set;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
+import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegion.FlushResult;
@@ -664,6 +665,9 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
   }
 
   private void executeFlush(HRegion region) throws IOException {
+    if (!RegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {
+      return;
+    }
     // retry 5 times if we can not flush
     for (int i = 0; i < 5; i++) {
       FlushResult result = region.flush(true);
@@ -704,7 +708,9 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
   public void compact(boolean major) throws IOException {
     for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
       for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
-        r.compact(major);
+        if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
+          r.compact(major);
+        }
       }
     }
   }
@@ -716,7 +722,9 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
     for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
       for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
         if (r.getTableDescriptor().getTableName().equals(tableName)) {
-          r.compact(major);
+          if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
+            r.compact(major);
+          }
         }
       }
     }
diff --git a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 1821f70..8e054e8 100644
--- a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -1407,7 +1407,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
 
   /**
    * Flushes all caches in the mini hbase cluster
-   * @throws IOException
    */
   public void flush() throws IOException {
     getMiniHBaseCluster().flushcache();
@@ -1415,7 +1414,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
 
   /**
    * Flushes all caches in the mini hbase cluster
-   * @throws IOException
    */
   public void flush(TableName tableName) throws IOException {
     getMiniHBaseCluster().flushcache(tableName);
@@ -1423,7 +1421,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
 
   /**
    * Compact all regions in the mini hbase cluster
-   * @throws IOException
    */
   public void compact(boolean major) throws IOException {
     getMiniHBaseCluster().compact(major);
@@ -1431,7 +1428,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
 
   /**
    * Compact all of a table's reagion in the mini hbase cluster
-   * @throws IOException
    */
   public void compact(TableName tableName, boolean major) throws IOException {
     getMiniHBaseCluster().compact(tableName, major);
diff --git a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index 17d64b5..7b6c697 100644
--- a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -27,6 +27,7 @@ import java.util.Set;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.client.RegionInfoBuilder;
+import org.apache.hadoop.hbase.client.RegionReplicaUtil;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegion.FlushResult;
@@ -710,6 +711,9 @@ public class MiniHBaseCluster extends HBaseCluster {
   }
 
   private void executeFlush(HRegion region) throws IOException {
+    if (!RegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {
+      return;
+    }
     // retry 5 times if we can not flush
     for (int i = 0; i < 5; i++) {
       FlushResult result = region.flush(true);
@@ -749,10 +753,11 @@ public class MiniHBaseCluster extends HBaseCluster {
    * @throws IOException
    */
   public void compact(boolean major) throws IOException {
-    for (JVMClusterUtil.RegionServerThread t:
-        this.hbaseCluster.getRegionServers()) {
-      for(HRegion r: t.getRegionServer().getOnlineRegionsLocalContext()) {
-        r.compact(major);
+    for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
+      for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
+        if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
+          r.compact(major);
+        }
       }
     }
   }
@@ -762,11 +767,12 @@ public class MiniHBaseCluster extends HBaseCluster {
    * @throws IOException
    */
   public void compact(TableName tableName, boolean major) throws IOException {
-    for (JVMClusterUtil.RegionServerThread t:
-        this.hbaseCluster.getRegionServers()) {
-      for(HRegion r: t.getRegionServer().getOnlineRegionsLocalContext()) {
-        if(r.getTableDescriptor().getTableName().equals(tableName)) {
-          r.compact(major);
+    for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
+      for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
+        if (r.getTableDescriptor().getTableName().equals(tableName)) {
+          if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
+            r.compact(major);
+          }
         }
       }
     }