HBASE-4506 [hbck] Allow HBaseFsck to be instantiated without connecting
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1177896 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
39c0909e3e
commit
5bbed78d73
|
@ -683,6 +683,8 @@ Release 0.90.5 - Unreleased
|
||||||
HBASE-4295 rowcounter does not return the correct number of rows in
|
HBASE-4295 rowcounter does not return the correct number of rows in
|
||||||
certain circumstances (David Revell)
|
certain circumstances (David Revell)
|
||||||
HBASE-4515 User.getCurrent() can fail to initialize the current user
|
HBASE-4515 User.getCurrent() can fail to initialize the current user
|
||||||
|
HBASE-4506 [hbck] Allow HBaseFsck to be instantiated without connecting
|
||||||
|
(Jonathan Hsieh)
|
||||||
|
|
||||||
IMPROVEMENT
|
IMPROVEMENT
|
||||||
HBASE-4205 Enhance HTable javadoc (Eric Charles)
|
HBASE-4205 Enhance HTable javadoc (Eric Charles)
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class HBaseFsck {
|
||||||
// Empty regioninfo qualifiers in .META.
|
// Empty regioninfo qualifiers in .META.
|
||||||
private Set<Result> emptyRegionInfoQualifiers = new HashSet<Result>();
|
private Set<Result> emptyRegionInfoQualifiers = new HashSet<Result>();
|
||||||
private int numThreads = MAX_NUM_THREADS;
|
private int numThreads = MAX_NUM_THREADS;
|
||||||
private final HBaseAdmin admin;
|
private HBaseAdmin admin;
|
||||||
|
|
||||||
ThreadPoolExecutor executor; // threads to retrieve data from regionservers
|
ThreadPoolExecutor executor; // threads to retrieve data from regionservers
|
||||||
|
|
||||||
|
@ -117,18 +117,21 @@ public class HBaseFsck {
|
||||||
* @throws MasterNotRunningException if the master is not running
|
* @throws MasterNotRunningException if the master is not running
|
||||||
* @throws ZooKeeperConnectionException if unable to connect to zookeeper
|
* @throws ZooKeeperConnectionException if unable to connect to zookeeper
|
||||||
*/
|
*/
|
||||||
public HBaseFsck(Configuration conf)
|
public HBaseFsck(Configuration conf) throws MasterNotRunningException,
|
||||||
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
|
ZooKeeperConnectionException, IOException {
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
|
|
||||||
admin = new HBaseAdmin(conf);
|
|
||||||
status = admin.getMaster().getClusterStatus();
|
|
||||||
connection = admin.getConnection();
|
|
||||||
|
|
||||||
numThreads = conf.getInt("hbasefsck.numthreads", numThreads);
|
numThreads = conf.getInt("hbasefsck.numthreads", numThreads);
|
||||||
executor = new ThreadPoolExecutor(0, numThreads,
|
executor = new ThreadPoolExecutor(0, numThreads,
|
||||||
THREADS_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS,
|
THREADS_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS,
|
||||||
new LinkedBlockingQueue<Runnable>());
|
new LinkedBlockingQueue<Runnable>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect() throws MasterNotRunningException,
|
||||||
|
ZooKeeperConnectionException {
|
||||||
|
admin = new HBaseAdmin(conf);
|
||||||
|
status = admin.getMaster().getClusterStatus();
|
||||||
|
connection = admin.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1337,11 +1340,11 @@ public class HBaseFsck {
|
||||||
* @param args
|
* @param args
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void main(String [] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
// create a fsck object
|
// create a fsck object
|
||||||
Configuration conf = HBaseConfiguration.create();
|
Configuration conf = HBaseConfiguration.create();
|
||||||
conf.set("fs.defaultFS", conf.get("hbase.rootdir"));
|
conf.set("fs.defaultFS", conf.get(HConstants.HBASE_DIR));
|
||||||
HBaseFsck fsck = new HBaseFsck(conf);
|
HBaseFsck fsck = new HBaseFsck(conf);
|
||||||
long sleepBeforeRerun = DEFAULT_SLEEP_BEFORE_RERUN;
|
long sleepBeforeRerun = DEFAULT_SLEEP_BEFORE_RERUN;
|
||||||
|
|
||||||
|
@ -1389,6 +1392,7 @@ public class HBaseFsck {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do the real work of fsck
|
// do the real work of fsck
|
||||||
|
fsck.connect();
|
||||||
int code = fsck.doWork();
|
int code = fsck.doWork();
|
||||||
// If we have changed the HBase state it is better to run fsck again
|
// If we have changed the HBase state it is better to run fsck again
|
||||||
// to see if we haven't broken something else in the process.
|
// to see if we haven't broken something else in the process.
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class TestHBaseFsck {
|
||||||
|
|
||||||
private List<ERROR_CODE> doFsck(boolean fix) throws Exception {
|
private List<ERROR_CODE> doFsck(boolean fix) throws Exception {
|
||||||
HBaseFsck fsck = new HBaseFsck(conf);
|
HBaseFsck fsck = new HBaseFsck(conf);
|
||||||
|
fsck.connect();
|
||||||
fsck.displayFullReport(); // i.e. -details
|
fsck.displayFullReport(); // i.e. -details
|
||||||
fsck.setTimeLag(0);
|
fsck.setTimeLag(0);
|
||||||
fsck.setFixErrors(fix);
|
fsck.setFixErrors(fix);
|
||||||
|
|
Loading…
Reference in New Issue