HBASE-26475 The flush and compact methods in HTU should skip processing secondary replicas (#3868)
Signed-off-by: Xiaolin Ha <haxiaolin@apache.org>
This commit is contained in:
parent
b870b6d9ac
commit
1c48248ef8
|
@ -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,10 +708,12 @@ 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()) {
|
||||
if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
|
||||
r.compact(major);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call flushCache on all regions of the specified table.
|
||||
|
@ -716,11 +722,13 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of live region servers in the cluster currently.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,28 +753,30 @@ 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()) {
|
||||
for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
|
||||
for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
|
||||
if (RegionReplicaUtil.isDefaultReplica(r.getRegionInfo())) {
|
||||
r.compact(major);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call flushCache on all regions of the specified table.
|
||||
* @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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Number of live region servers in the cluster currently.
|
||||
|
|
Loading…
Reference in New Issue