HBASE-19812 TestFlushSnapshotFromClient fails because of failing region.flush
This commit is contained in:
parent
0f2c1fa066
commit
d7e2e0d02c
|
@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.hbase.master.HMaster;
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
|
import org.apache.hadoop.hbase.regionserver.HRegion.FlushResult;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
import org.apache.hadoop.hbase.regionserver.Region;
|
import org.apache.hadoop.hbase.regionserver.Region;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
|
@ -386,7 +387,6 @@ public class MiniHBaseCluster extends HBaseCluster {
|
||||||
* within the timeout.
|
* within the timeout.
|
||||||
*
|
*
|
||||||
* @return New RegionServerThread
|
* @return New RegionServerThread
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public JVMClusterUtil.RegionServerThread startRegionServerAndWait(long timeout)
|
public JVMClusterUtil.RegionServerThread startRegionServerAndWait(long timeout)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -463,7 +463,6 @@ public class MiniHBaseCluster extends HBaseCluster {
|
||||||
/**
|
/**
|
||||||
* Starts a master thread running
|
* Starts a master thread running
|
||||||
*
|
*
|
||||||
* @throws IOException
|
|
||||||
* @return New RegionServerThread
|
* @return New RegionServerThread
|
||||||
*/
|
*/
|
||||||
public JVMClusterUtil.MasterThread startMaster() throws IOException {
|
public JVMClusterUtil.MasterThread startMaster() throws IOException {
|
||||||
|
@ -615,9 +614,7 @@ public class MiniHBaseCluster extends HBaseCluster {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shut down the mini HBase cluster
|
* Shut down the mini HBase cluster
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void shutdown() throws IOException {
|
public void shutdown() throws IOException {
|
||||||
if (this.hbaseCluster != null) {
|
if (this.hbaseCluster != null) {
|
||||||
this.hbaseCluster.shutdown();
|
this.hbaseCluster.shutdown();
|
||||||
|
@ -644,29 +641,36 @@ public class MiniHBaseCluster extends HBaseCluster {
|
||||||
return master == null ? null : master.getClusterMetrics();
|
return master == null ? null : master.getClusterMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void executeFlush(HRegion region) throws IOException {
|
||||||
|
// retry 5 times if we can not flush
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
FlushResult result = region.flush(true);
|
||||||
|
if (result.getResult() != FlushResult.Result.CANNOT_FLUSH) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Threads.sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call flushCache on all regions on all participating regionservers.
|
* Call flushCache on all regions on all participating regionservers.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void flushcache() throws IOException {
|
public void flushcache() throws IOException {
|
||||||
for (JVMClusterUtil.RegionServerThread t:
|
for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
|
||||||
this.hbaseCluster.getRegionServers()) {
|
|
||||||
for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
|
for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
|
||||||
r.flush(true);
|
executeFlush(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call flushCache on all regions of the specified table.
|
* Call flushCache on all regions of the specified table.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void flushcache(TableName tableName) throws IOException {
|
public void flushcache(TableName tableName) throws IOException {
|
||||||
for (JVMClusterUtil.RegionServerThread t:
|
for (JVMClusterUtil.RegionServerThread t : this.hbaseCluster.getRegionServers()) {
|
||||||
this.hbaseCluster.getRegionServers()) {
|
|
||||||
for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
|
for (HRegion r : t.getRegionServer().getOnlineRegionsLocalContext()) {
|
||||||
if (r.getTableDescriptor().getTableName().equals(tableName)) {
|
if (r.getTableDescriptor().getTableName().equals(tableName)) {
|
||||||
r.flush(true);
|
executeFlush(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue