From 4aa3600b7c85a6489aa235928ab486a2f7f04931 Mon Sep 17 00:00:00 2001 From: Jonathan Hsieh Date: Mon, 18 Nov 2013 20:21:25 +0000 Subject: [PATCH] HBASE-9831 'hbasefsck.numthreads' property isn't passed to hbck via cmdline -D option (Takeshi Miao) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1543137 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/util/HBaseFsck.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 09e3acdfef6..ea743eafe97 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -267,8 +267,7 @@ public class HBaseFsck extends Configured implements Tool { super(conf); errors = getErrorReporter(conf); - int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS); - executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck")); + initialPoolNumThreads(); } /** @@ -299,6 +298,18 @@ 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. */ @@ -3596,6 +3607,9 @@ public class HBaseFsck extends Configured implements Tool { @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(); }