You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/11/23 20:38:25 UTC

svn commit: r1544869 - /hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java

Author: stack
Date: Sat Nov 23 19:38:25 2013
New Revision: 1544869

URL: http://svn.apache.org/r1544869
Log:
HBASE-9992 [hbck] Refactor so that arbitrary -D cmdline options are included

Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1544869&r1=1544868&r2=1544869&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Sat Nov 23 19:38:25 2013
@@ -164,7 +164,7 @@ import com.google.protobuf.ServiceExcept
  */
 @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 Configure
     super(conf);
     errors = getErrorReporter(conf);
 
-    initialPoolNumThreads();
+    int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
+    executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck"));
   }
 
   /**
@@ -299,18 +300,6 @@ public class HBaseFsck extends Configure
   }
 
   /**
-   * 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.
    */
   private void loadDeployedRegions() throws IOException, InterruptedException {
@@ -3600,18 +3589,23 @@ public class HBaseFsck extends Configure
     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);
   }
 
-  @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();
-  }
+  /**
+   * 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 {
+      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 {