HBASE-12740 Improve performance of TestHBaseFsck
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
57b1efaabe
commit
042743fff0
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -184,7 +185,7 @@ import com.google.protobuf.ServiceException;
|
|||
*/
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
|
||||
@InterfaceStability.Evolving
|
||||
public class HBaseFsck extends Configured {
|
||||
public class HBaseFsck extends Configured implements Closeable {
|
||||
public static final long DEFAULT_TIME_LAG = 60000; // default value of 1 minute
|
||||
public static final long DEFAULT_SLEEP_BEFORE_RERUN = 10000;
|
||||
private static final int MAX_NUM_THREADS = 50; // #threads to contact regions
|
||||
|
@ -395,6 +396,7 @@ public class HBaseFsck extends Configured {
|
|||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
IOUtils.closeStream(HBaseFsck.this);
|
||||
unlockHbck();
|
||||
}
|
||||
});
|
||||
|
@ -611,6 +613,11 @@ public class HBaseFsck extends Configured {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
IOUtils.cleanup(null, admin, meta, connection);
|
||||
}
|
||||
|
||||
private static class RegionBoundariesInformation {
|
||||
public byte [] regionName;
|
||||
public byte [] metaFirstKey;
|
||||
|
@ -4082,6 +4089,7 @@ public class HBaseFsck extends Configured {
|
|||
public int run(String[] args) throws Exception {
|
||||
HBaseFsck hbck = new HBaseFsck(getConf());
|
||||
hbck.exec(hbck.executor, args);
|
||||
hbck.close();
|
||||
return hbck.getRetCode();
|
||||
}
|
||||
};
|
||||
|
@ -4300,7 +4308,7 @@ public class HBaseFsck extends Configured {
|
|||
setRetCode(code);
|
||||
}
|
||||
} finally {
|
||||
IOUtils.cleanup(null, connection, meta, admin);
|
||||
IOUtils.cleanup(null, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class HBaseFsckRepair {
|
|||
HRegion region = HRegion.createHRegion(hri, root, conf, htd, null);
|
||||
|
||||
// Close the new region to flush to disk. Close log file too.
|
||||
region.close();
|
||||
HRegion.closeHRegion(region);
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,6 +66,7 @@ public class HbckTestingUtil {
|
|||
fsck.includeTable(table);
|
||||
}
|
||||
fsck.onlineHbck();
|
||||
fsck.close();
|
||||
return fsck;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@ import static org.junit.Assert.assertFalse;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.testclassification.MiscTests;
|
||||
import org.apache.hadoop.hbase.util.HBaseFsck;
|
||||
|
@ -67,6 +64,7 @@ public class TestOfflineMetaRebuildHole extends OfflineMetaRebuildTestCore {
|
|||
// attempt to rebuild meta table from scratch
|
||||
HBaseFsck fsck = new HBaseFsck(conf);
|
||||
assertFalse(fsck.rebuildMeta(false));
|
||||
fsck.close();
|
||||
|
||||
// bring up the minicluster
|
||||
TEST_UTIL.startMiniZKCluster(); // tables seem enabled by default
|
||||
|
|
Loading…
Reference in New Issue