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:53:55 UTC
[hbase] branch branch-2.4 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 branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.4 by this push:
new e4ad6e9 HBASE-26475 The flush and compact methods in HTU should skip processing secondary replicas (#3868)
e4ad6e9 is described below
commit e4ad6e9f647dc07604b42733eecdff24dd30c519
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>
---
.../apache/hadoop/hbase/HBaseTestingUtility.java | 4 ----
.../org/apache/hadoop/hbase/MiniHBaseCluster.java | 25 +++++++++++++---------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index f130f31..204c75a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -1471,7 +1471,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
/**
* Flushes all caches in the mini hbase cluster
- * @throws IOException
*/
public void flush() throws IOException {
getMiniHBaseCluster().flushcache();
@@ -1479,7 +1478,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);
@@ -1487,7 +1485,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);
@@ -1495,7 +1492,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-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index f795eef..4942dc8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -24,9 +24,9 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
+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;
@@ -727,6 +727,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);
@@ -766,10 +769,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);
+ }
}
}
}
@@ -779,11 +783,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);
+ }
}
}
}