HBASE-12740 Improve performance of TestHBaseFsck

Signed-off-by: stack <stack@apache.org>

    Conflicts:

        hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
This commit is contained in:
stack 2014-12-30 14:32:16 -08:00
parent 1962d39bf6
commit ad7d7f5977
5 changed files with 253 additions and 248 deletions

View File

@ -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.InterruptedIOException;
@ -183,7 +184,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
@ -394,7 +395,8 @@ public class HBaseFsck extends Configured {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
unlockHbck();
IOUtils.closeStream(HBaseFsck.this);
unlockHbck();
}
});
LOG.debug("Launching hbck");
@ -610,6 +612,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;
@ -3963,6 +3970,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();
}
};
@ -4181,7 +4189,7 @@ public class HBaseFsck extends Configured {
setRetCode(code);
}
} finally {
IOUtils.cleanup(null, connection, meta, admin);
IOUtils.cleanup(null, this);
}
return this;
}

View File

@ -196,7 +196,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;
}
}

View File

@ -40,7 +40,7 @@ public class HbckTestingUtil {
public static HBaseFsck doFsck(
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,
@ -66,6 +66,7 @@ public class HbckTestingUtil {
fsck.includeTable(table);
}
fsck.onlineHbck();
fsck.close();
return fsck;
}

View File

@ -66,6 +66,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