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