HBASE-9992 [hbck] Refactor so that arbitrary -D cmdline options are included
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1544870 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5824f11f55
commit
129ce2523d
|
@ -164,7 +164,7 @@ import com.google.protobuf.ServiceException;
|
|||
*/
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Evolving
|
||||
public class HBaseFsck extends Configured implements Tool {
|
||||
public class HBaseFsck extends Configured {
|
||||
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
|
||||
|
@ -267,7 +267,8 @@ public class HBaseFsck extends Configured implements Tool {
|
|||
super(conf);
|
||||
errors = getErrorReporter(conf);
|
||||
|
||||
initialPoolNumThreads();
|
||||
int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
|
||||
executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,18 +299,6 @@ public class HBaseFsck extends Configured implements Tool {
|
|||
connection = admin.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial numThreads for {@link #executor}
|
||||
*/
|
||||
private void initialPoolNumThreads() {
|
||||
if (executor != null) {
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
int numThreads = getConf().getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
|
||||
executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deployed regions according to the region servers.
|
||||
*/
|
||||
|
@ -3601,18 +3590,23 @@ public class HBaseFsck extends Configured implements Tool {
|
|||
URI defaultFs = hbasedir.getFileSystem(conf).getUri();
|
||||
FSUtils.setFsDefault(conf, new Path(defaultFs));
|
||||
|
||||
int ret = ToolRunner.run(new HBaseFsck(conf), args);
|
||||
int ret = ToolRunner.run(new HBaseFsckTool(conf), args);
|
||||
System.exit(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a Tool wrapper that gathers -Dxxx=yyy configuration settings from the command line.
|
||||
*/
|
||||
static class HBaseFsckTool extends Configured implements Tool {
|
||||
HBaseFsckTool(Configuration conf) { super(conf); }
|
||||
@Override
|
||||
public int run(String[] args) throws Exception {
|
||||
// reset the numThreads due to user may set it via generic options
|
||||
initialPoolNumThreads();
|
||||
|
||||
exec(executor, args);
|
||||
return getRetCode();
|
||||
HBaseFsck hbck = new HBaseFsck(getConf());
|
||||
hbck.exec(hbck.executor, args);
|
||||
return hbck.getRetCode();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public HBaseFsck exec(ExecutorService exec, String[] args) throws KeeperException, IOException,
|
||||
ServiceException, InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue