hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [04/14] hbase-site git commit: Published site at .
Date Mon, 04 Dec 2017 15:22:32 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/29385b7e/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html
index 0cec549..06b92ba 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/HBaseTestingUtility.PortAllocator.html
@@ -2518,1796 +2518,1811 @@
 <span class="sourceLineNo">2510</span>    return rows;<a name="line.2510"></a>
 <span class="sourceLineNo">2511</span>  }<a name="line.2511"></a>
 <span class="sourceLineNo">2512</span><a name="line.2512"></a>
-<span class="sourceLineNo">2513</span>  /**<a name="line.2513"></a>
-<span class="sourceLineNo">2514</span>   * Tool to get the reference to the region server object that holds the<a name="line.2514"></a>
-<span class="sourceLineNo">2515</span>   * region of the specified user table.<a name="line.2515"></a>
-<span class="sourceLineNo">2516</span>   * It first searches for the meta rows that contain the region of the<a name="line.2516"></a>
-<span class="sourceLineNo">2517</span>   * specified table, then gets the index of that RS, and finally retrieves<a name="line.2517"></a>
-<span class="sourceLineNo">2518</span>   * the RS's reference.<a name="line.2518"></a>
-<span class="sourceLineNo">2519</span>   * @param tableName user table to lookup in hbase:meta<a name="line.2519"></a>
-<span class="sourceLineNo">2520</span>   * @return region server that holds it, null if the row doesn't exist<a name="line.2520"></a>
-<span class="sourceLineNo">2521</span>   * @throws IOException<a name="line.2521"></a>
-<span class="sourceLineNo">2522</span>   * @throws InterruptedException<a name="line.2522"></a>
-<span class="sourceLineNo">2523</span>   */<a name="line.2523"></a>
-<span class="sourceLineNo">2524</span>  public HRegionServer getRSForFirstRegionInTable(TableName tableName)<a name="line.2524"></a>
-<span class="sourceLineNo">2525</span>      throws IOException, InterruptedException {<a name="line.2525"></a>
-<span class="sourceLineNo">2526</span>    List&lt;byte[]&gt; metaRows = getMetaTableRows(tableName);<a name="line.2526"></a>
-<span class="sourceLineNo">2527</span>    if (metaRows == null || metaRows.isEmpty()) {<a name="line.2527"></a>
-<span class="sourceLineNo">2528</span>      return null;<a name="line.2528"></a>
-<span class="sourceLineNo">2529</span>    }<a name="line.2529"></a>
-<span class="sourceLineNo">2530</span>    LOG.debug("Found " + metaRows.size() + " rows for table " +<a name="line.2530"></a>
-<span class="sourceLineNo">2531</span>      tableName);<a name="line.2531"></a>
-<span class="sourceLineNo">2532</span>    byte [] firstrow = metaRows.get(0);<a name="line.2532"></a>
-<span class="sourceLineNo">2533</span>    LOG.debug("FirstRow=" + Bytes.toString(firstrow));<a name="line.2533"></a>
-<span class="sourceLineNo">2534</span>    long pause = getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE,<a name="line.2534"></a>
-<span class="sourceLineNo">2535</span>      HConstants.DEFAULT_HBASE_CLIENT_PAUSE);<a name="line.2535"></a>
-<span class="sourceLineNo">2536</span>    int numRetries = getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,<a name="line.2536"></a>
-<span class="sourceLineNo">2537</span>      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);<a name="line.2537"></a>
-<span class="sourceLineNo">2538</span>    RetryCounter retrier = new RetryCounter(numRetries+1, (int)pause, TimeUnit.MICROSECONDS);<a name="line.2538"></a>
-<span class="sourceLineNo">2539</span>    while(retrier.shouldRetry()) {<a name="line.2539"></a>
-<span class="sourceLineNo">2540</span>      int index = getMiniHBaseCluster().getServerWith(firstrow);<a name="line.2540"></a>
-<span class="sourceLineNo">2541</span>      if (index != -1) {<a name="line.2541"></a>
-<span class="sourceLineNo">2542</span>        return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();<a name="line.2542"></a>
-<span class="sourceLineNo">2543</span>      }<a name="line.2543"></a>
-<span class="sourceLineNo">2544</span>      // Came back -1.  Region may not be online yet.  Sleep a while.<a name="line.2544"></a>
-<span class="sourceLineNo">2545</span>      retrier.sleepUntilNextRetry();<a name="line.2545"></a>
-<span class="sourceLineNo">2546</span>    }<a name="line.2546"></a>
-<span class="sourceLineNo">2547</span>    return null;<a name="line.2547"></a>
-<span class="sourceLineNo">2548</span>  }<a name="line.2548"></a>
-<span class="sourceLineNo">2549</span><a name="line.2549"></a>
-<span class="sourceLineNo">2550</span>  /**<a name="line.2550"></a>
-<span class="sourceLineNo">2551</span>   * Starts a &lt;code&gt;MiniMRCluster&lt;/code&gt; with a default number of<a name="line.2551"></a>
-<span class="sourceLineNo">2552</span>   * &lt;code&gt;TaskTracker&lt;/code&gt;'s.<a name="line.2552"></a>
-<span class="sourceLineNo">2553</span>   *<a name="line.2553"></a>
-<span class="sourceLineNo">2554</span>   * @throws IOException When starting the cluster fails.<a name="line.2554"></a>
-<span class="sourceLineNo">2555</span>   */<a name="line.2555"></a>
-<span class="sourceLineNo">2556</span>  public MiniMRCluster startMiniMapReduceCluster() throws IOException {<a name="line.2556"></a>
-<span class="sourceLineNo">2557</span>    // Set a very high max-disk-utilization percentage to avoid the NodeManagers from failing.<a name="line.2557"></a>
-<span class="sourceLineNo">2558</span>    conf.setIfUnset(<a name="line.2558"></a>
-<span class="sourceLineNo">2559</span>        "yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage",<a name="line.2559"></a>
-<span class="sourceLineNo">2560</span>        "99.0");<a name="line.2560"></a>
-<span class="sourceLineNo">2561</span>    startMiniMapReduceCluster(2);<a name="line.2561"></a>
-<span class="sourceLineNo">2562</span>    return mrCluster;<a name="line.2562"></a>
+<span class="sourceLineNo">2513</span>  /*<a name="line.2513"></a>
+<span class="sourceLineNo">2514</span>   * Find any other region server which is different from the one identified by parameter<a name="line.2514"></a>
+<span class="sourceLineNo">2515</span>   * @param rs<a name="line.2515"></a>
+<span class="sourceLineNo">2516</span>   * @return another region server<a name="line.2516"></a>
+<span class="sourceLineNo">2517</span>   */<a name="line.2517"></a>
+<span class="sourceLineNo">2518</span>  public HRegionServer getOtherRegionServer(HRegionServer rs) {<a name="line.2518"></a>
+<span class="sourceLineNo">2519</span>    for (JVMClusterUtil.RegionServerThread rst :<a name="line.2519"></a>
+<span class="sourceLineNo">2520</span>      getMiniHBaseCluster().getRegionServerThreads()) {<a name="line.2520"></a>
+<span class="sourceLineNo">2521</span>      if (!(rst.getRegionServer() == rs)) {<a name="line.2521"></a>
+<span class="sourceLineNo">2522</span>        return rst.getRegionServer();<a name="line.2522"></a>
+<span class="sourceLineNo">2523</span>      }<a name="line.2523"></a>
+<span class="sourceLineNo">2524</span>    }<a name="line.2524"></a>
+<span class="sourceLineNo">2525</span>    return null;<a name="line.2525"></a>
+<span class="sourceLineNo">2526</span>  }<a name="line.2526"></a>
+<span class="sourceLineNo">2527</span><a name="line.2527"></a>
+<span class="sourceLineNo">2528</span>  /**<a name="line.2528"></a>
+<span class="sourceLineNo">2529</span>   * Tool to get the reference to the region server object that holds the<a name="line.2529"></a>
+<span class="sourceLineNo">2530</span>   * region of the specified user table.<a name="line.2530"></a>
+<span class="sourceLineNo">2531</span>   * It first searches for the meta rows that contain the region of the<a name="line.2531"></a>
+<span class="sourceLineNo">2532</span>   * specified table, then gets the index of that RS, and finally retrieves<a name="line.2532"></a>
+<span class="sourceLineNo">2533</span>   * the RS's reference.<a name="line.2533"></a>
+<span class="sourceLineNo">2534</span>   * @param tableName user table to lookup in hbase:meta<a name="line.2534"></a>
+<span class="sourceLineNo">2535</span>   * @return region server that holds it, null if the row doesn't exist<a name="line.2535"></a>
+<span class="sourceLineNo">2536</span>   * @throws IOException<a name="line.2536"></a>
+<span class="sourceLineNo">2537</span>   * @throws InterruptedException<a name="line.2537"></a>
+<span class="sourceLineNo">2538</span>   */<a name="line.2538"></a>
+<span class="sourceLineNo">2539</span>  public HRegionServer getRSForFirstRegionInTable(TableName tableName)<a name="line.2539"></a>
+<span class="sourceLineNo">2540</span>      throws IOException, InterruptedException {<a name="line.2540"></a>
+<span class="sourceLineNo">2541</span>    List&lt;byte[]&gt; metaRows = getMetaTableRows(tableName);<a name="line.2541"></a>
+<span class="sourceLineNo">2542</span>    if (metaRows == null || metaRows.isEmpty()) {<a name="line.2542"></a>
+<span class="sourceLineNo">2543</span>      return null;<a name="line.2543"></a>
+<span class="sourceLineNo">2544</span>    }<a name="line.2544"></a>
+<span class="sourceLineNo">2545</span>    LOG.debug("Found " + metaRows.size() + " rows for table " +<a name="line.2545"></a>
+<span class="sourceLineNo">2546</span>      tableName);<a name="line.2546"></a>
+<span class="sourceLineNo">2547</span>    byte [] firstrow = metaRows.get(0);<a name="line.2547"></a>
+<span class="sourceLineNo">2548</span>    LOG.debug("FirstRow=" + Bytes.toString(firstrow));<a name="line.2548"></a>
+<span class="sourceLineNo">2549</span>    long pause = getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE,<a name="line.2549"></a>
+<span class="sourceLineNo">2550</span>      HConstants.DEFAULT_HBASE_CLIENT_PAUSE);<a name="line.2550"></a>
+<span class="sourceLineNo">2551</span>    int numRetries = getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,<a name="line.2551"></a>
+<span class="sourceLineNo">2552</span>      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);<a name="line.2552"></a>
+<span class="sourceLineNo">2553</span>    RetryCounter retrier = new RetryCounter(numRetries+1, (int)pause, TimeUnit.MICROSECONDS);<a name="line.2553"></a>
+<span class="sourceLineNo">2554</span>    while(retrier.shouldRetry()) {<a name="line.2554"></a>
+<span class="sourceLineNo">2555</span>      int index = getMiniHBaseCluster().getServerWith(firstrow);<a name="line.2555"></a>
+<span class="sourceLineNo">2556</span>      if (index != -1) {<a name="line.2556"></a>
+<span class="sourceLineNo">2557</span>        return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer();<a name="line.2557"></a>
+<span class="sourceLineNo">2558</span>      }<a name="line.2558"></a>
+<span class="sourceLineNo">2559</span>      // Came back -1.  Region may not be online yet.  Sleep a while.<a name="line.2559"></a>
+<span class="sourceLineNo">2560</span>      retrier.sleepUntilNextRetry();<a name="line.2560"></a>
+<span class="sourceLineNo">2561</span>    }<a name="line.2561"></a>
+<span class="sourceLineNo">2562</span>    return null;<a name="line.2562"></a>
 <span class="sourceLineNo">2563</span>  }<a name="line.2563"></a>
 <span class="sourceLineNo">2564</span><a name="line.2564"></a>
 <span class="sourceLineNo">2565</span>  /**<a name="line.2565"></a>
-<span class="sourceLineNo">2566</span>   * Tasktracker has a bug where changing the hadoop.log.dir system property<a name="line.2566"></a>
-<span class="sourceLineNo">2567</span>   * will not change its internal static LOG_DIR variable.<a name="line.2567"></a>
-<span class="sourceLineNo">2568</span>   */<a name="line.2568"></a>
-<span class="sourceLineNo">2569</span>  private void forceChangeTaskLogDir() {<a name="line.2569"></a>
-<span class="sourceLineNo">2570</span>    Field logDirField;<a name="line.2570"></a>
-<span class="sourceLineNo">2571</span>    try {<a name="line.2571"></a>
-<span class="sourceLineNo">2572</span>      logDirField = TaskLog.class.getDeclaredField("LOG_DIR");<a name="line.2572"></a>
-<span class="sourceLineNo">2573</span>      logDirField.setAccessible(true);<a name="line.2573"></a>
-<span class="sourceLineNo">2574</span><a name="line.2574"></a>
-<span class="sourceLineNo">2575</span>      Field modifiersField = Field.class.getDeclaredField("modifiers");<a name="line.2575"></a>
-<span class="sourceLineNo">2576</span>      modifiersField.setAccessible(true);<a name="line.2576"></a>
-<span class="sourceLineNo">2577</span>      modifiersField.setInt(logDirField, logDirField.getModifiers() &amp; ~Modifier.FINAL);<a name="line.2577"></a>
-<span class="sourceLineNo">2578</span><a name="line.2578"></a>
-<span class="sourceLineNo">2579</span>      logDirField.set(null, new File(hadoopLogDir, "userlogs"));<a name="line.2579"></a>
-<span class="sourceLineNo">2580</span>    } catch (SecurityException e) {<a name="line.2580"></a>
-<span class="sourceLineNo">2581</span>      throw new RuntimeException(e);<a name="line.2581"></a>
-<span class="sourceLineNo">2582</span>    } catch (NoSuchFieldException e) {<a name="line.2582"></a>
-<span class="sourceLineNo">2583</span>      // TODO Auto-generated catch block<a name="line.2583"></a>
-<span class="sourceLineNo">2584</span>      throw new RuntimeException(e);<a name="line.2584"></a>
-<span class="sourceLineNo">2585</span>    } catch (IllegalArgumentException e) {<a name="line.2585"></a>
-<span class="sourceLineNo">2586</span>      throw new RuntimeException(e);<a name="line.2586"></a>
-<span class="sourceLineNo">2587</span>    } catch (IllegalAccessException e) {<a name="line.2587"></a>
-<span class="sourceLineNo">2588</span>      throw new RuntimeException(e);<a name="line.2588"></a>
-<span class="sourceLineNo">2589</span>    }<a name="line.2589"></a>
-<span class="sourceLineNo">2590</span>  }<a name="line.2590"></a>
-<span class="sourceLineNo">2591</span><a name="line.2591"></a>
-<span class="sourceLineNo">2592</span>  /**<a name="line.2592"></a>
-<span class="sourceLineNo">2593</span>   * Starts a &lt;code&gt;MiniMRCluster&lt;/code&gt;. Call {@link #setFileSystemURI(String)} to use a different<a name="line.2593"></a>
-<span class="sourceLineNo">2594</span>   * filesystem.<a name="line.2594"></a>
-<span class="sourceLineNo">2595</span>   * @param servers  The number of &lt;code&gt;TaskTracker&lt;/code&gt;'s to start.<a name="line.2595"></a>
-<span class="sourceLineNo">2596</span>   * @throws IOException When starting the cluster fails.<a name="line.2596"></a>
-<span class="sourceLineNo">2597</span>   */<a name="line.2597"></a>
-<span class="sourceLineNo">2598</span>  private void startMiniMapReduceCluster(final int servers) throws IOException {<a name="line.2598"></a>
-<span class="sourceLineNo">2599</span>    if (mrCluster != null) {<a name="line.2599"></a>
-<span class="sourceLineNo">2600</span>      throw new IllegalStateException("MiniMRCluster is already running");<a name="line.2600"></a>
-<span class="sourceLineNo">2601</span>    }<a name="line.2601"></a>
-<span class="sourceLineNo">2602</span>    LOG.info("Starting mini mapreduce cluster...");<a name="line.2602"></a>
-<span class="sourceLineNo">2603</span>    setupClusterTestDir();<a name="line.2603"></a>
-<span class="sourceLineNo">2604</span>    createDirsAndSetProperties();<a name="line.2604"></a>
-<span class="sourceLineNo">2605</span><a name="line.2605"></a>
-<span class="sourceLineNo">2606</span>    forceChangeTaskLogDir();<a name="line.2606"></a>
-<span class="sourceLineNo">2607</span><a name="line.2607"></a>
-<span class="sourceLineNo">2608</span>    //// hadoop2 specific settings<a name="line.2608"></a>
-<span class="sourceLineNo">2609</span>    // Tests were failing because this process used 6GB of virtual memory and was getting killed.<a name="line.2609"></a>
-<span class="sourceLineNo">2610</span>    // we up the VM usable so that processes don't get killed.<a name="line.2610"></a>
-<span class="sourceLineNo">2611</span>    conf.setFloat("yarn.nodemanager.vmem-pmem-ratio", 8.0f);<a name="line.2611"></a>
-<span class="sourceLineNo">2612</span><a name="line.2612"></a>
-<span class="sourceLineNo">2613</span>    // Tests were failing due to MAPREDUCE-4880 / MAPREDUCE-4607 against hadoop 2.0.2-alpha and<a name="line.2613"></a>
-<span class="sourceLineNo">2614</span>    // this avoids the problem by disabling speculative task execution in tests.<a name="line.2614"></a>
-<span class="sourceLineNo">2615</span>    conf.setBoolean("mapreduce.map.speculative", false);<a name="line.2615"></a>
-<span class="sourceLineNo">2616</span>    conf.setBoolean("mapreduce.reduce.speculative", false);<a name="line.2616"></a>
-<span class="sourceLineNo">2617</span>    ////<a name="line.2617"></a>
-<span class="sourceLineNo">2618</span><a name="line.2618"></a>
-<span class="sourceLineNo">2619</span>    // Allow the user to override FS URI for this map-reduce cluster to use.<a name="line.2619"></a>
-<span class="sourceLineNo">2620</span>    mrCluster = new MiniMRCluster(servers,<a name="line.2620"></a>
-<span class="sourceLineNo">2621</span>      FS_URI != null ? FS_URI : FileSystem.get(conf).getUri().toString(), 1,<a name="line.2621"></a>
-<span class="sourceLineNo">2622</span>      null, null, new JobConf(this.conf));<a name="line.2622"></a>
-<span class="sourceLineNo">2623</span>    JobConf jobConf = MapreduceTestingShim.getJobConf(mrCluster);<a name="line.2623"></a>
-<span class="sourceLineNo">2624</span>    if (jobConf == null) {<a name="line.2624"></a>
-<span class="sourceLineNo">2625</span>      jobConf = mrCluster.createJobConf();<a name="line.2625"></a>
-<span class="sourceLineNo">2626</span>    }<a name="line.2626"></a>
+<span class="sourceLineNo">2566</span>   * Starts a &lt;code&gt;MiniMRCluster&lt;/code&gt; with a default number of<a name="line.2566"></a>
+<span class="sourceLineNo">2567</span>   * &lt;code&gt;TaskTracker&lt;/code&gt;'s.<a name="line.2567"></a>
+<span class="sourceLineNo">2568</span>   *<a name="line.2568"></a>
+<span class="sourceLineNo">2569</span>   * @throws IOException When starting the cluster fails.<a name="line.2569"></a>
+<span class="sourceLineNo">2570</span>   */<a name="line.2570"></a>
+<span class="sourceLineNo">2571</span>  public MiniMRCluster startMiniMapReduceCluster() throws IOException {<a name="line.2571"></a>
+<span class="sourceLineNo">2572</span>    // Set a very high max-disk-utilization percentage to avoid the NodeManagers from failing.<a name="line.2572"></a>
+<span class="sourceLineNo">2573</span>    conf.setIfUnset(<a name="line.2573"></a>
+<span class="sourceLineNo">2574</span>        "yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage",<a name="line.2574"></a>
+<span class="sourceLineNo">2575</span>        "99.0");<a name="line.2575"></a>
+<span class="sourceLineNo">2576</span>    startMiniMapReduceCluster(2);<a name="line.2576"></a>
+<span class="sourceLineNo">2577</span>    return mrCluster;<a name="line.2577"></a>
+<span class="sourceLineNo">2578</span>  }<a name="line.2578"></a>
+<span class="sourceLineNo">2579</span><a name="line.2579"></a>
+<span class="sourceLineNo">2580</span>  /**<a name="line.2580"></a>
+<span class="sourceLineNo">2581</span>   * Tasktracker has a bug where changing the hadoop.log.dir system property<a name="line.2581"></a>
+<span class="sourceLineNo">2582</span>   * will not change its internal static LOG_DIR variable.<a name="line.2582"></a>
+<span class="sourceLineNo">2583</span>   */<a name="line.2583"></a>
+<span class="sourceLineNo">2584</span>  private void forceChangeTaskLogDir() {<a name="line.2584"></a>
+<span class="sourceLineNo">2585</span>    Field logDirField;<a name="line.2585"></a>
+<span class="sourceLineNo">2586</span>    try {<a name="line.2586"></a>
+<span class="sourceLineNo">2587</span>      logDirField = TaskLog.class.getDeclaredField("LOG_DIR");<a name="line.2587"></a>
+<span class="sourceLineNo">2588</span>      logDirField.setAccessible(true);<a name="line.2588"></a>
+<span class="sourceLineNo">2589</span><a name="line.2589"></a>
+<span class="sourceLineNo">2590</span>      Field modifiersField = Field.class.getDeclaredField("modifiers");<a name="line.2590"></a>
+<span class="sourceLineNo">2591</span>      modifiersField.setAccessible(true);<a name="line.2591"></a>
+<span class="sourceLineNo">2592</span>      modifiersField.setInt(logDirField, logDirField.getModifiers() &amp; ~Modifier.FINAL);<a name="line.2592"></a>
+<span class="sourceLineNo">2593</span><a name="line.2593"></a>
+<span class="sourceLineNo">2594</span>      logDirField.set(null, new File(hadoopLogDir, "userlogs"));<a name="line.2594"></a>
+<span class="sourceLineNo">2595</span>    } catch (SecurityException e) {<a name="line.2595"></a>
+<span class="sourceLineNo">2596</span>      throw new RuntimeException(e);<a name="line.2596"></a>
+<span class="sourceLineNo">2597</span>    } catch (NoSuchFieldException e) {<a name="line.2597"></a>
+<span class="sourceLineNo">2598</span>      // TODO Auto-generated catch block<a name="line.2598"></a>
+<span class="sourceLineNo">2599</span>      throw new RuntimeException(e);<a name="line.2599"></a>
+<span class="sourceLineNo">2600</span>    } catch (IllegalArgumentException e) {<a name="line.2600"></a>
+<span class="sourceLineNo">2601</span>      throw new RuntimeException(e);<a name="line.2601"></a>
+<span class="sourceLineNo">2602</span>    } catch (IllegalAccessException e) {<a name="line.2602"></a>
+<span class="sourceLineNo">2603</span>      throw new RuntimeException(e);<a name="line.2603"></a>
+<span class="sourceLineNo">2604</span>    }<a name="line.2604"></a>
+<span class="sourceLineNo">2605</span>  }<a name="line.2605"></a>
+<span class="sourceLineNo">2606</span><a name="line.2606"></a>
+<span class="sourceLineNo">2607</span>  /**<a name="line.2607"></a>
+<span class="sourceLineNo">2608</span>   * Starts a &lt;code&gt;MiniMRCluster&lt;/code&gt;. Call {@link #setFileSystemURI(String)} to use a different<a name="line.2608"></a>
+<span class="sourceLineNo">2609</span>   * filesystem.<a name="line.2609"></a>
+<span class="sourceLineNo">2610</span>   * @param servers  The number of &lt;code&gt;TaskTracker&lt;/code&gt;'s to start.<a name="line.2610"></a>
+<span class="sourceLineNo">2611</span>   * @throws IOException When starting the cluster fails.<a name="line.2611"></a>
+<span class="sourceLineNo">2612</span>   */<a name="line.2612"></a>
+<span class="sourceLineNo">2613</span>  private void startMiniMapReduceCluster(final int servers) throws IOException {<a name="line.2613"></a>
+<span class="sourceLineNo">2614</span>    if (mrCluster != null) {<a name="line.2614"></a>
+<span class="sourceLineNo">2615</span>      throw new IllegalStateException("MiniMRCluster is already running");<a name="line.2615"></a>
+<span class="sourceLineNo">2616</span>    }<a name="line.2616"></a>
+<span class="sourceLineNo">2617</span>    LOG.info("Starting mini mapreduce cluster...");<a name="line.2617"></a>
+<span class="sourceLineNo">2618</span>    setupClusterTestDir();<a name="line.2618"></a>
+<span class="sourceLineNo">2619</span>    createDirsAndSetProperties();<a name="line.2619"></a>
+<span class="sourceLineNo">2620</span><a name="line.2620"></a>
+<span class="sourceLineNo">2621</span>    forceChangeTaskLogDir();<a name="line.2621"></a>
+<span class="sourceLineNo">2622</span><a name="line.2622"></a>
+<span class="sourceLineNo">2623</span>    //// hadoop2 specific settings<a name="line.2623"></a>
+<span class="sourceLineNo">2624</span>    // Tests were failing because this process used 6GB of virtual memory and was getting killed.<a name="line.2624"></a>
+<span class="sourceLineNo">2625</span>    // we up the VM usable so that processes don't get killed.<a name="line.2625"></a>
+<span class="sourceLineNo">2626</span>    conf.setFloat("yarn.nodemanager.vmem-pmem-ratio", 8.0f);<a name="line.2626"></a>
 <span class="sourceLineNo">2627</span><a name="line.2627"></a>
-<span class="sourceLineNo">2628</span>    jobConf.set("mapreduce.cluster.local.dir",<a name="line.2628"></a>
-<span class="sourceLineNo">2629</span>      conf.get("mapreduce.cluster.local.dir")); //Hadoop MiniMR overwrites this while it should not<a name="line.2629"></a>
-<span class="sourceLineNo">2630</span>    LOG.info("Mini mapreduce cluster started");<a name="line.2630"></a>
-<span class="sourceLineNo">2631</span><a name="line.2631"></a>
-<span class="sourceLineNo">2632</span>    // In hadoop2, YARN/MR2 starts a mini cluster with its own conf instance and updates settings.<a name="line.2632"></a>
-<span class="sourceLineNo">2633</span>    // Our HBase MR jobs need several of these settings in order to properly run.  So we copy the<a name="line.2633"></a>
-<span class="sourceLineNo">2634</span>    // necessary config properties here.  YARN-129 required adding a few properties.<a name="line.2634"></a>
-<span class="sourceLineNo">2635</span>    conf.set("mapreduce.jobtracker.address", jobConf.get("mapreduce.jobtracker.address"));<a name="line.2635"></a>
-<span class="sourceLineNo">2636</span>    // this for mrv2 support; mr1 ignores this<a name="line.2636"></a>
-<span class="sourceLineNo">2637</span>    conf.set("mapreduce.framework.name", "yarn");<a name="line.2637"></a>
-<span class="sourceLineNo">2638</span>    conf.setBoolean("yarn.is.minicluster", true);<a name="line.2638"></a>
-<span class="sourceLineNo">2639</span>    String rmAddress = jobConf.get("yarn.resourcemanager.address");<a name="line.2639"></a>
-<span class="sourceLineNo">2640</span>    if (rmAddress != null) {<a name="line.2640"></a>
-<span class="sourceLineNo">2641</span>      conf.set("yarn.resourcemanager.address", rmAddress);<a name="line.2641"></a>
-<span class="sourceLineNo">2642</span>    }<a name="line.2642"></a>
-<span class="sourceLineNo">2643</span>    String historyAddress = jobConf.get("mapreduce.jobhistory.address");<a name="line.2643"></a>
-<span class="sourceLineNo">2644</span>    if (historyAddress != null) {<a name="line.2644"></a>
-<span class="sourceLineNo">2645</span>      conf.set("mapreduce.jobhistory.address", historyAddress);<a name="line.2645"></a>
-<span class="sourceLineNo">2646</span>    }<a name="line.2646"></a>
-<span class="sourceLineNo">2647</span>    String schedulerAddress =<a name="line.2647"></a>
-<span class="sourceLineNo">2648</span>      jobConf.get("yarn.resourcemanager.scheduler.address");<a name="line.2648"></a>
-<span class="sourceLineNo">2649</span>    if (schedulerAddress != null) {<a name="line.2649"></a>
-<span class="sourceLineNo">2650</span>      conf.set("yarn.resourcemanager.scheduler.address", schedulerAddress);<a name="line.2650"></a>
-<span class="sourceLineNo">2651</span>    }<a name="line.2651"></a>
-<span class="sourceLineNo">2652</span>    String mrJobHistoryWebappAddress =<a name="line.2652"></a>
-<span class="sourceLineNo">2653</span>      jobConf.get("mapreduce.jobhistory.webapp.address");<a name="line.2653"></a>
-<span class="sourceLineNo">2654</span>    if (mrJobHistoryWebappAddress != null) {<a name="line.2654"></a>
-<span class="sourceLineNo">2655</span>      conf.set("mapreduce.jobhistory.webapp.address", mrJobHistoryWebappAddress);<a name="line.2655"></a>
-<span class="sourceLineNo">2656</span>    }<a name="line.2656"></a>
-<span class="sourceLineNo">2657</span>    String yarnRMWebappAddress =<a name="line.2657"></a>
-<span class="sourceLineNo">2658</span>      jobConf.get("yarn.resourcemanager.webapp.address");<a name="line.2658"></a>
-<span class="sourceLineNo">2659</span>    if (yarnRMWebappAddress != null) {<a name="line.2659"></a>
-<span class="sourceLineNo">2660</span>      conf.set("yarn.resourcemanager.webapp.address", yarnRMWebappAddress);<a name="line.2660"></a>
+<span class="sourceLineNo">2628</span>    // Tests were failing due to MAPREDUCE-4880 / MAPREDUCE-4607 against hadoop 2.0.2-alpha and<a name="line.2628"></a>
+<span class="sourceLineNo">2629</span>    // this avoids the problem by disabling speculative task execution in tests.<a name="line.2629"></a>
+<span class="sourceLineNo">2630</span>    conf.setBoolean("mapreduce.map.speculative", false);<a name="line.2630"></a>
+<span class="sourceLineNo">2631</span>    conf.setBoolean("mapreduce.reduce.speculative", false);<a name="line.2631"></a>
+<span class="sourceLineNo">2632</span>    ////<a name="line.2632"></a>
+<span class="sourceLineNo">2633</span><a name="line.2633"></a>
+<span class="sourceLineNo">2634</span>    // Allow the user to override FS URI for this map-reduce cluster to use.<a name="line.2634"></a>
+<span class="sourceLineNo">2635</span>    mrCluster = new MiniMRCluster(servers,<a name="line.2635"></a>
+<span class="sourceLineNo">2636</span>      FS_URI != null ? FS_URI : FileSystem.get(conf).getUri().toString(), 1,<a name="line.2636"></a>
+<span class="sourceLineNo">2637</span>      null, null, new JobConf(this.conf));<a name="line.2637"></a>
+<span class="sourceLineNo">2638</span>    JobConf jobConf = MapreduceTestingShim.getJobConf(mrCluster);<a name="line.2638"></a>
+<span class="sourceLineNo">2639</span>    if (jobConf == null) {<a name="line.2639"></a>
+<span class="sourceLineNo">2640</span>      jobConf = mrCluster.createJobConf();<a name="line.2640"></a>
+<span class="sourceLineNo">2641</span>    }<a name="line.2641"></a>
+<span class="sourceLineNo">2642</span><a name="line.2642"></a>
+<span class="sourceLineNo">2643</span>    jobConf.set("mapreduce.cluster.local.dir",<a name="line.2643"></a>
+<span class="sourceLineNo">2644</span>      conf.get("mapreduce.cluster.local.dir")); //Hadoop MiniMR overwrites this while it should not<a name="line.2644"></a>
+<span class="sourceLineNo">2645</span>    LOG.info("Mini mapreduce cluster started");<a name="line.2645"></a>
+<span class="sourceLineNo">2646</span><a name="line.2646"></a>
+<span class="sourceLineNo">2647</span>    // In hadoop2, YARN/MR2 starts a mini cluster with its own conf instance and updates settings.<a name="line.2647"></a>
+<span class="sourceLineNo">2648</span>    // Our HBase MR jobs need several of these settings in order to properly run.  So we copy the<a name="line.2648"></a>
+<span class="sourceLineNo">2649</span>    // necessary config properties here.  YARN-129 required adding a few properties.<a name="line.2649"></a>
+<span class="sourceLineNo">2650</span>    conf.set("mapreduce.jobtracker.address", jobConf.get("mapreduce.jobtracker.address"));<a name="line.2650"></a>
+<span class="sourceLineNo">2651</span>    // this for mrv2 support; mr1 ignores this<a name="line.2651"></a>
+<span class="sourceLineNo">2652</span>    conf.set("mapreduce.framework.name", "yarn");<a name="line.2652"></a>
+<span class="sourceLineNo">2653</span>    conf.setBoolean("yarn.is.minicluster", true);<a name="line.2653"></a>
+<span class="sourceLineNo">2654</span>    String rmAddress = jobConf.get("yarn.resourcemanager.address");<a name="line.2654"></a>
+<span class="sourceLineNo">2655</span>    if (rmAddress != null) {<a name="line.2655"></a>
+<span class="sourceLineNo">2656</span>      conf.set("yarn.resourcemanager.address", rmAddress);<a name="line.2656"></a>
+<span class="sourceLineNo">2657</span>    }<a name="line.2657"></a>
+<span class="sourceLineNo">2658</span>    String historyAddress = jobConf.get("mapreduce.jobhistory.address");<a name="line.2658"></a>
+<span class="sourceLineNo">2659</span>    if (historyAddress != null) {<a name="line.2659"></a>
+<span class="sourceLineNo">2660</span>      conf.set("mapreduce.jobhistory.address", historyAddress);<a name="line.2660"></a>
 <span class="sourceLineNo">2661</span>    }<a name="line.2661"></a>
-<span class="sourceLineNo">2662</span>  }<a name="line.2662"></a>
-<span class="sourceLineNo">2663</span><a name="line.2663"></a>
-<span class="sourceLineNo">2664</span>  /**<a name="line.2664"></a>
-<span class="sourceLineNo">2665</span>   * Stops the previously started &lt;code&gt;MiniMRCluster&lt;/code&gt;.<a name="line.2665"></a>
-<span class="sourceLineNo">2666</span>   */<a name="line.2666"></a>
-<span class="sourceLineNo">2667</span>  public void shutdownMiniMapReduceCluster() {<a name="line.2667"></a>
-<span class="sourceLineNo">2668</span>    if (mrCluster != null) {<a name="line.2668"></a>
-<span class="sourceLineNo">2669</span>      LOG.info("Stopping mini mapreduce cluster...");<a name="line.2669"></a>
-<span class="sourceLineNo">2670</span>      mrCluster.shutdown();<a name="line.2670"></a>
-<span class="sourceLineNo">2671</span>      mrCluster = null;<a name="line.2671"></a>
-<span class="sourceLineNo">2672</span>      LOG.info("Mini mapreduce cluster stopped");<a name="line.2672"></a>
-<span class="sourceLineNo">2673</span>    }<a name="line.2673"></a>
-<span class="sourceLineNo">2674</span>    // Restore configuration to point to local jobtracker<a name="line.2674"></a>
-<span class="sourceLineNo">2675</span>    conf.set("mapreduce.jobtracker.address", "local");<a name="line.2675"></a>
-<span class="sourceLineNo">2676</span>  }<a name="line.2676"></a>
-<span class="sourceLineNo">2677</span><a name="line.2677"></a>
-<span class="sourceLineNo">2678</span>  /**<a name="line.2678"></a>
-<span class="sourceLineNo">2679</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2679"></a>
-<span class="sourceLineNo">2680</span>   */<a name="line.2680"></a>
-<span class="sourceLineNo">2681</span>  public RegionServerServices createMockRegionServerService() throws IOException {<a name="line.2681"></a>
-<span class="sourceLineNo">2682</span>    return createMockRegionServerService((ServerName)null);<a name="line.2682"></a>
-<span class="sourceLineNo">2683</span>  }<a name="line.2683"></a>
-<span class="sourceLineNo">2684</span><a name="line.2684"></a>
-<span class="sourceLineNo">2685</span>  /**<a name="line.2685"></a>
-<span class="sourceLineNo">2686</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2686"></a>
-<span class="sourceLineNo">2687</span>   * This version is used by TestTokenAuthentication<a name="line.2687"></a>
-<span class="sourceLineNo">2688</span>   */<a name="line.2688"></a>
-<span class="sourceLineNo">2689</span>  public RegionServerServices createMockRegionServerService(RpcServerInterface rpc) throws<a name="line.2689"></a>
-<span class="sourceLineNo">2690</span>      IOException {<a name="line.2690"></a>
-<span class="sourceLineNo">2691</span>    final MockRegionServerServices rss = new MockRegionServerServices(getZooKeeperWatcher());<a name="line.2691"></a>
-<span class="sourceLineNo">2692</span>    rss.setFileSystem(getTestFileSystem());<a name="line.2692"></a>
-<span class="sourceLineNo">2693</span>    rss.setRpcServer(rpc);<a name="line.2693"></a>
-<span class="sourceLineNo">2694</span>    return rss;<a name="line.2694"></a>
-<span class="sourceLineNo">2695</span>  }<a name="line.2695"></a>
-<span class="sourceLineNo">2696</span><a name="line.2696"></a>
-<span class="sourceLineNo">2697</span>  /**<a name="line.2697"></a>
-<span class="sourceLineNo">2698</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2698"></a>
-<span class="sourceLineNo">2699</span>   * This version is used by TestOpenRegionHandler<a name="line.2699"></a>
-<span class="sourceLineNo">2700</span>   */<a name="line.2700"></a>
-<span class="sourceLineNo">2701</span>  public RegionServerServices createMockRegionServerService(ServerName name) throws IOException {<a name="line.2701"></a>
-<span class="sourceLineNo">2702</span>    final MockRegionServerServices rss = new MockRegionServerServices(getZooKeeperWatcher(), name);<a name="line.2702"></a>
-<span class="sourceLineNo">2703</span>    rss.setFileSystem(getTestFileSystem());<a name="line.2703"></a>
-<span class="sourceLineNo">2704</span>    return rss;<a name="line.2704"></a>
-<span class="sourceLineNo">2705</span>  }<a name="line.2705"></a>
-<span class="sourceLineNo">2706</span><a name="line.2706"></a>
-<span class="sourceLineNo">2707</span>  /**<a name="line.2707"></a>
-<span class="sourceLineNo">2708</span>   * Switches the logger for the given class to DEBUG level.<a name="line.2708"></a>
-<span class="sourceLineNo">2709</span>   *<a name="line.2709"></a>
-<span class="sourceLineNo">2710</span>   * @param clazz  The class for which to switch to debug logging.<a name="line.2710"></a>
-<span class="sourceLineNo">2711</span>   */<a name="line.2711"></a>
-<span class="sourceLineNo">2712</span>  public void enableDebug(Class&lt;?&gt; clazz) {<a name="line.2712"></a>
-<span class="sourceLineNo">2713</span>    Log l = LogFactory.getLog(clazz);<a name="line.2713"></a>
-<span class="sourceLineNo">2714</span>    if (l instanceof Log4JLogger) {<a name="line.2714"></a>
-<span class="sourceLineNo">2715</span>      ((Log4JLogger) l).getLogger().setLevel(org.apache.log4j.Level.DEBUG);<a name="line.2715"></a>
-<span class="sourceLineNo">2716</span>    } else if (l instanceof Jdk14Logger) {<a name="line.2716"></a>
-<span class="sourceLineNo">2717</span>      ((Jdk14Logger) l).getLogger().setLevel(java.util.logging.Level.ALL);<a name="line.2717"></a>
-<span class="sourceLineNo">2718</span>    }<a name="line.2718"></a>
-<span class="sourceLineNo">2719</span>  }<a name="line.2719"></a>
-<span class="sourceLineNo">2720</span><a name="line.2720"></a>
-<span class="sourceLineNo">2721</span>  /**<a name="line.2721"></a>
-<span class="sourceLineNo">2722</span>   * Expire the Master's session<a name="line.2722"></a>
-<span class="sourceLineNo">2723</span>   * @throws Exception<a name="line.2723"></a>
-<span class="sourceLineNo">2724</span>   */<a name="line.2724"></a>
-<span class="sourceLineNo">2725</span>  public void expireMasterSession() throws Exception {<a name="line.2725"></a>
-<span class="sourceLineNo">2726</span>    HMaster master = getMiniHBaseCluster().getMaster();<a name="line.2726"></a>
-<span class="sourceLineNo">2727</span>    expireSession(master.getZooKeeper(), false);<a name="line.2727"></a>
-<span class="sourceLineNo">2728</span>  }<a name="line.2728"></a>
-<span class="sourceLineNo">2729</span><a name="line.2729"></a>
-<span class="sourceLineNo">2730</span>  /**<a name="line.2730"></a>
-<span class="sourceLineNo">2731</span>   * Expire a region server's session<a name="line.2731"></a>
-<span class="sourceLineNo">2732</span>   * @param index which RS<a name="line.2732"></a>
-<span class="sourceLineNo">2733</span>   * @throws Exception<a name="line.2733"></a>
-<span class="sourceLineNo">2734</span>   */<a name="line.2734"></a>
-<span class="sourceLineNo">2735</span>  public void expireRegionServerSession(int index) throws Exception {<a name="line.2735"></a>
-<span class="sourceLineNo">2736</span>    HRegionServer rs = getMiniHBaseCluster().getRegionServer(index);<a name="line.2736"></a>
-<span class="sourceLineNo">2737</span>    expireSession(rs.getZooKeeper(), false);<a name="line.2737"></a>
-<span class="sourceLineNo">2738</span>    decrementMinRegionServerCount();<a name="line.2738"></a>
-<span class="sourceLineNo">2739</span>  }<a name="line.2739"></a>
-<span class="sourceLineNo">2740</span><a name="line.2740"></a>
-<span class="sourceLineNo">2741</span>  private void decrementMinRegionServerCount() {<a name="line.2741"></a>
-<span class="sourceLineNo">2742</span>    // decrement the count for this.conf, for newly spwaned master<a name="line.2742"></a>
-<span class="sourceLineNo">2743</span>    // this.hbaseCluster shares this configuration too<a name="line.2743"></a>
-<span class="sourceLineNo">2744</span>    decrementMinRegionServerCount(getConfiguration());<a name="line.2744"></a>
-<span class="sourceLineNo">2745</span><a name="line.2745"></a>
-<span class="sourceLineNo">2746</span>    // each master thread keeps a copy of configuration<a name="line.2746"></a>
-<span class="sourceLineNo">2747</span>    for (MasterThread master : getHBaseCluster().getMasterThreads()) {<a name="line.2747"></a>
-<span class="sourceLineNo">2748</span>      decrementMinRegionServerCount(master.getMaster().getConfiguration());<a name="line.2748"></a>
-<span class="sourceLineNo">2749</span>    }<a name="line.2749"></a>
-<span class="sourceLineNo">2750</span>  }<a name="line.2750"></a>
-<span class="sourceLineNo">2751</span><a name="line.2751"></a>
-<span class="sourceLineNo">2752</span>  private void decrementMinRegionServerCount(Configuration conf) {<a name="line.2752"></a>
-<span class="sourceLineNo">2753</span>    int currentCount = conf.getInt(<a name="line.2753"></a>
-<span class="sourceLineNo">2754</span>        ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1);<a name="line.2754"></a>
-<span class="sourceLineNo">2755</span>    if (currentCount != -1) {<a name="line.2755"></a>
-<span class="sourceLineNo">2756</span>      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,<a name="line.2756"></a>
-<span class="sourceLineNo">2757</span>          Math.max(currentCount - 1, 1));<a name="line.2757"></a>
-<span class="sourceLineNo">2758</span>    }<a name="line.2758"></a>
-<span class="sourceLineNo">2759</span>  }<a name="line.2759"></a>
+<span class="sourceLineNo">2662</span>    String schedulerAddress =<a name="line.2662"></a>
+<span class="sourceLineNo">2663</span>      jobConf.get("yarn.resourcemanager.scheduler.address");<a name="line.2663"></a>
+<span class="sourceLineNo">2664</span>    if (schedulerAddress != null) {<a name="line.2664"></a>
+<span class="sourceLineNo">2665</span>      conf.set("yarn.resourcemanager.scheduler.address", schedulerAddress);<a name="line.2665"></a>
+<span class="sourceLineNo">2666</span>    }<a name="line.2666"></a>
+<span class="sourceLineNo">2667</span>    String mrJobHistoryWebappAddress =<a name="line.2667"></a>
+<span class="sourceLineNo">2668</span>      jobConf.get("mapreduce.jobhistory.webapp.address");<a name="line.2668"></a>
+<span class="sourceLineNo">2669</span>    if (mrJobHistoryWebappAddress != null) {<a name="line.2669"></a>
+<span class="sourceLineNo">2670</span>      conf.set("mapreduce.jobhistory.webapp.address", mrJobHistoryWebappAddress);<a name="line.2670"></a>
+<span class="sourceLineNo">2671</span>    }<a name="line.2671"></a>
+<span class="sourceLineNo">2672</span>    String yarnRMWebappAddress =<a name="line.2672"></a>
+<span class="sourceLineNo">2673</span>      jobConf.get("yarn.resourcemanager.webapp.address");<a name="line.2673"></a>
+<span class="sourceLineNo">2674</span>    if (yarnRMWebappAddress != null) {<a name="line.2674"></a>
+<span class="sourceLineNo">2675</span>      conf.set("yarn.resourcemanager.webapp.address", yarnRMWebappAddress);<a name="line.2675"></a>
+<span class="sourceLineNo">2676</span>    }<a name="line.2676"></a>
+<span class="sourceLineNo">2677</span>  }<a name="line.2677"></a>
+<span class="sourceLineNo">2678</span><a name="line.2678"></a>
+<span class="sourceLineNo">2679</span>  /**<a name="line.2679"></a>
+<span class="sourceLineNo">2680</span>   * Stops the previously started &lt;code&gt;MiniMRCluster&lt;/code&gt;.<a name="line.2680"></a>
+<span class="sourceLineNo">2681</span>   */<a name="line.2681"></a>
+<span class="sourceLineNo">2682</span>  public void shutdownMiniMapReduceCluster() {<a name="line.2682"></a>
+<span class="sourceLineNo">2683</span>    if (mrCluster != null) {<a name="line.2683"></a>
+<span class="sourceLineNo">2684</span>      LOG.info("Stopping mini mapreduce cluster...");<a name="line.2684"></a>
+<span class="sourceLineNo">2685</span>      mrCluster.shutdown();<a name="line.2685"></a>
+<span class="sourceLineNo">2686</span>      mrCluster = null;<a name="line.2686"></a>
+<span class="sourceLineNo">2687</span>      LOG.info("Mini mapreduce cluster stopped");<a name="line.2687"></a>
+<span class="sourceLineNo">2688</span>    }<a name="line.2688"></a>
+<span class="sourceLineNo">2689</span>    // Restore configuration to point to local jobtracker<a name="line.2689"></a>
+<span class="sourceLineNo">2690</span>    conf.set("mapreduce.jobtracker.address", "local");<a name="line.2690"></a>
+<span class="sourceLineNo">2691</span>  }<a name="line.2691"></a>
+<span class="sourceLineNo">2692</span><a name="line.2692"></a>
+<span class="sourceLineNo">2693</span>  /**<a name="line.2693"></a>
+<span class="sourceLineNo">2694</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2694"></a>
+<span class="sourceLineNo">2695</span>   */<a name="line.2695"></a>
+<span class="sourceLineNo">2696</span>  public RegionServerServices createMockRegionServerService() throws IOException {<a name="line.2696"></a>
+<span class="sourceLineNo">2697</span>    return createMockRegionServerService((ServerName)null);<a name="line.2697"></a>
+<span class="sourceLineNo">2698</span>  }<a name="line.2698"></a>
+<span class="sourceLineNo">2699</span><a name="line.2699"></a>
+<span class="sourceLineNo">2700</span>  /**<a name="line.2700"></a>
+<span class="sourceLineNo">2701</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2701"></a>
+<span class="sourceLineNo">2702</span>   * This version is used by TestTokenAuthentication<a name="line.2702"></a>
+<span class="sourceLineNo">2703</span>   */<a name="line.2703"></a>
+<span class="sourceLineNo">2704</span>  public RegionServerServices createMockRegionServerService(RpcServerInterface rpc) throws<a name="line.2704"></a>
+<span class="sourceLineNo">2705</span>      IOException {<a name="line.2705"></a>
+<span class="sourceLineNo">2706</span>    final MockRegionServerServices rss = new MockRegionServerServices(getZooKeeperWatcher());<a name="line.2706"></a>
+<span class="sourceLineNo">2707</span>    rss.setFileSystem(getTestFileSystem());<a name="line.2707"></a>
+<span class="sourceLineNo">2708</span>    rss.setRpcServer(rpc);<a name="line.2708"></a>
+<span class="sourceLineNo">2709</span>    return rss;<a name="line.2709"></a>
+<span class="sourceLineNo">2710</span>  }<a name="line.2710"></a>
+<span class="sourceLineNo">2711</span><a name="line.2711"></a>
+<span class="sourceLineNo">2712</span>  /**<a name="line.2712"></a>
+<span class="sourceLineNo">2713</span>   * Create a stubbed out RegionServerService, mainly for getting FS.<a name="line.2713"></a>
+<span class="sourceLineNo">2714</span>   * This version is used by TestOpenRegionHandler<a name="line.2714"></a>
+<span class="sourceLineNo">2715</span>   */<a name="line.2715"></a>
+<span class="sourceLineNo">2716</span>  public RegionServerServices createMockRegionServerService(ServerName name) throws IOException {<a name="line.2716"></a>
+<span class="sourceLineNo">2717</span>    final MockRegionServerServices rss = new MockRegionServerServices(getZooKeeperWatcher(), name);<a name="line.2717"></a>
+<span class="sourceLineNo">2718</span>    rss.setFileSystem(getTestFileSystem());<a name="line.2718"></a>
+<span class="sourceLineNo">2719</span>    return rss;<a name="line.2719"></a>
+<span class="sourceLineNo">2720</span>  }<a name="line.2720"></a>
+<span class="sourceLineNo">2721</span><a name="line.2721"></a>
+<span class="sourceLineNo">2722</span>  /**<a name="line.2722"></a>
+<span class="sourceLineNo">2723</span>   * Switches the logger for the given class to DEBUG level.<a name="line.2723"></a>
+<span class="sourceLineNo">2724</span>   *<a name="line.2724"></a>
+<span class="sourceLineNo">2725</span>   * @param clazz  The class for which to switch to debug logging.<a name="line.2725"></a>
+<span class="sourceLineNo">2726</span>   */<a name="line.2726"></a>
+<span class="sourceLineNo">2727</span>  public void enableDebug(Class&lt;?&gt; clazz) {<a name="line.2727"></a>
+<span class="sourceLineNo">2728</span>    Log l = LogFactory.getLog(clazz);<a name="line.2728"></a>
+<span class="sourceLineNo">2729</span>    if (l instanceof Log4JLogger) {<a name="line.2729"></a>
+<span class="sourceLineNo">2730</span>      ((Log4JLogger) l).getLogger().setLevel(org.apache.log4j.Level.DEBUG);<a name="line.2730"></a>
+<span class="sourceLineNo">2731</span>    } else if (l instanceof Jdk14Logger) {<a name="line.2731"></a>
+<span class="sourceLineNo">2732</span>      ((Jdk14Logger) l).getLogger().setLevel(java.util.logging.Level.ALL);<a name="line.2732"></a>
+<span class="sourceLineNo">2733</span>    }<a name="line.2733"></a>
+<span class="sourceLineNo">2734</span>  }<a name="line.2734"></a>
+<span class="sourceLineNo">2735</span><a name="line.2735"></a>
+<span class="sourceLineNo">2736</span>  /**<a name="line.2736"></a>
+<span class="sourceLineNo">2737</span>   * Expire the Master's session<a name="line.2737"></a>
+<span class="sourceLineNo">2738</span>   * @throws Exception<a name="line.2738"></a>
+<span class="sourceLineNo">2739</span>   */<a name="line.2739"></a>
+<span class="sourceLineNo">2740</span>  public void expireMasterSession() throws Exception {<a name="line.2740"></a>
+<span class="sourceLineNo">2741</span>    HMaster master = getMiniHBaseCluster().getMaster();<a name="line.2741"></a>
+<span class="sourceLineNo">2742</span>    expireSession(master.getZooKeeper(), false);<a name="line.2742"></a>
+<span class="sourceLineNo">2743</span>  }<a name="line.2743"></a>
+<span class="sourceLineNo">2744</span><a name="line.2744"></a>
+<span class="sourceLineNo">2745</span>  /**<a name="line.2745"></a>
+<span class="sourceLineNo">2746</span>   * Expire a region server's session<a name="line.2746"></a>
+<span class="sourceLineNo">2747</span>   * @param index which RS<a name="line.2747"></a>
+<span class="sourceLineNo">2748</span>   * @throws Exception<a name="line.2748"></a>
+<span class="sourceLineNo">2749</span>   */<a name="line.2749"></a>
+<span class="sourceLineNo">2750</span>  public void expireRegionServerSession(int index) throws Exception {<a name="line.2750"></a>
+<span class="sourceLineNo">2751</span>    HRegionServer rs = getMiniHBaseCluster().getRegionServer(index);<a name="line.2751"></a>
+<span class="sourceLineNo">2752</span>    expireSession(rs.getZooKeeper(), false);<a name="line.2752"></a>
+<span class="sourceLineNo">2753</span>    decrementMinRegionServerCount();<a name="line.2753"></a>
+<span class="sourceLineNo">2754</span>  }<a name="line.2754"></a>
+<span class="sourceLineNo">2755</span><a name="line.2755"></a>
+<span class="sourceLineNo">2756</span>  private void decrementMinRegionServerCount() {<a name="line.2756"></a>
+<span class="sourceLineNo">2757</span>    // decrement the count for this.conf, for newly spwaned master<a name="line.2757"></a>
+<span class="sourceLineNo">2758</span>    // this.hbaseCluster shares this configuration too<a name="line.2758"></a>
+<span class="sourceLineNo">2759</span>    decrementMinRegionServerCount(getConfiguration());<a name="line.2759"></a>
 <span class="sourceLineNo">2760</span><a name="line.2760"></a>
-<span class="sourceLineNo">2761</span>  public void expireSession(ZKWatcher nodeZK) throws Exception {<a name="line.2761"></a>
-<span class="sourceLineNo">2762</span>   expireSession(nodeZK, false);<a name="line.2762"></a>
-<span class="sourceLineNo">2763</span>  }<a name="line.2763"></a>
-<span class="sourceLineNo">2764</span><a name="line.2764"></a>
-<span class="sourceLineNo">2765</span>  /**<a name="line.2765"></a>
-<span class="sourceLineNo">2766</span>   * Expire a ZooKeeper session as recommended in ZooKeeper documentation<a name="line.2766"></a>
-<span class="sourceLineNo">2767</span>   * http://hbase.apache.org/book.html#trouble.zookeeper<a name="line.2767"></a>
-<span class="sourceLineNo">2768</span>   * There are issues when doing this:<a name="line.2768"></a>
-<span class="sourceLineNo">2769</span>   * [1] http://www.mail-archive.com/dev@zookeeper.apache.org/msg01942.html<a name="line.2769"></a>
-<span class="sourceLineNo">2770</span>   * [2] https://issues.apache.org/jira/browse/ZOOKEEPER-1105<a name="line.2770"></a>
-<span class="sourceLineNo">2771</span>   *<a name="line.2771"></a>
-<span class="sourceLineNo">2772</span>   * @param nodeZK - the ZK watcher to expire<a name="line.2772"></a>
-<span class="sourceLineNo">2773</span>   * @param checkStatus - true to check if we can create a Table with the<a name="line.2773"></a>
-<span class="sourceLineNo">2774</span>   *                    current configuration.<a name="line.2774"></a>
-<span class="sourceLineNo">2775</span>   */<a name="line.2775"></a>
-<span class="sourceLineNo">2776</span>  public void expireSession(ZKWatcher nodeZK, boolean checkStatus)<a name="line.2776"></a>
-<span class="sourceLineNo">2777</span>    throws Exception {<a name="line.2777"></a>
-<span class="sourceLineNo">2778</span>    Configuration c = new Configuration(this.conf);<a name="line.2778"></a>
-<span class="sourceLineNo">2779</span>    String quorumServers = ZKConfig.getZKQuorumServersString(c);<a name="line.2779"></a>
-<span class="sourceLineNo">2780</span>    ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper();<a name="line.2780"></a>
-<span class="sourceLineNo">2781</span>    byte[] password = zk.getSessionPasswd();<a name="line.2781"></a>
-<span class="sourceLineNo">2782</span>    long sessionID = zk.getSessionId();<a name="line.2782"></a>
-<span class="sourceLineNo">2783</span><a name="line.2783"></a>
-<span class="sourceLineNo">2784</span>    // Expiry seems to be asynchronous (see comment from P. Hunt in [1]),<a name="line.2784"></a>
-<span class="sourceLineNo">2785</span>    //  so we create a first watcher to be sure that the<a name="line.2785"></a>
-<span class="sourceLineNo">2786</span>    //  event was sent. We expect that if our watcher receives the event<a name="line.2786"></a>
-<span class="sourceLineNo">2787</span>    //  other watchers on the same machine will get is as well.<a name="line.2787"></a>
-<span class="sourceLineNo">2788</span>    // When we ask to close the connection, ZK does not close it before<a name="line.2788"></a>
-<span class="sourceLineNo">2789</span>    //  we receive all the events, so don't have to capture the event, just<a name="line.2789"></a>
-<span class="sourceLineNo">2790</span>    //  closing the connection should be enough.<a name="line.2790"></a>
-<span class="sourceLineNo">2791</span>    ZooKeeper monitor = new ZooKeeper(quorumServers,<a name="line.2791"></a>
-<span class="sourceLineNo">2792</span>      1000, new org.apache.zookeeper.Watcher(){<a name="line.2792"></a>
-<span class="sourceLineNo">2793</span>      @Override<a name="line.2793"></a>
-<span class="sourceLineNo">2794</span>      public void process(WatchedEvent watchedEvent) {<a name="line.2794"></a>
-<span class="sourceLineNo">2795</span>        LOG.info("Monitor ZKW received event="+watchedEvent);<a name="line.2795"></a>
-<span class="sourceLineNo">2796</span>      }<a name="line.2796"></a>
-<span class="sourceLineNo">2797</span>    } , sessionID, password);<a name="line.2797"></a>
+<span class="sourceLineNo">2761</span>    // each master thread keeps a copy of configuration<a name="line.2761"></a>
+<span class="sourceLineNo">2762</span>    for (MasterThread master : getHBaseCluster().getMasterThreads()) {<a name="line.2762"></a>
+<span class="sourceLineNo">2763</span>      decrementMinRegionServerCount(master.getMaster().getConfiguration());<a name="line.2763"></a>
+<span class="sourceLineNo">2764</span>    }<a name="line.2764"></a>
+<span class="sourceLineNo">2765</span>  }<a name="line.2765"></a>
+<span class="sourceLineNo">2766</span><a name="line.2766"></a>
+<span class="sourceLineNo">2767</span>  private void decrementMinRegionServerCount(Configuration conf) {<a name="line.2767"></a>
+<span class="sourceLineNo">2768</span>    int currentCount = conf.getInt(<a name="line.2768"></a>
+<span class="sourceLineNo">2769</span>        ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1);<a name="line.2769"></a>
+<span class="sourceLineNo">2770</span>    if (currentCount != -1) {<a name="line.2770"></a>
+<span class="sourceLineNo">2771</span>      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,<a name="line.2771"></a>
+<span class="sourceLineNo">2772</span>          Math.max(currentCount - 1, 1));<a name="line.2772"></a>
+<span class="sourceLineNo">2773</span>    }<a name="line.2773"></a>
+<span class="sourceLineNo">2774</span>  }<a name="line.2774"></a>
+<span class="sourceLineNo">2775</span><a name="line.2775"></a>
+<span class="sourceLineNo">2776</span>  public void expireSession(ZKWatcher nodeZK) throws Exception {<a name="line.2776"></a>
+<span class="sourceLineNo">2777</span>   expireSession(nodeZK, false);<a name="line.2777"></a>
+<span class="sourceLineNo">2778</span>  }<a name="line.2778"></a>
+<span class="sourceLineNo">2779</span><a name="line.2779"></a>
+<span class="sourceLineNo">2780</span>  /**<a name="line.2780"></a>
+<span class="sourceLineNo">2781</span>   * Expire a ZooKeeper session as recommended in ZooKeeper documentation<a name="line.2781"></a>
+<span class="sourceLineNo">2782</span>   * http://hbase.apache.org/book.html#trouble.zookeeper<a name="line.2782"></a>
+<span class="sourceLineNo">2783</span>   * There are issues when doing this:<a name="line.2783"></a>
+<span class="sourceLineNo">2784</span>   * [1] http://www.mail-archive.com/dev@zookeeper.apache.org/msg01942.html<a name="line.2784"></a>
+<span class="sourceLineNo">2785</span>   * [2] https://issues.apache.org/jira/browse/ZOOKEEPER-1105<a name="line.2785"></a>
+<span class="sourceLineNo">2786</span>   *<a name="line.2786"></a>
+<span class="sourceLineNo">2787</span>   * @param nodeZK - the ZK watcher to expire<a name="line.2787"></a>
+<span class="sourceLineNo">2788</span>   * @param checkStatus - true to check if we can create a Table with the<a name="line.2788"></a>
+<span class="sourceLineNo">2789</span>   *                    current configuration.<a name="line.2789"></a>
+<span class="sourceLineNo">2790</span>   */<a name="line.2790"></a>
+<span class="sourceLineNo">2791</span>  public void expireSession(ZKWatcher nodeZK, boolean checkStatus)<a name="line.2791"></a>
+<span class="sourceLineNo">2792</span>    throws Exception {<a name="line.2792"></a>
+<span class="sourceLineNo">2793</span>    Configuration c = new Configuration(this.conf);<a name="line.2793"></a>
+<span class="sourceLineNo">2794</span>    String quorumServers = ZKConfig.getZKQuorumServersString(c);<a name="line.2794"></a>
+<span class="sourceLineNo">2795</span>    ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper();<a name="line.2795"></a>
+<span class="sourceLineNo">2796</span>    byte[] password = zk.getSessionPasswd();<a name="line.2796"></a>
+<span class="sourceLineNo">2797</span>    long sessionID = zk.getSessionId();<a name="line.2797"></a>
 <span class="sourceLineNo">2798</span><a name="line.2798"></a>
-<span class="sourceLineNo">2799</span>    // Making it expire<a name="line.2799"></a>
-<span class="sourceLineNo">2800</span>    ZooKeeper newZK = new ZooKeeper(quorumServers,<a name="line.2800"></a>
-<span class="sourceLineNo">2801</span>        1000, EmptyWatcher.instance, sessionID, password);<a name="line.2801"></a>
-<span class="sourceLineNo">2802</span><a name="line.2802"></a>
-<span class="sourceLineNo">2803</span>    //ensure that we have connection to the server before closing down, otherwise<a name="line.2803"></a>
-<span class="sourceLineNo">2804</span>    //the close session event will be eaten out before we start CONNECTING state<a name="line.2804"></a>
-<span class="sourceLineNo">2805</span>    long start = System.currentTimeMillis();<a name="line.2805"></a>
-<span class="sourceLineNo">2806</span>    while (newZK.getState() != States.CONNECTED<a name="line.2806"></a>
-<span class="sourceLineNo">2807</span>         &amp;&amp; System.currentTimeMillis() - start &lt; 1000) {<a name="line.2807"></a>
-<span class="sourceLineNo">2808</span>       Thread.sleep(1);<a name="line.2808"></a>
-<span class="sourceLineNo">2809</span>    }<a name="line.2809"></a>
-<span class="sourceLineNo">2810</span>    newZK.close();<a name="line.2810"></a>
-<span class="sourceLineNo">2811</span>    LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID));<a name="line.2811"></a>
-<span class="sourceLineNo">2812</span><a name="line.2812"></a>
-<span class="sourceLineNo">2813</span>    // Now closing &amp; waiting to be sure that the clients get it.<a name="line.2813"></a>
-<span class="sourceLineNo">2814</span>    monitor.close();<a name="line.2814"></a>
-<span class="sourceLineNo">2815</span><a name="line.2815"></a>
-<span class="sourceLineNo">2816</span>    if (checkStatus) {<a name="line.2816"></a>
-<span class="sourceLineNo">2817</span>      getConnection().getTable(TableName.META_TABLE_NAME).close();<a name="line.2817"></a>
-<span class="sourceLineNo">2818</span>    }<a name="line.2818"></a>
-<span class="sourceLineNo">2819</span>  }<a name="line.2819"></a>
-<span class="sourceLineNo">2820</span><a name="line.2820"></a>
-<span class="sourceLineNo">2821</span>  /**<a name="line.2821"></a>
-<span class="sourceLineNo">2822</span>   * Get the Mini HBase cluster.<a name="line.2822"></a>
-<span class="sourceLineNo">2823</span>   *<a name="line.2823"></a>
-<span class="sourceLineNo">2824</span>   * @return hbase cluster<a name="line.2824"></a>
-<span class="sourceLineNo">2825</span>   * @see #getHBaseClusterInterface()<a name="line.2825"></a>
-<span class="sourceLineNo">2826</span>   */<a name="line.2826"></a>
-<span class="sourceLineNo">2827</span>  public MiniHBaseCluster getHBaseCluster() {<a name="line.2827"></a>
-<span class="sourceLineNo">2828</span>    return getMiniHBaseCluster();<a name="line.2828"></a>
-<span class="sourceLineNo">2829</span>  }<a name="line.2829"></a>
+<span class="sourceLineNo">2799</span>    // Expiry seems to be asynchronous (see comment from P. Hunt in [1]),<a name="line.2799"></a>
+<span class="sourceLineNo">2800</span>    //  so we create a first watcher to be sure that the<a name="line.2800"></a>
+<span class="sourceLineNo">2801</span>    //  event was sent. We expect that if our watcher receives the event<a name="line.2801"></a>
+<span class="sourceLineNo">2802</span>    //  other watchers on the same machine will get is as well.<a name="line.2802"></a>
+<span class="sourceLineNo">2803</span>    // When we ask to close the connection, ZK does not close it before<a name="line.2803"></a>
+<span class="sourceLineNo">2804</span>    //  we receive all the events, so don't have to capture the event, just<a name="line.2804"></a>
+<span class="sourceLineNo">2805</span>    //  closing the connection should be enough.<a name="line.2805"></a>
+<span class="sourceLineNo">2806</span>    ZooKeeper monitor = new ZooKeeper(quorumServers,<a name="line.2806"></a>
+<span class="sourceLineNo">2807</span>      1000, new org.apache.zookeeper.Watcher(){<a name="line.2807"></a>
+<span class="sourceLineNo">2808</span>      @Override<a name="line.2808"></a>
+<span class="sourceLineNo">2809</span>      public void process(WatchedEvent watchedEvent) {<a name="line.2809"></a>
+<span class="sourceLineNo">2810</span>        LOG.info("Monitor ZKW received event="+watchedEvent);<a name="line.2810"></a>
+<span class="sourceLineNo">2811</span>      }<a name="line.2811"></a>
+<span class="sourceLineNo">2812</span>    } , sessionID, password);<a name="line.2812"></a>
+<span class="sourceLineNo">2813</span><a name="line.2813"></a>
+<span class="sourceLineNo">2814</span>    // Making it expire<a name="line.2814"></a>
+<span class="sourceLineNo">2815</span>    ZooKeeper newZK = new ZooKeeper(quorumServers,<a name="line.2815"></a>
+<span class="sourceLineNo">2816</span>        1000, EmptyWatcher.instance, sessionID, password);<a name="line.2816"></a>
+<span class="sourceLineNo">2817</span><a name="line.2817"></a>
+<span class="sourceLineNo">2818</span>    //ensure that we have connection to the server before closing down, otherwise<a name="line.2818"></a>
+<span class="sourceLineNo">2819</span>    //the close session event will be eaten out before we start CONNECTING state<a name="line.2819"></a>
+<span class="sourceLineNo">2820</span>    long start = System.currentTimeMillis();<a name="line.2820"></a>
+<span class="sourceLineNo">2821</span>    while (newZK.getState() != States.CONNECTED<a name="line.2821"></a>
+<span class="sourceLineNo">2822</span>         &amp;&amp; System.currentTimeMillis() - start &lt; 1000) {<a name="line.2822"></a>
+<span class="sourceLineNo">2823</span>       Thread.sleep(1);<a name="line.2823"></a>
+<span class="sourceLineNo">2824</span>    }<a name="line.2824"></a>
+<span class="sourceLineNo">2825</span>    newZK.close();<a name="line.2825"></a>
+<span class="sourceLineNo">2826</span>    LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID));<a name="line.2826"></a>
+<span class="sourceLineNo">2827</span><a name="line.2827"></a>
+<span class="sourceLineNo">2828</span>    // Now closing &amp; waiting to be sure that the clients get it.<a name="line.2828"></a>
+<span class="sourceLineNo">2829</span>    monitor.close();<a name="line.2829"></a>
 <span class="sourceLineNo">2830</span><a name="line.2830"></a>
-<span class="sourceLineNo">2831</span>  /**<a name="line.2831"></a>
-<span class="sourceLineNo">2832</span>   * Returns the HBaseCluster instance.<a name="line.2832"></a>
-<span class="sourceLineNo">2833</span>   * &lt;p&gt;Returned object can be any of the subclasses of HBaseCluster, and the<a name="line.2833"></a>
-<span class="sourceLineNo">2834</span>   * tests referring this should not assume that the cluster is a mini cluster or a<a name="line.2834"></a>
-<span class="sourceLineNo">2835</span>   * distributed one. If the test only works on a mini cluster, then specific<a name="line.2835"></a>
-<span class="sourceLineNo">2836</span>   * method {@link #getMiniHBaseCluster()} can be used instead w/o the<a name="line.2836"></a>
-<span class="sourceLineNo">2837</span>   * need to type-cast.<a name="line.2837"></a>
-<span class="sourceLineNo">2838</span>   */<a name="line.2838"></a>
-<span class="sourceLineNo">2839</span>  public HBaseCluster getHBaseClusterInterface() {<a name="line.2839"></a>
-<span class="sourceLineNo">2840</span>    //implementation note: we should rename this method as #getHBaseCluster(),<a name="line.2840"></a>
-<span class="sourceLineNo">2841</span>    //but this would require refactoring 90+ calls.<a name="line.2841"></a>
-<span class="sourceLineNo">2842</span>    return hbaseCluster;<a name="line.2842"></a>
-<span class="sourceLineNo">2843</span>  }<a name="line.2843"></a>
-<span class="sourceLineNo">2844</span><a name="line.2844"></a>
-<span class="sourceLineNo">2845</span>  /**<a name="line.2845"></a>
-<span class="sourceLineNo">2846</span>   * Get a Connection to the cluster.<a name="line.2846"></a>
-<span class="sourceLineNo">2847</span>   * Not thread-safe (This class needs a lot of work to make it thread-safe).<a name="line.2847"></a>
-<span class="sourceLineNo">2848</span>   * @return A Connection that can be shared. Don't close. Will be closed on shutdown of cluster.<a name="line.2848"></a>
-<span class="sourceLineNo">2849</span>   * @throws IOException<a name="line.2849"></a>
-<span class="sourceLineNo">2850</span>   */<a name="line.2850"></a>
-<span class="sourceLineNo">2851</span>  public Connection getConnection() throws IOException {<a name="line.2851"></a>
-<span class="sourceLineNo">2852</span>    if (this.connection == null) {<a name="line.2852"></a>
-<span class="sourceLineNo">2853</span>      this.connection = ConnectionFactory.createConnection(this.conf);<a name="line.2853"></a>
-<span class="sourceLineNo">2854</span>    }<a name="line.2854"></a>
-<span class="sourceLineNo">2855</span>    return this.connection;<a name="line.2855"></a>
-<span class="sourceLineNo">2856</span>  }<a name="line.2856"></a>
-<span class="sourceLineNo">2857</span><a name="line.2857"></a>
-<span class="sourceLineNo">2858</span>  /**<a name="line.2858"></a>
-<span class="sourceLineNo">2859</span>   * Returns a Admin instance.<a name="line.2859"></a>
-<span class="sourceLineNo">2860</span>   * This instance is shared between HBaseTestingUtility instance users. Closing it has no effect,<a name="line.2860"></a>
-<span class="sourceLineNo">2861</span>   * it will be closed automatically when the cluster shutdowns<a name="line.2861"></a>
-<span class="sourceLineNo">2862</span>   *<a name="line.2862"></a>
-<span class="sourceLineNo">2863</span>   * @return HBaseAdmin instance which is guaranteed to support only {@link Admin} interface.<a name="line.2863"></a>
-<span class="sourceLineNo">2864</span>   *   Functions in HBaseAdmin not provided by {@link Admin} interface can be changed/deleted<a name="line.2864"></a>
-<span class="sourceLineNo">2865</span>   *   anytime.<a name="line.2865"></a>
-<span class="sourceLineNo">2866</span>   * @deprecated Since 2.0. Will be removed in 3.0. Use {@link #getAdmin()} instead.<a name="line.2866"></a>
-<span class="sourceLineNo">2867</span>   */<a name="line.2867"></a>
-<span class="sourceLineNo">2868</span>  @Deprecated<a name="line.2868"></a>
-<span class="sourceLineNo">2869</span>  public synchronized HBaseAdmin getHBaseAdmin()<a name="line.2869"></a>
-<span class="sourceLineNo">2870</span>  throws IOException {<a name="line.2870"></a>
-<span class="sourceLineNo">2871</span>    if (hbaseAdmin == null){<a name="line.2871"></a>
-<span class="sourceLineNo">2872</span>      this.hbaseAdmin = (HBaseAdmin) getConnection().getAdmin();<a name="line.2872"></a>
-<span class="sourceLineNo">2873</span>    }<a name="line.2873"></a>
-<span class="sourceLineNo">2874</span>    return hbaseAdmin;<a name="line.2874"></a>
-<span class="sourceLineNo">2875</span>  }<a name="line.2875"></a>
-<span class="sourceLineNo">2876</span><a name="line.2876"></a>
-<span class="sourceLineNo">2877</span>  /**<a name="line.2877"></a>
-<span class="sourceLineNo">2878</span>   * Returns an Admin instance which is shared between HBaseTestingUtility instance users.<a name="line.2878"></a>
-<span class="sourceLineNo">2879</span>   * Closing it has no effect, it will be closed automatically when the cluster shutdowns<a name="line.2879"></a>
-<span class="sourceLineNo">2880</span>   */<a name="line.2880"></a>
-<span class="sourceLineNo">2881</span>  public synchronized Admin getAdmin() throws IOException {<a name="line.2881"></a>
-<span class="sourceLineNo">2882</span>    if (hbaseAdmin == null){<a name="line.2882"></a>
-<span class="sourceLineNo">2883</span>      this.hbaseAdmin = (HBaseAdmin) getConnection().getAdmin();<a name="line.2883"></a>
-<span class="sourceLineNo">2884</span>    }<a name="line.2884"></a>
-<span class="sourceLineNo">2885</span>    return hbaseAdmin;<a name="line.2885"></a>
-<span class="sourceLineNo">2886</span>  }<a name="line.2886"></a>
-<span class="sourceLineNo">2887</span><a name="line.2887"></a>
-<span class="sourceLineNo">2888</span>  private HBaseAdmin hbaseAdmin = null;<a name="line.2888"></a>
-<span class="sourceLineNo">2889</span><a name="line.2889"></a>
-<span class="sourceLineNo">2890</span>  /**<a name="line.2890"></a>
-<span class="sourceLineNo">2891</span>   * Returns a ZKWatcher instance.<a name="line.2891"></a>
-<span class="sourceLineNo">2892</span>   * This instance is shared between HBaseTestingUtility instance users.<a name="line.2892"></a>
-<span class="sourceLineNo">2893</span>   * Don't close it, it will be closed automatically when the<a name="line.2893"></a>
-<span class="sourceLineNo">2894</span>   * cluster shutdowns<a name="line.2894"></a>
-<span class="sourceLineNo">2895</span>   *<a name="line.2895"></a>
-<span class="sourceLineNo">2896</span>   * @return The ZKWatcher instance.<a name="line.2896"></a>
-<span class="sourceLineNo">2897</span>   * @throws IOException<a name="line.2897"></a>
-<span class="sourceLineNo">2898</span>   */<a name="line.2898"></a>
-<span class="sourceLineNo">2899</span>  public synchronized ZKWatcher getZooKeeperWatcher()<a name="line.2899"></a>
-<span class="sourceLineNo">2900</span>    throws IOException {<a name="line.2900"></a>
-<span class="sourceLineNo">2901</span>    if (zooKeeperWatcher == null) {<a name="line.2901"></a>
-<span class="sourceLineNo">2902</span>      zooKeeperWatcher = new ZKWatcher(conf, "testing utility",<a name="line.2902"></a>
-<span class="sourceLineNo">2903</span>        new Abortable() {<a name="line.2903"></a>
-<span class="sourceLineNo">2904</span>        @Override public void abort(String why, Throwable e) {<a name="line.2904"></a>
-<span class="sourceLineNo">2905</span>          throw new RuntimeException("Unexpected abort in HBaseTestingUtility:"+why, e);<a name="line.2905"></a>
-<span class="sourceLineNo">2906</span>        }<a name="line.2906"></a>
-<span class="sourceLineNo">2907</span>        @Override public boolean isAborted() {return false;}<a name="line.2907"></a>
-<span class="sourceLineNo">2908</span>      });<a name="line.2908"></a>
-<span class="sourceLineNo">2909</span>    }<a name="line.2909"></a>
-<span class="sourceLineNo">2910</span>    return zooKeeperWatcher;<a name="line.2910"></a>
-<span class="sourceLineNo">2911</span>  }<a name="line.2911"></a>
-<span class="sourceLineNo">2912</span>  private ZKWatcher zooKeeperWatcher;<a name="line.2912"></a>
-<span class="sourceLineNo">2913</span><a name="line.2913"></a>
-<span class="sourceLineNo">2914</span><a name="line.2914"></a>
-<span class="sourceLineNo">2915</span><a name="line.2915"></a>
-<span class="sourceLineNo">2916</span>  /**<a name="line.2916"></a>
-<span class="sourceLineNo">2917</span>   * Unassign the named region.<a name="line.2917"></a>
-<span class="sourceLineNo">2918</span>   *<a name="line.2918"></a>
-<span class="sourceLineNo">2919</span>   * @param regionName  The region to unassign.<a name="line.2919"></a>
-<span class="sourceLineNo">2920</span>   */<a name="line.2920"></a>
-<span class="sourceLineNo">2921</span>  public void unassignRegion(String regionName) throws IOException {<a name="line.2921"></a>
-<span class="sourceLineNo">2922</span>    unassignRegion(Bytes.toBytes(regionName));<a name="line.2922"></a>
-<span class="sourceLineNo">2923</span>  }<a name="line.2923"></a>
-<span class="sourceLineNo">2924</span><a name="line.2924"></a>
-<span class="sourceLineNo">2925</span>  /**<a name="line.2925"></a>
-<span class="sourceLineNo">2926</span>   * Unassign the named region.<a name="line.2926"></a>
-<span class="sourceLineNo">2927</span>   *<a name="line.2927"></a>
-<span class="sourceLineNo">2928</span>   * @param regionName  The region to unassign.<a name="line.2928"></a>
-<span class="sourceLineNo">2929</span>   */<a name="line.2929"></a>
-<span class="sourceLineNo">2930</span>  public void unassignRegion(byte[] regionName) throws IOException {<a name="line.2930"></a>
-<span class="sourceLineNo">2931</span>    getAdmin().unassign(regionName, true);<a name="line.2931"></a>
-<span class="sourceLineNo">2932</span>  }<a name="line.2932"></a>
-<span class="sourceLineNo">2933</span><a name="line.2933"></a>
-<span class="sourceLineNo">2934</span>  /**<a name="line.2934"></a>
-<span class="sourceLineNo">2935</span>   * Closes the region containing the given row.<a name="line.2935"></a>
-<span class="sourceLineNo">2936</span>   *<a name="line.2936"></a>
-<span class="sourceLineNo">2937</span>   * @param row  The row to find the containing region.<a name="line.2937"></a>
-<span class="sourceLineNo">2938</span>   * @param table  The table to find the region.<a name="line.2938"></a>
-<span class="sourceLineNo">2939</span>   */<a name="line.2939"></a>
-<span class="sourceLineNo">2940</span>  public void unassignRegionByRow(String row, RegionLocator table) throws IOException {<a name="line.2940"></a>
-<span class="sourceLineNo">2941</span>    unassignRegionByRow(Bytes.toBytes(row), table);<a name="line.2941"></a>
-<span class="sourceLineNo">2942</span>  }<a name="line.2942"></a>
-<span class="sourceLineNo">2943</span><a name="line.2943"></a>
-<span class="sourceLineNo">2944</span>  /**<a name="line.2944"></a>
-<span class="sourceLineNo">2945</span>   * Closes the region containing the given row.<a name="line.2945"></a>
-<span class="sourceLineNo">2946</span>   *<a name="line.2946"></a>
-<span class="sourceLineNo">2947</span>   * @param row  The row to find the containing region.<a name="line.2947"></a>
-<span class="sourceLineNo">2948</span>   * @param table  The table to find the region.<a name="line.2948"></a>
-<span class="sourceLineNo">2949</span>   * @throws IOException<a name="line.2949"></a>
-<span class="sourceLineNo">2950</span>   */<a name="line.2950"></a>
-<span class="sourceLineNo">2951</span>  public void unassignRegionByRow(byte[] row, RegionLocator table) throws IOException {<a name="line.2951"></a>
-<span class="sourceLineNo">2952</span>    HRegionLocation hrl = table.getRegionLocation(row);<a name="line.2952"></a>
-<span class="sourceLineNo">2953</span>    unassignRegion(hrl.getRegionInfo().getRegionName());<a name="line.2953"></a>
-<span class="sourceLineNo">2954</span>  }<a name="line.2954"></a>
-<span class="sourceLineNo">2955</span><a name="line.2955"></a>
-<span class="sourceLineNo">2956</span>  /*<a name="line.2956"></a>
-<span class="sourceLineNo">2957</span>   * Retrieves a splittable region randomly from tableName<a name="line.2957"></a>
-<span class="sourceLineNo">2958</span>   *<a name="line.2958"></a>
-<span class="sourceLineNo">2959</span>   * @param tableName name of table<a name="line.2959"></a>
-<span class="sourceLineNo">2960</span>   * @param maxAttempts maximum number of attempts, unlimited for value of -1<a name="line.2960"></a>
-<span class="sourceLineNo">2961</span>   * @return the HRegion chosen, null if none was found within limit of maxAttempts<a name="line.2961"></a>
-<span class="sourceLineNo">2962</span>   */<a name="line.2962"></a>
-<span class="sourceLineNo">2963</span>  public HRegion getSplittableRegion(TableName tableName, int maxAttempts) {<a name="line.2963"></a>
-<span class="sourceLineNo">2964</span>    List&lt;HRegion&gt; regions = getHBaseCluster().getRegions(tableName);<a name="line.2964"></a>
-<span class="sourceLineNo">2965</span>    int regCount = regions.size();<a name="line.2965"></a>
-<span class="sourceLineNo">2966</span>    Set&lt;Integer&gt; attempted = new HashSet&lt;&gt;();<a name="line.2966"></a>
-<span class="sourceLineNo">2967</span>    int idx;<a name="line.2967"></a>
-<span class="sourceLineNo">2968</span>    int attempts = 0;<a name="line.2968"></a>
-<span class="sourceLineNo">2969</span>    do {<a name="line.2969"></a>
-<span class="sourceLineNo">2970</span>      regions = getHBaseCluster().getRegions(tableName);<a name="line.2970"></a>
-<span class="sourceLineNo">2971</span>      if (regCount != regions.size()) {<a name="line.2971"></a>
-<span class="sourceLineNo">2972</span>        // if there was region movement, clear attempted Set<a name="line.2972"></a>
-<span class="sourceLineNo">2973</span>        attempted.clear();<a name="line.2973"></a>
-<span class="sourceLineNo">2974</span>      }<a name="line.2974"></a>
-<span class="sourceLineNo">2975</span>      regCount = regions.size();<a name="line.2975"></a>
-<span class="sourceLineNo">2976</span>      // There are chances that before we get the region for the table from an RS the region may<a name="line.2976"></a>
-<span class="sourceLineNo">2977</span>      // be going for CLOSE.  This may be because online schema change is enabled<a name="line.2977"></a>
-<span class="sourceLineNo">2978</span>      if (regCount &gt; 0) {<a name="line.2978"></a>
-<span class="sourceLineNo">2979</span>        idx = random.nextInt(regCount);<a name="line.2979"></a>
-<span class="sourceLineNo">2980</span>        // if we have just tried this region, there is no need to try again<a name="line.2980"></a>
-<span class="sourceLineNo">2981</span>        if (attempted.contains(idx))<a name="line.2981"></a>
-<span class="sourceLineNo">2982</span>          continue;<a name="line.2982"></a>
-<span class="sourceLineNo">2983</span>        try {<a name="line.2983"></a>
-<span class="sourceLineNo">2984</span>          regions.get(idx).checkSplit();<a name="line.2984"></a>
-<span class="sourceLineNo">2985</span>          return regions.get(idx);<a name="line.2985"></a>
-<span class="sourceLineNo">2986</span>        } catch (Exception ex) {<a name="line.2986"></a>
-<span class="sourceLineNo">2987</span>          LOG.warn("Caught exception", ex);<a name="line.2987"></a>
-<span class="sourceLineNo">2988</span>          attempted.add(idx);<a name="line.2988"></a>
-<span class="sourceLineNo">2989</span>        }<a name="line.2989"></a>
-<span class="sourceLineNo">2990</span>      }<a name="line.2990"></a>
-<span class="sourceLineNo">2991</span>      attempts++;<a name="line.2991"></a>
-<span class="sourceLineNo">2992</span>    } while (maxAttempts == -1 || attempts &lt; maxAttempts);<a name="line.2992"></a>
-<span class="sourceLineNo">2993</span>    return null;<a name="line.2993"></a>
-<span class="sourceLineNo">2994</span>  }<a name="line.2994"></a>
-<span class="sourceLineNo">2995</span><a name="line.2995"></a>
-<span class="sourceLineNo">2996</span>  public MiniZooKeeperCluster getZkCluster() {<a name="line.2996"></a>
-<span class="sourceLineNo">2997</span>    return zkCluster;<a name="line.2997"></a>
-<span class="sourceLineNo">2998</span>  }<a name="line.2998"></a>
-<span class="sourceLineNo">2999</span><a name="line.2999"></a>
-<span class="sourceLineNo">3000</span>  public void setZkCluster(MiniZooKeeperCluster zkCluster) {<a name="line.3000"></a>
-<span class="sourceLineNo">3001</span>    this.passedZkCluster = true;<a name="line.3001"></a>
-<span class="sourceLineNo">3002</span>    this.zkCluster = zkCluster;<a name="line.3002"></a>
-<span class="sourceLineNo">3003</span>    conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkCluster.getClientPort());<a name="line.3003"></a>
-<span class="sourceLineNo">3004</span>  }<a name="line.3004"></a>
-<span class="sourceLineNo">3005</span><a name="line.3005"></a>
-<span class="sourceLineNo">3006</span>  public MiniDFSCluster getDFSCluster() {<a name="line.3006"></a>
-<span class="sourceLineNo">3007</span>    return dfsCluster;<a name="line.3007"></a>
-<span class="sourceLineNo">3008</span>  }<a name="line.3008"></a>
-<span class="sourceLineNo">3009</span><a name="line.3009"></a>
-<span class="sourceLineNo">3010</span>  public void setDFSCluster(MiniDFSCluster cluster) throws IllegalStateException, IOException {<a name="line.3010"></a>
-<span class="sourceLineNo">3011</span>    setDFSCluster(cluster, true);<a name="line.3011"></a>
-<span class="sourceLineNo">3012</span>  }<a name="line.3012"></a>
-<span class="sourceLineNo">3013</span><a name="line.3013"></a>
-<span class="sourceLineNo">3014</span>  /**<a name="line.3014"></a>
-<span class="sourceLineNo">3015</span>   * Set the MiniDFSCluster<a name="line.3015"></a>
-<span class="sourceLineNo">3016</span>   * @param cluster cluster to use<a name="line.3016"></a>
-<span class="sourceLineNo">3017</span>   * @param requireDown require the that cluster not be "up" (MiniDFSCluster#isClusterUp) before<a name="line.3017"></a>
-<span class="sourceLineNo">3018</span>   * it is set.<a name="line.3018"></a>
-<span class="sourceLineNo">3019</span>   * @throws IllegalStateException if the passed cluster is up when it is required to be down<a name="line.3019"></a>
-<span class="sourceLineNo">3020</span>   * @throws IOException if the FileSystem could not be set from the passed dfs cluster<a name="line.3020"></a>
-<span class="sourceLineNo">3021</span>   */<a name="line.3021"></a>
-<span class="sourceLineNo">3022</span>  public void setDFSCluster(MiniDFSCluster cluster, boolean requireDown)<a name="line.3022"></a>
-<span class="sourceLineNo">3023</span>      throws IllegalStateException, IOException {<a name="line.3023"></a>
-<span class="sourceLineNo">3024</span>    if (dfsCluster != null &amp;&amp; requireDown &amp;&amp; dfsCluster.isClusterUp()) {<a name="line.3024"></a>
-<span class="sourceLineNo">3025</span>      throw new IllegalStateException("DFSCluster is already running! Shut it down first.");<a name="line.3025"></a>
-<span class="sourceLineNo">3026</span>    }<a name="line.3026"></a>
-<span class="sourceLineNo">3027</span>    this.dfsCluster = cluster;<a name="line.3027"></a>
-<span class="sourceLineNo">3028</span>    this.setFs();<a name="line.3028"></a>
-<span class="sourceLineNo">3029</span>  }<a name="line.3029"></a>
-<span class="sourceLineNo">3030</span><a name="line.3030"></a>
-<span class="sourceLineNo">3031</span>  public FileSystem getTestFileSystem() throws IOException {<a name="line.3031"></a>
-<span class="sourceLineNo">3032</span>    return HFileSystem.get(conf);<a name="line.3032"></a>
-<span class="sourceLineNo">3033</span>  }<a name="line.3033"></a>
-<span class="sourceLineNo">3034</span><a name="line.3034"></a>
-<span class="sourceLineNo">3035</span>  /**<a name="line.3035"></a>
-<span class="sourceLineNo">3036</span>   * Wait until all regions in a table have been assigned.  Waits default timeout before giving up<a name="line.3036"></a>
-<span class="sourceLineNo">3037</span>   * (30 seconds).<a name="line.3037"></a>
-<span class="sourceLineNo">3038</span>   * @param table Table to wait on.<a name="line.3038"></a>
-<span class="sourceLineNo">3039</span>   * @throws InterruptedException<a name="line.3039"></a>
-<span class="sourceLineNo">3040</span>   * @throws IOException<a name="line.3040"></a>
-<span class="sourceLineNo">3041</span>   */<a name="line.3041"></a>
-<span class="sourceLineNo">3042</span>  public void waitTableAvailable(TableName table)<a name="line.3042"></a>
-<span class="sourceLineNo">3043</span>      throws InterruptedException, IOException {<a name="line.3043"></a>
-<span class="sourceLineNo">3044</span>    waitTableAvailable(table.getName(), 30000);<a name="line.3044"></a>
-<span class="sourceLineNo">3045</span>  }<a name="line.3045"></a>
-<span class="sourceLineNo">3046</span><a name="line.3046"></a>
-<span class="sourceLineNo">3047</span>  public void waitTableAvailable(TableName table, long timeoutMillis)<a name="line.3047"></a>
-<span class="sourceLineNo">3048</span>      throws InterruptedException, IOException {<a name="line.3048"></a>
-<span class="sourceLineNo">3049</span>    waitFor(timeoutMillis, predicateTableAvailable(table));<a name="line.3049"></a>
-<span class="sourceLineNo">3050</span>  }<a name="line.3050"></a>
-<span class="sourceLineNo">3051</span><a name="line.3051"></a>
-<span class="sourceLineNo">3052</span>  /**<a name="line.3052"></a>
-<span class="sourceLineNo">3053</span>   * Wait until all regions in a table have been assigned<a name="line.3053"></a>
-<span class="sourceLineNo">3054</span>   * @param table Table to wait on.<a name="line.3054"></a>
-<span class="sourceLineNo">3055</span>   * @param timeoutMillis Timeout.<a name="line.3055"></a>
-<span class="sourceLineNo">3056</span>   * @throws InterruptedException<a name="line.3056"></a>
-<span class="sourceLineNo">3057</span>   * @throws IOException<a name="line.3057"></a>
-<span class="sourceLineNo">3058</span>   */<a name="line.3058"></a>
-<span class="sourceLineNo">3059</span>  public void waitTableAvailable(byte[] table, long timeoutMillis)<a name="line.3059"></a>
-<span class="sourceLineNo">3060</span>  throws InterruptedException, IOException {<a name="line.3060"></a>
-<span class="sourceLineNo">3061</span>    waitFor(timeoutMillis, predicateTableAvailable(TableName.valueOf(table)));<a name="line.3061"></a>
-<span class="sourceLineNo">3062</span>  }<a name="line.3062"></a>
-<span class="sourceLineNo">3063</span><a name="line.3063"></a>
-<span class="sourceLineNo">3064</span>  public String explainTableAvailability(TableName tableName) throws IOException {<a name="line.3064"></a>
-<span class="sourceLineNo">3065</span>    String msg = explainTableState(tableName, TableState.State.ENABLED) + ", ";<a name="line.3065"></a>
-<span class="sourceLineNo">3066</span>    if (getHBaseCluster().getMaster().isAlive()) {<a name="line.3066"></a>
-<span class="sourceLineNo">3067</span>      Map&lt;RegionInfo, ServerName&gt; assignments =<a name="line.3067"></a>
-<span class="sourceLineNo">3068</span>          getHBaseCluster().getMaster().getAssignmentManager().getRegionStates()<a name="line.3068"></a>
-<span class="sourceLineNo">3069</span>              .getRegionAssignments();<a name="line.3069"></a>
-<span class="sourceLineNo">3070</span>      final List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; metaLocations =<a name="line.3070"></a>
-<span class="sourceLineNo">3071</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, tableName);<a name="line.3071"></a>
-<span class="sourceLineNo">3072</span>      for (Pair&lt;RegionInfo, ServerName&gt; metaLocation : metaLocations) {<a name="line.3072"></a>
-<span class="sourceLineNo">3073</span>        RegionInfo hri = metaLocation.getFirst();<a name="line.3073"></a>
-<span class="sourceLineNo">3074</span>        ServerName sn = metaLocation.getSecond();<a name="line.3074"></a>
-<span class="sourceLineNo">3075</span>        if (!assignments.containsKey(hri)) {<a name="line.3075"></a>
-<span class="sourceLineNo">3076</span>          msg += ", region " + hri<a name="line.3076"></

<TRUNCATED>

Mime
View raw message