hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [42/51] [partial] hbase-site git commit: Published site at .
Date Thu, 09 Nov 2017 15:17:10 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2b3f2bee/apidocs/src-html/org/apache/hadoop/hbase/exceptions/RegionInRecoveryException.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/exceptions/RegionInRecoveryException.html b/apidocs/src-html/org/apache/hadoop/hbase/exceptions/RegionInRecoveryException.html
deleted file mode 100644
index e324a9e..0000000
--- a/apidocs/src-html/org/apache/hadoop/hbase/exceptions/RegionInRecoveryException.html
+++ /dev/null
@@ -1,116 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html lang="en">
-<head>
-<title>Source code</title>
-<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
-</head>
-<body>
-<div class="sourceContainer">
-<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
-<span class="sourceLineNo">002</span> *<a name="line.2"></a>
-<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a>
-<span class="sourceLineNo">004</span> * or more contributor license agreements.  See the NOTICE file<a name="line.4"></a>
-<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a>
-<span class="sourceLineNo">006</span> * regarding copyright ownership.  The ASF licenses this file<a name="line.6"></a>
-<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a>
-<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a>
-<span class="sourceLineNo">009</span> * with the License.  You may obtain a copy of the License at<a name="line.9"></a>
-<span class="sourceLineNo">010</span> *<a name="line.10"></a>
-<span class="sourceLineNo">011</span> *     http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a>
-<span class="sourceLineNo">012</span> *<a name="line.12"></a>
-<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a>
-<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a>
-<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a>
-<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a>
-<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a>
-<span class="sourceLineNo">018</span> */<a name="line.18"></a>
-<span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.exceptions;<a name="line.19"></a>
-<span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.22"></a>
-<span class="sourceLineNo">023</span><a name="line.23"></a>
-<span class="sourceLineNo">024</span>/**<a name="line.24"></a>
-<span class="sourceLineNo">025</span> * Thrown when a read request issued against a region which is in recovering state.<a name="line.25"></a>
-<span class="sourceLineNo">026</span> */<a name="line.26"></a>
-<span class="sourceLineNo">027</span>@InterfaceAudience.Public<a name="line.27"></a>
-<span class="sourceLineNo">028</span>public class RegionInRecoveryException extends NotServingRegionException {<a name="line.28"></a>
-<span class="sourceLineNo">029</span>  private static final long serialVersionUID = 327302071153799L;<a name="line.29"></a>
-<span class="sourceLineNo">030</span><a name="line.30"></a>
-<span class="sourceLineNo">031</span>  /** default constructor */<a name="line.31"></a>
-<span class="sourceLineNo">032</span>  public RegionInRecoveryException() {<a name="line.32"></a>
-<span class="sourceLineNo">033</span>    super();<a name="line.33"></a>
-<span class="sourceLineNo">034</span>  }<a name="line.34"></a>
-<span class="sourceLineNo">035</span><a name="line.35"></a>
-<span class="sourceLineNo">036</span>  /**<a name="line.36"></a>
-<span class="sourceLineNo">037</span>   * Constructor<a name="line.37"></a>
-<span class="sourceLineNo">038</span>   * @param s message<a name="line.38"></a>
-<span class="sourceLineNo">039</span>   */<a name="line.39"></a>
-<span class="sourceLineNo">040</span>  public RegionInRecoveryException(String s) {<a name="line.40"></a>
-<span class="sourceLineNo">041</span>    super(s);<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  }<a name="line.42"></a>
-<span class="sourceLineNo">043</span><a name="line.43"></a>
-<span class="sourceLineNo">044</span>}<a name="line.44"></a>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-</pre>
-</div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2b3f2bee/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html
----------------------------------------------------------------------
diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html
index 898d59a..be26fad 100644
--- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html
+++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html
@@ -276,391 +276,392 @@
 <span class="sourceLineNo">268</span>      }<a name="line.268"></a>
 <span class="sourceLineNo">269</span><a name="line.269"></a>
 <span class="sourceLineNo">270</span>      //The default value of "hbase.mapreduce.input.autobalance" is false.<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      if (context.getConfiguration().getBoolean(MAPREDUCE_INPUT_AUTOBALANCE, false) != false) {<a name="line.271"></a>
-<span class="sourceLineNo">272</span>        long maxAveRegionSize = context.getConfiguration().getInt(MAX_AVERAGE_REGION_SIZE, 8*1073741824);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>        return calculateAutoBalancedSplits(splits, maxAveRegionSize);<a name="line.273"></a>
-<span class="sourceLineNo">274</span>      }<a name="line.274"></a>
-<span class="sourceLineNo">275</span><a name="line.275"></a>
-<span class="sourceLineNo">276</span>      // return one mapper per region<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      return splits;<a name="line.277"></a>
-<span class="sourceLineNo">278</span>    } finally {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>      if (closeOnFinish) {<a name="line.279"></a>
-<span class="sourceLineNo">280</span>        closeTable();<a name="line.280"></a>
-<span class="sourceLineNo">281</span>      }<a name="line.281"></a>
-<span class="sourceLineNo">282</span>    }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>  }<a name="line.283"></a>
-<span class="sourceLineNo">284</span><a name="line.284"></a>
-<span class="sourceLineNo">285</span>  /**<a name="line.285"></a>
-<span class="sourceLineNo">286</span>   * Create one InputSplit per region<a name="line.286"></a>
-<span class="sourceLineNo">287</span>   *<a name="line.287"></a>
-<span class="sourceLineNo">288</span>   * @return The list of InputSplit for all the regions<a name="line.288"></a>
-<span class="sourceLineNo">289</span>   * @throws IOException<a name="line.289"></a>
-<span class="sourceLineNo">290</span>   */<a name="line.290"></a>
-<span class="sourceLineNo">291</span>  private List&lt;InputSplit&gt; oneInputSplitPerRegion() throws IOException {<a name="line.291"></a>
-<span class="sourceLineNo">292</span>    RegionSizeCalculator sizeCalculator =<a name="line.292"></a>
-<span class="sourceLineNo">293</span>        new RegionSizeCalculator(getRegionLocator(), getAdmin());<a name="line.293"></a>
-<span class="sourceLineNo">294</span><a name="line.294"></a>
-<span class="sourceLineNo">295</span>    TableName tableName = getTable().getName();<a name="line.295"></a>
-<span class="sourceLineNo">296</span><a name="line.296"></a>
-<span class="sourceLineNo">297</span>    Pair&lt;byte[][], byte[][]&gt; keys = getStartEndKeys();<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    if (keys == null || keys.getFirst() == null ||<a name="line.298"></a>
-<span class="sourceLineNo">299</span>        keys.getFirst().length == 0) {<a name="line.299"></a>
-<span class="sourceLineNo">300</span>      HRegionLocation regLoc =<a name="line.300"></a>
-<span class="sourceLineNo">301</span>          getRegionLocator().getRegionLocation(HConstants.EMPTY_BYTE_ARRAY, false);<a name="line.301"></a>
-<span class="sourceLineNo">302</span>      if (null == regLoc) {<a name="line.302"></a>
-<span class="sourceLineNo">303</span>        throw new IOException("Expecting at least one region.");<a name="line.303"></a>
-<span class="sourceLineNo">304</span>      }<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      List&lt;InputSplit&gt; splits = new ArrayList&lt;&gt;(1);<a name="line.305"></a>
-<span class="sourceLineNo">306</span>      long regionSize = sizeCalculator.getRegionSize(regLoc.getRegionInfo().getRegionName());<a name="line.306"></a>
-<span class="sourceLineNo">307</span>      TableSplit split = new TableSplit(tableName, scan,<a name="line.307"></a>
-<span class="sourceLineNo">308</span>          HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, regLoc<a name="line.308"></a>
-<span class="sourceLineNo">309</span>          .getHostnamePort().split(Addressing.HOSTNAME_PORT_SEPARATOR)[0], regionSize);<a name="line.309"></a>
-<span class="sourceLineNo">310</span>      splits.add(split);<a name="line.310"></a>
-<span class="sourceLineNo">311</span>      return splits;<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    }<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    List&lt;InputSplit&gt; splits = new ArrayList&lt;&gt;(keys.getFirst().length);<a name="line.313"></a>
-<span class="sourceLineNo">314</span>    for (int i = 0; i &lt; keys.getFirst().length; i++) {<a name="line.314"></a>
-<span class="sourceLineNo">315</span>      if (!includeRegionInSplit(keys.getFirst()[i], keys.getSecond()[i])) {<a name="line.315"></a>
-<span class="sourceLineNo">316</span>        continue;<a name="line.316"></a>
-<span class="sourceLineNo">317</span>      }<a name="line.317"></a>
-<span class="sourceLineNo">318</span><a name="line.318"></a>
-<span class="sourceLineNo">319</span>      byte[] startRow = scan.getStartRow();<a name="line.319"></a>
-<span class="sourceLineNo">320</span>      byte[] stopRow = scan.getStopRow();<a name="line.320"></a>
-<span class="sourceLineNo">321</span>      // determine if the given start an stop key fall into the region<a name="line.321"></a>
-<span class="sourceLineNo">322</span>      if ((startRow.length == 0 || keys.getSecond()[i].length == 0 ||<a name="line.322"></a>
-<span class="sourceLineNo">323</span>          Bytes.compareTo(startRow, keys.getSecond()[i]) &lt; 0) &amp;&amp;<a name="line.323"></a>
-<span class="sourceLineNo">324</span>          (stopRow.length == 0 ||<a name="line.324"></a>
-<span class="sourceLineNo">325</span>              Bytes.compareTo(stopRow, keys.getFirst()[i]) &gt; 0)) {<a name="line.325"></a>
-<span class="sourceLineNo">326</span>        byte[] splitStart = startRow.length == 0 ||<a name="line.326"></a>
-<span class="sourceLineNo">327</span>            Bytes.compareTo(keys.getFirst()[i], startRow) &gt;= 0 ?<a name="line.327"></a>
-<span class="sourceLineNo">328</span>            keys.getFirst()[i] : startRow;<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        byte[] splitStop = (stopRow.length == 0 ||<a name="line.329"></a>
-<span class="sourceLineNo">330</span>            Bytes.compareTo(keys.getSecond()[i], stopRow) &lt;= 0) &amp;&amp;<a name="line.330"></a>
-<span class="sourceLineNo">331</span>            keys.getSecond()[i].length &gt; 0 ?<a name="line.331"></a>
-<span class="sourceLineNo">332</span>            keys.getSecond()[i] : stopRow;<a name="line.332"></a>
-<span class="sourceLineNo">333</span><a name="line.333"></a>
-<span class="sourceLineNo">334</span>        HRegionLocation location = getRegionLocator().getRegionLocation(keys.getFirst()[i], false);<a name="line.334"></a>
-<span class="sourceLineNo">335</span>        // The below InetSocketAddress creation does a name resolution.<a name="line.335"></a>
-<span class="sourceLineNo">336</span>        InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort());<a name="line.336"></a>
-<span class="sourceLineNo">337</span>        if (isa.isUnresolved()) {<a name="line.337"></a>
-<span class="sourceLineNo">338</span>          LOG.warn("Failed resolve " + isa);<a name="line.338"></a>
-<span class="sourceLineNo">339</span>        }<a name="line.339"></a>
-<span class="sourceLineNo">340</span>        InetAddress regionAddress = isa.getAddress();<a name="line.340"></a>
-<span class="sourceLineNo">341</span>        String regionLocation;<a name="line.341"></a>
-<span class="sourceLineNo">342</span>        regionLocation = reverseDNS(regionAddress);<a name="line.342"></a>
-<span class="sourceLineNo">343</span><a name="line.343"></a>
-<span class="sourceLineNo">344</span>        byte[] regionName = location.getRegionInfo().getRegionName();<a name="line.344"></a>
-<span class="sourceLineNo">345</span>        String encodedRegionName = location.getRegionInfo().getEncodedName();<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        long regionSize = sizeCalculator.getRegionSize(regionName);<a name="line.346"></a>
-<span class="sourceLineNo">347</span>        TableSplit split = new TableSplit(tableName, scan,<a name="line.347"></a>
-<span class="sourceLineNo">348</span>            splitStart, splitStop, regionLocation, encodedRegionName, regionSize);<a name="line.348"></a>
-<span class="sourceLineNo">349</span>        splits.add(split);<a name="line.349"></a>
-<span class="sourceLineNo">350</span>        if (LOG.isDebugEnabled()) {<a name="line.350"></a>
-<span class="sourceLineNo">351</span>          LOG.debug("getSplits: split -&gt; " + i + " -&gt; " + split);<a name="line.351"></a>
-<span class="sourceLineNo">352</span>        }<a name="line.352"></a>
-<span class="sourceLineNo">353</span>      }<a name="line.353"></a>
-<span class="sourceLineNo">354</span>    }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>    return splits;<a name="line.355"></a>
-<span class="sourceLineNo">356</span>  }<a name="line.356"></a>
-<span class="sourceLineNo">357</span><a name="line.357"></a>
-<span class="sourceLineNo">358</span>  /**<a name="line.358"></a>
-<span class="sourceLineNo">359</span>   * Create n splits for one InputSplit, For now only support uniform distribution<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   * @param split A TableSplit corresponding to a range of rowkeys<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   * @param n     Number of ranges after splitting.  Pass 1 means no split for the range<a name="line.361"></a>
-<span class="sourceLineNo">362</span>   *              Pass 2 if you want to split the range in two;<a name="line.362"></a>
-<span class="sourceLineNo">363</span>   * @return A list of TableSplit, the size of the list is n<a name="line.363"></a>
-<span class="sourceLineNo">364</span>   * @throws IllegalArgumentIOException<a name="line.364"></a>
-<span class="sourceLineNo">365</span>   */<a name="line.365"></a>
-<span class="sourceLineNo">366</span>  protected List&lt;InputSplit&gt; createNInputSplitsUniform(InputSplit split, int n)<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      throws IllegalArgumentIOException {<a name="line.367"></a>
-<span class="sourceLineNo">368</span>    if (split == null || !(split instanceof TableSplit)) {<a name="line.368"></a>
-<span class="sourceLineNo">369</span>      throw new IllegalArgumentIOException(<a name="line.369"></a>
-<span class="sourceLineNo">370</span>          "InputSplit for CreateNSplitsPerRegion can not be null + "<a name="line.370"></a>
-<span class="sourceLineNo">371</span>              + "and should be instance of TableSplit");<a name="line.371"></a>
-<span class="sourceLineNo">372</span>    }<a name="line.372"></a>
-<span class="sourceLineNo">373</span>    //if n &lt; 1, then still continue using n = 1<a name="line.373"></a>
-<span class="sourceLineNo">374</span>    n = n &lt; 1 ? 1 : n;<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    List&lt;InputSplit&gt; res = new ArrayList&lt;&gt;(n);<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    if (n == 1) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>      res.add(split);<a name="line.377"></a>
-<span class="sourceLineNo">378</span>      return res;<a name="line.378"></a>
-<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
-<span class="sourceLineNo">380</span><a name="line.380"></a>
-<span class="sourceLineNo">381</span>    // Collect Region related information<a name="line.381"></a>
-<span class="sourceLineNo">382</span>    TableSplit ts = (TableSplit) split;<a name="line.382"></a>
-<span class="sourceLineNo">383</span>    TableName tableName = ts.getTable();<a name="line.383"></a>
-<span class="sourceLineNo">384</span>    String regionLocation = ts.getRegionLocation();<a name="line.384"></a>
-<span class="sourceLineNo">385</span>    String encodedRegionName = ts.getEncodedRegionName();<a name="line.385"></a>
-<span class="sourceLineNo">386</span>    long regionSize = ts.getLength();<a name="line.386"></a>
-<span class="sourceLineNo">387</span>    byte[] startRow = ts.getStartRow();<a name="line.387"></a>
-<span class="sourceLineNo">388</span>    byte[] endRow = ts.getEndRow();<a name="line.388"></a>
-<span class="sourceLineNo">389</span><a name="line.389"></a>
-<span class="sourceLineNo">390</span>    // For special case: startRow or endRow is empty<a name="line.390"></a>
-<span class="sourceLineNo">391</span>    if (startRow.length == 0 &amp;&amp; endRow.length == 0){<a name="line.391"></a>
-<span class="sourceLineNo">392</span>      startRow = new byte[1];<a name="line.392"></a>
-<span class="sourceLineNo">393</span>      endRow = new byte[1];<a name="line.393"></a>
-<span class="sourceLineNo">394</span>      startRow[0] = 0;<a name="line.394"></a>
-<span class="sourceLineNo">395</span>      endRow[0] = -1;<a name="line.395"></a>
-<span class="sourceLineNo">396</span>    }<a name="line.396"></a>
-<span class="sourceLineNo">397</span>    if (startRow.length == 0 &amp;&amp; endRow.length != 0){<a name="line.397"></a>
-<span class="sourceLineNo">398</span>      startRow = new byte[1];<a name="line.398"></a>
-<span class="sourceLineNo">399</span>      startRow[0] = 0;<a name="line.399"></a>
-<span class="sourceLineNo">400</span>    }<a name="line.400"></a>
-<span class="sourceLineNo">401</span>    if (startRow.length != 0 &amp;&amp; endRow.length == 0){<a name="line.401"></a>
-<span class="sourceLineNo">402</span>      endRow =new byte[startRow.length];<a name="line.402"></a>
-<span class="sourceLineNo">403</span>      for (int k = 0; k &lt; startRow.length; k++){<a name="line.403"></a>
-<span class="sourceLineNo">404</span>        endRow[k] = -1;<a name="line.404"></a>
-<span class="sourceLineNo">405</span>      }<a name="line.405"></a>
-<span class="sourceLineNo">406</span>    }<a name="line.406"></a>
-<span class="sourceLineNo">407</span><a name="line.407"></a>
-<span class="sourceLineNo">408</span>    // Split Region into n chunks evenly<a name="line.408"></a>
-<span class="sourceLineNo">409</span>    byte[][] splitKeys = Bytes.split(startRow, endRow, true, n-1);<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    for (int i = 0; i &lt; splitKeys.length - 1; i++) {<a name="line.410"></a>
-<span class="sourceLineNo">411</span>      //notice that the regionSize parameter may be not very accurate<a name="line.411"></a>
-<span class="sourceLineNo">412</span>      TableSplit tsplit =<a name="line.412"></a>
-<span class="sourceLineNo">413</span>          new TableSplit(tableName, scan, splitKeys[i], splitKeys[i + 1], regionLocation,<a name="line.413"></a>
-<span class="sourceLineNo">414</span>              encodedRegionName, regionSize / n);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>      res.add(tsplit);<a name="line.415"></a>
-<span class="sourceLineNo">416</span>    }<a name="line.416"></a>
-<span class="sourceLineNo">417</span>    return res;<a name="line.417"></a>
-<span class="sourceLineNo">418</span>  }<a name="line.418"></a>
-<span class="sourceLineNo">419</span>  /**<a name="line.419"></a>
-<span class="sourceLineNo">420</span>   * Calculates the number of MapReduce input splits for the map tasks. The number of<a name="line.420"></a>
-<span class="sourceLineNo">421</span>   * MapReduce input splits depends on the average region size.<a name="line.421"></a>
-<span class="sourceLineNo">422</span>   * Make it 'public' for testing<a name="line.422"></a>
-<span class="sourceLineNo">423</span>   *<a name="line.423"></a>
-<span class="sourceLineNo">424</span>   * @param splits The list of input splits before balance.<a name="line.424"></a>
-<span class="sourceLineNo">425</span>   * @param maxAverageRegionSize max Average region size for one mapper<a name="line.425"></a>
-<span class="sourceLineNo">426</span>   * @return The list of input splits.<a name="line.426"></a>
-<span class="sourceLineNo">427</span>   * @throws IOException When creating the list of splits fails.<a name="line.427"></a>
-<span class="sourceLineNo">428</span>   * @see org.apache.hadoop.mapreduce.InputFormat#getSplits(<a name="line.428"></a>
-<span class="sourceLineNo">429</span>   *org.apache.hadoop.mapreduce.JobContext)<a name="line.429"></a>
-<span class="sourceLineNo">430</span>   */<a name="line.430"></a>
-<span class="sourceLineNo">431</span>  public List&lt;InputSplit&gt; calculateAutoBalancedSplits(List&lt;InputSplit&gt; splits, long maxAverageRegionSize)<a name="line.431"></a>
-<span class="sourceLineNo">432</span>      throws IOException {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    if (splits.size() == 0) {<a name="line.433"></a>
-<span class="sourceLineNo">434</span>      return splits;<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    }<a name="line.435"></a>
-<span class="sourceLineNo">436</span>    List&lt;InputSplit&gt; resultList = new ArrayList&lt;&gt;();<a name="line.436"></a>
-<span class="sourceLineNo">437</span>    long totalRegionSize = 0;<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    for (int i = 0; i &lt; splits.size(); i++) {<a name="line.438"></a>
-<span class="sourceLineNo">439</span>      TableSplit ts = (TableSplit) splits.get(i);<a name="line.439"></a>
-<span class="sourceLineNo">440</span>      totalRegionSize += ts.getLength();<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    }<a name="line.441"></a>
-<span class="sourceLineNo">442</span>    long averageRegionSize = totalRegionSize / splits.size();<a name="line.442"></a>
-<span class="sourceLineNo">443</span>    // totalRegionSize might be overflow, and the averageRegionSize must be positive.<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    if (averageRegionSize &lt;= 0) {<a name="line.444"></a>
-<span class="sourceLineNo">445</span>      LOG.warn("The averageRegionSize is not positive: " + averageRegionSize + ", " +<a name="line.445"></a>
-<span class="sourceLineNo">446</span>          "set it to Long.MAX_VALUE " + splits.size());<a name="line.446"></a>
-<span class="sourceLineNo">447</span>      averageRegionSize = Long.MAX_VALUE / splits.size();<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    }<a name="line.448"></a>
-<span class="sourceLineNo">449</span>    //if averageRegionSize is too big, change it to default as 1 GB,<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    if (averageRegionSize &gt; maxAverageRegionSize) {<a name="line.450"></a>
-<span class="sourceLineNo">451</span>      averageRegionSize = maxAverageRegionSize;<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    }<a name="line.452"></a>
-<span class="sourceLineNo">453</span>    // if averageRegionSize is too small, we do not need to allocate more mappers for those 'large' region<a name="line.453"></a>
-<span class="sourceLineNo">454</span>    // set default as 16M = (default hdfs block size) / 4;<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    if (averageRegionSize &lt; 16 * 1048576) {<a name="line.455"></a>
-<span class="sourceLineNo">456</span>      return splits;<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    }<a name="line.457"></a>
-<span class="sourceLineNo">458</span>    for (int i = 0; i &lt; splits.size(); i++) {<a name="line.458"></a>
-<span class="sourceLineNo">459</span>      TableSplit ts = (TableSplit) splits.get(i);<a name="line.459"></a>
-<span class="sourceLineNo">460</span>      TableName tableName = ts.getTable();<a name="line.460"></a>
-<span class="sourceLineNo">461</span>      String regionLocation = ts.getRegionLocation();<a name="line.461"></a>
-<span class="sourceLineNo">462</span>      String encodedRegionName = ts.getEncodedRegionName();<a name="line.462"></a>
-<span class="sourceLineNo">463</span>      long regionSize = ts.getLength();<a name="line.463"></a>
-<span class="sourceLineNo">464</span><a name="line.464"></a>
-<span class="sourceLineNo">465</span>      if (regionSize &gt;= averageRegionSize) {<a name="line.465"></a>
-<span class="sourceLineNo">466</span>        // make this region as multiple MapReduce input split.<a name="line.466"></a>
-<span class="sourceLineNo">467</span>        int n = (int) Math.round(Math.log(((double) regionSize) / ((double) averageRegionSize)) + 1.0);<a name="line.467"></a>
-<span class="sourceLineNo">468</span>        List&lt;InputSplit&gt; temp = createNInputSplitsUniform(ts, n);<a name="line.468"></a>
-<span class="sourceLineNo">469</span>        resultList.addAll(temp);<a name="line.469"></a>
-<span class="sourceLineNo">470</span>      } else {<a name="line.470"></a>
-<span class="sourceLineNo">471</span>        // if the total size of several small continuous regions less than the average region size,<a name="line.471"></a>
-<span class="sourceLineNo">472</span>        // combine them into one MapReduce input split.<a name="line.472"></a>
-<span class="sourceLineNo">473</span>        long totalSize = regionSize;<a name="line.473"></a>
-<span class="sourceLineNo">474</span>        byte[] splitStartKey = ts.getStartRow();<a name="line.474"></a>
-<span class="sourceLineNo">475</span>        byte[] splitEndKey = ts.getEndRow();<a name="line.475"></a>
-<span class="sourceLineNo">476</span>        int j = i + 1;<a name="line.476"></a>
-<span class="sourceLineNo">477</span>        while (j &lt; splits.size()) {<a name="line.477"></a>
-<span class="sourceLineNo">478</span>          TableSplit nextRegion = (TableSplit) splits.get(j);<a name="line.478"></a>
-<span class="sourceLineNo">479</span>          long nextRegionSize = nextRegion.getLength();<a name="line.479"></a>
-<span class="sourceLineNo">480</span>          if (totalSize + nextRegionSize &lt;= averageRegionSize) {<a name="line.480"></a>
-<span class="sourceLineNo">481</span>            totalSize = totalSize + nextRegionSize;<a name="line.481"></a>
-<span class="sourceLineNo">482</span>            splitEndKey = nextRegion.getEndRow();<a name="line.482"></a>
-<span class="sourceLineNo">483</span>            j++;<a name="line.483"></a>
-<span class="sourceLineNo">484</span>          } else {<a name="line.484"></a>
-<span class="sourceLineNo">485</span>            break;<a name="line.485"></a>
-<span class="sourceLineNo">486</span>          }<a name="line.486"></a>
-<span class="sourceLineNo">487</span>        }<a name="line.487"></a>
-<span class="sourceLineNo">488</span>        i = j - 1;<a name="line.488"></a>
-<span class="sourceLineNo">489</span>        TableSplit t = new TableSplit(tableName, scan, splitStartKey, splitEndKey, regionLocation,<a name="line.489"></a>
-<span class="sourceLineNo">490</span>            encodedRegionName, totalSize);<a name="line.490"></a>
-<span class="sourceLineNo">491</span>        resultList.add(t);<a name="line.491"></a>
-<span class="sourceLineNo">492</span>      }<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    }<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    return resultList;<a name="line.494"></a>
-<span class="sourceLineNo">495</span>  }<a name="line.495"></a>
-<span class="sourceLineNo">496</span><a name="line.496"></a>
-<span class="sourceLineNo">497</span>  String reverseDNS(InetAddress ipAddress) throws UnknownHostException {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>    String hostName = this.reverseDNSCacheMap.get(ipAddress);<a name="line.498"></a>
-<span class="sourceLineNo">499</span>    if (hostName == null) {<a name="line.499"></a>
-<span class="sourceLineNo">500</span>      String ipAddressString = null;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>      try {<a name="line.501"></a>
-<span class="sourceLineNo">502</span>        ipAddressString = DNS.reverseDns(ipAddress, null);<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      } catch (Exception e) {<a name="line.503"></a>
-<span class="sourceLineNo">504</span>        // We can use InetAddress in case the jndi failed to pull up the reverse DNS entry from the<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        // name service. Also, in case of ipv6, we need to use the InetAddress since resolving<a name="line.505"></a>
-<span class="sourceLineNo">506</span>        // reverse DNS using jndi doesn't work well with ipv6 addresses.<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        ipAddressString = InetAddress.getByName(ipAddress.getHostAddress()).getHostName();<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      if (ipAddressString == null) throw new UnknownHostException("No host found for " + ipAddress);<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      hostName = Strings.domainNamePointerToHostName(ipAddressString);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>      this.reverseDNSCacheMap.put(ipAddress, hostName);<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    }<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    return hostName;<a name="line.513"></a>
-<span class="sourceLineNo">514</span>  }<a name="line.514"></a>
-<span class="sourceLineNo">515</span><a name="line.515"></a>
-<span class="sourceLineNo">516</span>  /**<a name="line.516"></a>
-<span class="sourceLineNo">517</span>   * Test if the given region is to be included in the InputSplit while splitting<a name="line.517"></a>
-<span class="sourceLineNo">518</span>   * the regions of a table.<a name="line.518"></a>
-<span class="sourceLineNo">519</span>   * &lt;p&gt;<a name="line.519"></a>
-<span class="sourceLineNo">520</span>   * This optimization is effective when there is a specific reasoning to exclude an entire region from the M-R job,<a name="line.520"></a>
-<span class="sourceLineNo">521</span>   * (and hence, not contributing to the InputSplit), given the start and end keys of the same. &lt;br&gt;<a name="line.521"></a>
-<span class="sourceLineNo">522</span>   * Useful when we need to remember the last-processed top record and revisit the [last, current) interval for M-R processing,<a name="line.522"></a>
-<span class="sourceLineNo">523</span>   * continuously. In addition to reducing InputSplits, reduces the load on the region server as well, due to the ordering of the keys.<a name="line.523"></a>
-<span class="sourceLineNo">524</span>   * &lt;br&gt;<a name="line.524"></a>
+<span class="sourceLineNo">271</span>      if (context.getConfiguration().getBoolean(MAPREDUCE_INPUT_AUTOBALANCE, false)) {<a name="line.271"></a>
+<span class="sourceLineNo">272</span>        long maxAveRegionSize = context.getConfiguration()<a name="line.272"></a>
+<span class="sourceLineNo">273</span>            .getLong(MAX_AVERAGE_REGION_SIZE, 8L*1073741824); //8GB<a name="line.273"></a>
+<span class="sourceLineNo">274</span>        return calculateAutoBalancedSplits(splits, maxAveRegionSize);<a name="line.274"></a>
+<span class="sourceLineNo">275</span>      }<a name="line.275"></a>
+<span class="sourceLineNo">276</span><a name="line.276"></a>
+<span class="sourceLineNo">277</span>      // return one mapper per region<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      return splits;<a name="line.278"></a>
+<span class="sourceLineNo">279</span>    } finally {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      if (closeOnFinish) {<a name="line.280"></a>
+<span class="sourceLineNo">281</span>        closeTable();<a name="line.281"></a>
+<span class="sourceLineNo">282</span>      }<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    }<a name="line.283"></a>
+<span class="sourceLineNo">284</span>  }<a name="line.284"></a>
+<span class="sourceLineNo">285</span><a name="line.285"></a>
+<span class="sourceLineNo">286</span>  /**<a name="line.286"></a>
+<span class="sourceLineNo">287</span>   * Create one InputSplit per region<a name="line.287"></a>
+<span class="sourceLineNo">288</span>   *<a name="line.288"></a>
+<span class="sourceLineNo">289</span>   * @return The list of InputSplit for all the regions<a name="line.289"></a>
+<span class="sourceLineNo">290</span>   * @throws IOException<a name="line.290"></a>
+<span class="sourceLineNo">291</span>   */<a name="line.291"></a>
+<span class="sourceLineNo">292</span>  private List&lt;InputSplit&gt; oneInputSplitPerRegion() throws IOException {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>    RegionSizeCalculator sizeCalculator =<a name="line.293"></a>
+<span class="sourceLineNo">294</span>        new RegionSizeCalculator(getRegionLocator(), getAdmin());<a name="line.294"></a>
+<span class="sourceLineNo">295</span><a name="line.295"></a>
+<span class="sourceLineNo">296</span>    TableName tableName = getTable().getName();<a name="line.296"></a>
+<span class="sourceLineNo">297</span><a name="line.297"></a>
+<span class="sourceLineNo">298</span>    Pair&lt;byte[][], byte[][]&gt; keys = getStartEndKeys();<a name="line.298"></a>
+<span class="sourceLineNo">299</span>    if (keys == null || keys.getFirst() == null ||<a name="line.299"></a>
+<span class="sourceLineNo">300</span>        keys.getFirst().length == 0) {<a name="line.300"></a>
+<span class="sourceLineNo">301</span>      HRegionLocation regLoc =<a name="line.301"></a>
+<span class="sourceLineNo">302</span>          getRegionLocator().getRegionLocation(HConstants.EMPTY_BYTE_ARRAY, false);<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      if (null == regLoc) {<a name="line.303"></a>
+<span class="sourceLineNo">304</span>        throw new IOException("Expecting at least one region.");<a name="line.304"></a>
+<span class="sourceLineNo">305</span>      }<a name="line.305"></a>
+<span class="sourceLineNo">306</span>      List&lt;InputSplit&gt; splits = new ArrayList&lt;&gt;(1);<a name="line.306"></a>
+<span class="sourceLineNo">307</span>      long regionSize = sizeCalculator.getRegionSize(regLoc.getRegionInfo().getRegionName());<a name="line.307"></a>
+<span class="sourceLineNo">308</span>      TableSplit split = new TableSplit(tableName, scan,<a name="line.308"></a>
+<span class="sourceLineNo">309</span>          HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, regLoc<a name="line.309"></a>
+<span class="sourceLineNo">310</span>          .getHostnamePort().split(Addressing.HOSTNAME_PORT_SEPARATOR)[0], regionSize);<a name="line.310"></a>
+<span class="sourceLineNo">311</span>      splits.add(split);<a name="line.311"></a>
+<span class="sourceLineNo">312</span>      return splits;<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    }<a name="line.313"></a>
+<span class="sourceLineNo">314</span>    List&lt;InputSplit&gt; splits = new ArrayList&lt;&gt;(keys.getFirst().length);<a name="line.314"></a>
+<span class="sourceLineNo">315</span>    for (int i = 0; i &lt; keys.getFirst().length; i++) {<a name="line.315"></a>
+<span class="sourceLineNo">316</span>      if (!includeRegionInSplit(keys.getFirst()[i], keys.getSecond()[i])) {<a name="line.316"></a>
+<span class="sourceLineNo">317</span>        continue;<a name="line.317"></a>
+<span class="sourceLineNo">318</span>      }<a name="line.318"></a>
+<span class="sourceLineNo">319</span><a name="line.319"></a>
+<span class="sourceLineNo">320</span>      byte[] startRow = scan.getStartRow();<a name="line.320"></a>
+<span class="sourceLineNo">321</span>      byte[] stopRow = scan.getStopRow();<a name="line.321"></a>
+<span class="sourceLineNo">322</span>      // determine if the given start an stop key fall into the region<a name="line.322"></a>
+<span class="sourceLineNo">323</span>      if ((startRow.length == 0 || keys.getSecond()[i].length == 0 ||<a name="line.323"></a>
+<span class="sourceLineNo">324</span>          Bytes.compareTo(startRow, keys.getSecond()[i]) &lt; 0) &amp;&amp;<a name="line.324"></a>
+<span class="sourceLineNo">325</span>          (stopRow.length == 0 ||<a name="line.325"></a>
+<span class="sourceLineNo">326</span>              Bytes.compareTo(stopRow, keys.getFirst()[i]) &gt; 0)) {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>        byte[] splitStart = startRow.length == 0 ||<a name="line.327"></a>
+<span class="sourceLineNo">328</span>            Bytes.compareTo(keys.getFirst()[i], startRow) &gt;= 0 ?<a name="line.328"></a>
+<span class="sourceLineNo">329</span>            keys.getFirst()[i] : startRow;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>        byte[] splitStop = (stopRow.length == 0 ||<a name="line.330"></a>
+<span class="sourceLineNo">331</span>            Bytes.compareTo(keys.getSecond()[i], stopRow) &lt;= 0) &amp;&amp;<a name="line.331"></a>
+<span class="sourceLineNo">332</span>            keys.getSecond()[i].length &gt; 0 ?<a name="line.332"></a>
+<span class="sourceLineNo">333</span>            keys.getSecond()[i] : stopRow;<a name="line.333"></a>
+<span class="sourceLineNo">334</span><a name="line.334"></a>
+<span class="sourceLineNo">335</span>        HRegionLocation location = getRegionLocator().getRegionLocation(keys.getFirst()[i], false);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>        // The below InetSocketAddress creation does a name resolution.<a name="line.336"></a>
+<span class="sourceLineNo">337</span>        InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort());<a name="line.337"></a>
+<span class="sourceLineNo">338</span>        if (isa.isUnresolved()) {<a name="line.338"></a>
+<span class="sourceLineNo">339</span>          LOG.warn("Failed resolve " + isa);<a name="line.339"></a>
+<span class="sourceLineNo">340</span>        }<a name="line.340"></a>
+<span class="sourceLineNo">341</span>        InetAddress regionAddress = isa.getAddress();<a name="line.341"></a>
+<span class="sourceLineNo">342</span>        String regionLocation;<a name="line.342"></a>
+<span class="sourceLineNo">343</span>        regionLocation = reverseDNS(regionAddress);<a name="line.343"></a>
+<span class="sourceLineNo">344</span><a name="line.344"></a>
+<span class="sourceLineNo">345</span>        byte[] regionName = location.getRegionInfo().getRegionName();<a name="line.345"></a>
+<span class="sourceLineNo">346</span>        String encodedRegionName = location.getRegionInfo().getEncodedName();<a name="line.346"></a>
+<span class="sourceLineNo">347</span>        long regionSize = sizeCalculator.getRegionSize(regionName);<a name="line.347"></a>
+<span class="sourceLineNo">348</span>        TableSplit split = new TableSplit(tableName, scan,<a name="line.348"></a>
+<span class="sourceLineNo">349</span>            splitStart, splitStop, regionLocation, encodedRegionName, regionSize);<a name="line.349"></a>
+<span class="sourceLineNo">350</span>        splits.add(split);<a name="line.350"></a>
+<span class="sourceLineNo">351</span>        if (LOG.isDebugEnabled()) {<a name="line.351"></a>
+<span class="sourceLineNo">352</span>          LOG.debug("getSplits: split -&gt; " + i + " -&gt; " + split);<a name="line.352"></a>
+<span class="sourceLineNo">353</span>        }<a name="line.353"></a>
+<span class="sourceLineNo">354</span>      }<a name="line.354"></a>
+<span class="sourceLineNo">355</span>    }<a name="line.355"></a>
+<span class="sourceLineNo">356</span>    return splits;<a name="line.356"></a>
+<span class="sourceLineNo">357</span>  }<a name="line.357"></a>
+<span class="sourceLineNo">358</span><a name="line.358"></a>
+<span class="sourceLineNo">359</span>  /**<a name="line.359"></a>
+<span class="sourceLineNo">360</span>   * Create n splits for one InputSplit, For now only support uniform distribution<a name="line.360"></a>
+<span class="sourceLineNo">361</span>   * @param split A TableSplit corresponding to a range of rowkeys<a name="line.361"></a>
+<span class="sourceLineNo">362</span>   * @param n     Number of ranges after splitting.  Pass 1 means no split for the range<a name="line.362"></a>
+<span class="sourceLineNo">363</span>   *              Pass 2 if you want to split the range in two;<a name="line.363"></a>
+<span class="sourceLineNo">364</span>   * @return A list of TableSplit, the size of the list is n<a name="line.364"></a>
+<span class="sourceLineNo">365</span>   * @throws IllegalArgumentIOException<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   */<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  protected List&lt;InputSplit&gt; createNInputSplitsUniform(InputSplit split, int n)<a name="line.367"></a>
+<span class="sourceLineNo">368</span>      throws IllegalArgumentIOException {<a name="line.368"></a>
+<span class="sourceLineNo">369</span>    if (split == null || !(split instanceof TableSplit)) {<a name="line.369"></a>
+<span class="sourceLineNo">370</span>      throw new IllegalArgumentIOException(<a name="line.370"></a>
+<span class="sourceLineNo">371</span>          "InputSplit for CreateNSplitsPerRegion can not be null + "<a name="line.371"></a>
+<span class="sourceLineNo">372</span>              + "and should be instance of TableSplit");<a name="line.372"></a>
+<span class="sourceLineNo">373</span>    }<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    //if n &lt; 1, then still continue using n = 1<a name="line.374"></a>
+<span class="sourceLineNo">375</span>    n = n &lt; 1 ? 1 : n;<a name="line.375"></a>
+<span class="sourceLineNo">376</span>    List&lt;InputSplit&gt; res = new ArrayList&lt;&gt;(n);<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    if (n == 1) {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      res.add(split);<a name="line.378"></a>
+<span class="sourceLineNo">379</span>      return res;<a name="line.379"></a>
+<span class="sourceLineNo">380</span>    }<a name="line.380"></a>
+<span class="sourceLineNo">381</span><a name="line.381"></a>
+<span class="sourceLineNo">382</span>    // Collect Region related information<a name="line.382"></a>
+<span class="sourceLineNo">383</span>    TableSplit ts = (TableSplit) split;<a name="line.383"></a>
+<span class="sourceLineNo">384</span>    TableName tableName = ts.getTable();<a name="line.384"></a>
+<span class="sourceLineNo">385</span>    String regionLocation = ts.getRegionLocation();<a name="line.385"></a>
+<span class="sourceLineNo">386</span>    String encodedRegionName = ts.getEncodedRegionName();<a name="line.386"></a>
+<span class="sourceLineNo">387</span>    long regionSize = ts.getLength();<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    byte[] startRow = ts.getStartRow();<a name="line.388"></a>
+<span class="sourceLineNo">389</span>    byte[] endRow = ts.getEndRow();<a name="line.389"></a>
+<span class="sourceLineNo">390</span><a name="line.390"></a>
+<span class="sourceLineNo">391</span>    // For special case: startRow or endRow is empty<a name="line.391"></a>
+<span class="sourceLineNo">392</span>    if (startRow.length == 0 &amp;&amp; endRow.length == 0){<a name="line.392"></a>
+<span class="sourceLineNo">393</span>      startRow = new byte[1];<a name="line.393"></a>
+<span class="sourceLineNo">394</span>      endRow = new byte[1];<a name="line.394"></a>
+<span class="sourceLineNo">395</span>      startRow[0] = 0;<a name="line.395"></a>
+<span class="sourceLineNo">396</span>      endRow[0] = -1;<a name="line.396"></a>
+<span class="sourceLineNo">397</span>    }<a name="line.397"></a>
+<span class="sourceLineNo">398</span>    if (startRow.length == 0 &amp;&amp; endRow.length != 0){<a name="line.398"></a>
+<span class="sourceLineNo">399</span>      startRow = new byte[1];<a name="line.399"></a>
+<span class="sourceLineNo">400</span>      startRow[0] = 0;<a name="line.400"></a>
+<span class="sourceLineNo">401</span>    }<a name="line.401"></a>
+<span class="sourceLineNo">402</span>    if (startRow.length != 0 &amp;&amp; endRow.length == 0){<a name="line.402"></a>
+<span class="sourceLineNo">403</span>      endRow =new byte[startRow.length];<a name="line.403"></a>
+<span class="sourceLineNo">404</span>      for (int k = 0; k &lt; startRow.length; k++){<a name="line.404"></a>
+<span class="sourceLineNo">405</span>        endRow[k] = -1;<a name="line.405"></a>
+<span class="sourceLineNo">406</span>      }<a name="line.406"></a>
+<span class="sourceLineNo">407</span>    }<a name="line.407"></a>
+<span class="sourceLineNo">408</span><a name="line.408"></a>
+<span class="sourceLineNo">409</span>    // Split Region into n chunks evenly<a name="line.409"></a>
+<span class="sourceLineNo">410</span>    byte[][] splitKeys = Bytes.split(startRow, endRow, true, n-1);<a name="line.410"></a>
+<span class="sourceLineNo">411</span>    for (int i = 0; i &lt; splitKeys.length - 1; i++) {<a name="line.411"></a>
+<span class="sourceLineNo">412</span>      //notice that the regionSize parameter may be not very accurate<a name="line.412"></a>
+<span class="sourceLineNo">413</span>      TableSplit tsplit =<a name="line.413"></a>
+<span class="sourceLineNo">414</span>          new TableSplit(tableName, scan, splitKeys[i], splitKeys[i + 1], regionLocation,<a name="line.414"></a>
+<span class="sourceLineNo">415</span>              encodedRegionName, regionSize / n);<a name="line.415"></a>
+<span class="sourceLineNo">416</span>      res.add(tsplit);<a name="line.416"></a>
+<span class="sourceLineNo">417</span>    }<a name="line.417"></a>
+<span class="sourceLineNo">418</span>    return res;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>  }<a name="line.419"></a>
+<span class="sourceLineNo">420</span>  /**<a name="line.420"></a>
+<span class="sourceLineNo">421</span>   * Calculates the number of MapReduce input splits for the map tasks. The number of<a name="line.421"></a>
+<span class="sourceLineNo">422</span>   * MapReduce input splits depends on the average region size.<a name="line.422"></a>
+<span class="sourceLineNo">423</span>   * Make it 'public' for testing<a name="line.423"></a>
+<span class="sourceLineNo">424</span>   *<a name="line.424"></a>
+<span class="sourceLineNo">425</span>   * @param splits The list of input splits before balance.<a name="line.425"></a>
+<span class="sourceLineNo">426</span>   * @param maxAverageRegionSize max Average region size for one mapper<a name="line.426"></a>
+<span class="sourceLineNo">427</span>   * @return The list of input splits.<a name="line.427"></a>
+<span class="sourceLineNo">428</span>   * @throws IOException When creating the list of splits fails.<a name="line.428"></a>
+<span class="sourceLineNo">429</span>   * @see org.apache.hadoop.mapreduce.InputFormat#getSplits(<a name="line.429"></a>
+<span class="sourceLineNo">430</span>   *org.apache.hadoop.mapreduce.JobContext)<a name="line.430"></a>
+<span class="sourceLineNo">431</span>   */<a name="line.431"></a>
+<span class="sourceLineNo">432</span>  public List&lt;InputSplit&gt; calculateAutoBalancedSplits(List&lt;InputSplit&gt; splits, long maxAverageRegionSize)<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      throws IOException {<a name="line.433"></a>
+<span class="sourceLineNo">434</span>    if (splits.size() == 0) {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      return splits;<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    }<a name="line.436"></a>
+<span class="sourceLineNo">437</span>    List&lt;InputSplit&gt; resultList = new ArrayList&lt;&gt;();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>    long totalRegionSize = 0;<a name="line.438"></a>
+<span class="sourceLineNo">439</span>    for (int i = 0; i &lt; splits.size(); i++) {<a name="line.439"></a>
+<span class="sourceLineNo">440</span>      TableSplit ts = (TableSplit) splits.get(i);<a name="line.440"></a>
+<span class="sourceLineNo">441</span>      totalRegionSize += ts.getLength();<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    }<a name="line.442"></a>
+<span class="sourceLineNo">443</span>    long averageRegionSize = totalRegionSize / splits.size();<a name="line.443"></a>
+<span class="sourceLineNo">444</span>    // totalRegionSize might be overflow, and the averageRegionSize must be positive.<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    if (averageRegionSize &lt;= 0) {<a name="line.445"></a>
+<span class="sourceLineNo">446</span>      LOG.warn("The averageRegionSize is not positive: " + averageRegionSize + ", " +<a name="line.446"></a>
+<span class="sourceLineNo">447</span>          "set it to Long.MAX_VALUE " + splits.size());<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      averageRegionSize = Long.MAX_VALUE / splits.size();<a name="line.448"></a>
+<span class="sourceLineNo">449</span>    }<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    //if averageRegionSize is too big, change it to default as 1 GB,<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    if (averageRegionSize &gt; maxAverageRegionSize) {<a name="line.451"></a>
+<span class="sourceLineNo">452</span>      averageRegionSize = maxAverageRegionSize;<a name="line.452"></a>
+<span class="sourceLineNo">453</span>    }<a name="line.453"></a>
+<span class="sourceLineNo">454</span>    // if averageRegionSize is too small, we do not need to allocate more mappers for those 'large' region<a name="line.454"></a>
+<span class="sourceLineNo">455</span>    // set default as 16M = (default hdfs block size) / 4;<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    if (averageRegionSize &lt; 16 * 1048576) {<a name="line.456"></a>
+<span class="sourceLineNo">457</span>      return splits;<a name="line.457"></a>
+<span class="sourceLineNo">458</span>    }<a name="line.458"></a>
+<span class="sourceLineNo">459</span>    for (int i = 0; i &lt; splits.size(); i++) {<a name="line.459"></a>
+<span class="sourceLineNo">460</span>      TableSplit ts = (TableSplit) splits.get(i);<a name="line.460"></a>
+<span class="sourceLineNo">461</span>      TableName tableName = ts.getTable();<a name="line.461"></a>
+<span class="sourceLineNo">462</span>      String regionLocation = ts.getRegionLocation();<a name="line.462"></a>
+<span class="sourceLineNo">463</span>      String encodedRegionName = ts.getEncodedRegionName();<a name="line.463"></a>
+<span class="sourceLineNo">464</span>      long regionSize = ts.getLength();<a name="line.464"></a>
+<span class="sourceLineNo">465</span><a name="line.465"></a>
+<span class="sourceLineNo">466</span>      if (regionSize &gt;= averageRegionSize) {<a name="line.466"></a>
+<span class="sourceLineNo">467</span>        // make this region as multiple MapReduce input split.<a name="line.467"></a>
+<span class="sourceLineNo">468</span>        int n = (int) Math.round(Math.log(((double) regionSize) / ((double) averageRegionSize)) + 1.0);<a name="line.468"></a>
+<span class="sourceLineNo">469</span>        List&lt;InputSplit&gt; temp = createNInputSplitsUniform(ts, n);<a name="line.469"></a>
+<span class="sourceLineNo">470</span>        resultList.addAll(temp);<a name="line.470"></a>
+<span class="sourceLineNo">471</span>      } else {<a name="line.471"></a>
+<span class="sourceLineNo">472</span>        // if the total size of several small continuous regions less than the average region size,<a name="line.472"></a>
+<span class="sourceLineNo">473</span>        // combine them into one MapReduce input split.<a name="line.473"></a>
+<span class="sourceLineNo">474</span>        long totalSize = regionSize;<a name="line.474"></a>
+<span class="sourceLineNo">475</span>        byte[] splitStartKey = ts.getStartRow();<a name="line.475"></a>
+<span class="sourceLineNo">476</span>        byte[] splitEndKey = ts.getEndRow();<a name="line.476"></a>
+<span class="sourceLineNo">477</span>        int j = i + 1;<a name="line.477"></a>
+<span class="sourceLineNo">478</span>        while (j &lt; splits.size()) {<a name="line.478"></a>
+<span class="sourceLineNo">479</span>          TableSplit nextRegion = (TableSplit) splits.get(j);<a name="line.479"></a>
+<span class="sourceLineNo">480</span>          long nextRegionSize = nextRegion.getLength();<a name="line.480"></a>
+<span class="sourceLineNo">481</span>          if (totalSize + nextRegionSize &lt;= averageRegionSize) {<a name="line.481"></a>
+<span class="sourceLineNo">482</span>            totalSize = totalSize + nextRegionSize;<a name="line.482"></a>
+<span class="sourceLineNo">483</span>            splitEndKey = nextRegion.getEndRow();<a name="line.483"></a>
+<span class="sourceLineNo">484</span>            j++;<a name="line.484"></a>
+<span class="sourceLineNo">485</span>          } else {<a name="line.485"></a>
+<span class="sourceLineNo">486</span>            break;<a name="line.486"></a>
+<span class="sourceLineNo">487</span>          }<a name="line.487"></a>
+<span class="sourceLineNo">488</span>        }<a name="line.488"></a>
+<span class="sourceLineNo">489</span>        i = j - 1;<a name="line.489"></a>
+<span class="sourceLineNo">490</span>        TableSplit t = new TableSplit(tableName, scan, splitStartKey, splitEndKey, regionLocation,<a name="line.490"></a>
+<span class="sourceLineNo">491</span>            encodedRegionName, totalSize);<a name="line.491"></a>
+<span class="sourceLineNo">492</span>        resultList.add(t);<a name="line.492"></a>
+<span class="sourceLineNo">493</span>      }<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    }<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    return resultList;<a name="line.495"></a>
+<span class="sourceLineNo">496</span>  }<a name="line.496"></a>
+<span class="sourceLineNo">497</span><a name="line.497"></a>
+<span class="sourceLineNo">498</span>  String reverseDNS(InetAddress ipAddress) throws UnknownHostException {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>    String hostName = this.reverseDNSCacheMap.get(ipAddress);<a name="line.499"></a>
+<span class="sourceLineNo">500</span>    if (hostName == null) {<a name="line.500"></a>
+<span class="sourceLineNo">501</span>      String ipAddressString = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>      try {<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        ipAddressString = DNS.reverseDns(ipAddress, null);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      } catch (Exception e) {<a name="line.504"></a>
+<span class="sourceLineNo">505</span>        // We can use InetAddress in case the jndi failed to pull up the reverse DNS entry from the<a name="line.505"></a>
+<span class="sourceLineNo">506</span>        // name service. Also, in case of ipv6, we need to use the InetAddress since resolving<a name="line.506"></a>
+<span class="sourceLineNo">507</span>        // reverse DNS using jndi doesn't work well with ipv6 addresses.<a name="line.507"></a>
+<span class="sourceLineNo">508</span>        ipAddressString = InetAddress.getByName(ipAddress.getHostAddress()).getHostName();<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
+<span class="sourceLineNo">510</span>      if (ipAddressString == null) throw new UnknownHostException("No host found for " + ipAddress);<a name="line.510"></a>
+<span class="sourceLineNo">511</span>      hostName = Strings.domainNamePointerToHostName(ipAddressString);<a name="line.511"></a>
+<span class="sourceLineNo">512</span>      this.reverseDNSCacheMap.put(ipAddress, hostName);<a name="line.512"></a>
+<span class="sourceLineNo">513</span>    }<a name="line.513"></a>
+<span class="sourceLineNo">514</span>    return hostName;<a name="line.514"></a>
+<span class="sourceLineNo">515</span>  }<a name="line.515"></a>
+<span class="sourceLineNo">516</span><a name="line.516"></a>
+<span class="sourceLineNo">517</span>  /**<a name="line.517"></a>
+<span class="sourceLineNo">518</span>   * Test if the given region is to be included in the InputSplit while splitting<a name="line.518"></a>
+<span class="sourceLineNo">519</span>   * the regions of a table.<a name="line.519"></a>
+<span class="sourceLineNo">520</span>   * &lt;p&gt;<a name="line.520"></a>
+<span class="sourceLineNo">521</span>   * This optimization is effective when there is a specific reasoning to exclude an entire region from the M-R job,<a name="line.521"></a>
+<span class="sourceLineNo">522</span>   * (and hence, not contributing to the InputSplit), given the start and end keys of the same. &lt;br&gt;<a name="line.522"></a>
+<span class="sourceLineNo">523</span>   * Useful when we need to remember the last-processed top record and revisit the [last, current) interval for M-R processing,<a name="line.523"></a>
+<span class="sourceLineNo">524</span>   * continuously. In addition to reducing InputSplits, reduces the load on the region server as well, due to the ordering of the keys.<a name="line.524"></a>
 <span class="sourceLineNo">525</span>   * &lt;br&gt;<a name="line.525"></a>
-<span class="sourceLineNo">526</span>   * Note: It is possible that &lt;code&gt;endKey.length() == 0 &lt;/code&gt; , for the last (recent) region.<a name="line.526"></a>
-<span class="sourceLineNo">527</span>   * &lt;br&gt;<a name="line.527"></a>
-<span class="sourceLineNo">528</span>   * Override this method, if you want to bulk exclude regions altogether from M-R. By default, no region is excluded( i.e. all regions are included).<a name="line.528"></a>
-<span class="sourceLineNo">529</span>   *<a name="line.529"></a>
+<span class="sourceLineNo">526</span>   * &lt;br&gt;<a name="line.526"></a>
+<span class="sourceLineNo">527</span>   * Note: It is possible that &lt;code&gt;endKey.length() == 0 &lt;/code&gt; , for the last (recent) region.<a name="line.527"></a>
+<span class="sourceLineNo">528</span>   * &lt;br&gt;<a name="line.528"></a>
+<span class="sourceLineNo">529</span>   * Override this method, if you want to bulk exclude regions altogether from M-R. By default, no region is excluded( i.e. all regions are included).<a name="line.529"></a>
 <span class="sourceLineNo">530</span>   *<a name="line.530"></a>
-<span class="sourceLineNo">531</span>   * @param startKey Start key of the region<a name="line.531"></a>
-<span class="sourceLineNo">532</span>   * @param endKey End key of the region<a name="line.532"></a>
-<span class="sourceLineNo">533</span>   * @return true, if this region needs to be included as part of the input (default).<a name="line.533"></a>
-<span class="sourceLineNo">534</span>   *<a name="line.534"></a>
-<span class="sourceLineNo">535</span>   */<a name="line.535"></a>
-<span class="sourceLineNo">536</span>  protected boolean includeRegionInSplit(final byte[] startKey, final byte [] endKey) {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>    return true;<a name="line.537"></a>
-<span class="sourceLineNo">538</span>  }<a name="line.538"></a>
-<span class="sourceLineNo">539</span><a name="line.539"></a>
-<span class="sourceLineNo">540</span>  /**<a name="line.540"></a>
-<span class="sourceLineNo">541</span>   * Allows subclasses to get the {@link RegionLocator}.<a name="line.541"></a>
-<span class="sourceLineNo">542</span>   */<a name="line.542"></a>
-<span class="sourceLineNo">543</span>  protected RegionLocator getRegionLocator() {<a name="line.543"></a>
-<span class="sourceLineNo">544</span>    if (regionLocator == null) {<a name="line.544"></a>
-<span class="sourceLineNo">545</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    }<a name="line.546"></a>
-<span class="sourceLineNo">547</span>    return regionLocator;<a name="line.547"></a>
-<span class="sourceLineNo">548</span>  }<a name="line.548"></a>
-<span class="sourceLineNo">549</span><a name="line.549"></a>
-<span class="sourceLineNo">550</span>  /**<a name="line.550"></a>
-<span class="sourceLineNo">551</span>   * Allows subclasses to get the {@link Table}.<a name="line.551"></a>
-<span class="sourceLineNo">552</span>   */<a name="line.552"></a>
-<span class="sourceLineNo">553</span>  protected Table getTable() {<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    if (table == null) {<a name="line.554"></a>
-<span class="sourceLineNo">555</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.555"></a>
-<span class="sourceLineNo">556</span>    }<a name="line.556"></a>
-<span class="sourceLineNo">557</span>    return table;<a name="line.557"></a>
-<span class="sourceLineNo">558</span>  }<a name="line.558"></a>
-<span class="sourceLineNo">559</span><a name="line.559"></a>
-<span class="sourceLineNo">560</span>  /**<a name="line.560"></a>
-<span class="sourceLineNo">561</span>   * Allows subclasses to get the {@link Admin}.<a name="line.561"></a>
-<span class="sourceLineNo">562</span>   */<a name="line.562"></a>
-<span class="sourceLineNo">563</span>  protected Admin getAdmin() {<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    if (admin == null) {<a name="line.564"></a>
-<span class="sourceLineNo">565</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    }<a name="line.566"></a>
-<span class="sourceLineNo">567</span>    return admin;<a name="line.567"></a>
-<span class="sourceLineNo">568</span>  }<a name="line.568"></a>
-<span class="sourceLineNo">569</span><a name="line.569"></a>
-<span class="sourceLineNo">570</span>  /**<a name="line.570"></a>
-<span class="sourceLineNo">571</span>   * Allows subclasses to initialize the table information.<a name="line.571"></a>
-<span class="sourceLineNo">572</span>   *<a name="line.572"></a>
-<span class="sourceLineNo">573</span>   * @param connection  The Connection to the HBase cluster. MUST be unmanaged. We will close.<a name="line.573"></a>
-<span class="sourceLineNo">574</span>   * @param tableName  The {@link TableName} of the table to process.<a name="line.574"></a>
-<span class="sourceLineNo">575</span>   * @throws IOException<a name="line.575"></a>
-<span class="sourceLineNo">576</span>   */<a name="line.576"></a>
-<span class="sourceLineNo">577</span>  protected void initializeTable(Connection connection, TableName tableName) throws IOException {<a name="line.577"></a>
-<span class="sourceLineNo">578</span>    if (this.table != null || this.connection != null) {<a name="line.578"></a>
-<span class="sourceLineNo">579</span>      LOG.warn("initializeTable called multiple times. Overwriting connection and table " +<a name="line.579"></a>
-<span class="sourceLineNo">580</span>          "reference; TableInputFormatBase will not close these old references when done.");<a name="line.580"></a>
-<span class="sourceLineNo">581</span>    }<a name="line.581"></a>
-<span class="sourceLineNo">582</span>    this.table = connection.getTable(tableName);<a name="line.582"></a>
-<span class="sourceLineNo">583</span>    this.regionLocator = connection.getRegionLocator(tableName);<a name="line.583"></a>
-<span class="sourceLineNo">584</span>    this.admin = connection.getAdmin();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>    this.connection = connection;<a name="line.585"></a>
-<span class="sourceLineNo">586</span>  }<a name="line.586"></a>
-<span class="sourceLineNo">587</span><a name="line.587"></a>
-<span class="sourceLineNo">588</span>  /**<a name="line.588"></a>
-<span class="sourceLineNo">589</span>   * Gets the scan defining the actual details like columns etc.<a name="line.589"></a>
-<span class="sourceLineNo">590</span>   *<a name="line.590"></a>
-<span class="sourceLineNo">591</span>   * @return The internal scan instance.<a name="line.591"></a>
-<span class="sourceLineNo">592</span>   */<a name="line.592"></a>
-<span class="sourceLineNo">593</span>  public Scan getScan() {<a name="line.593"></a>
-<span class="sourceLineNo">594</span>    if (this.scan == null) this.scan = new Scan();<a name="line.594"></a>
-<span class="sourceLineNo">595</span>    return scan;<a name="line.595"></a>
-<span class="sourceLineNo">596</span>  }<a name="line.596"></a>
-<span class="sourceLineNo">597</span><a name="line.597"></a>
-<span class="sourceLineNo">598</span>  /**<a name="line.598"></a>
-<span class="sourceLineNo">599</span>   * Sets the scan defining the actual details like columns etc.<a name="line.599"></a>
-<span class="sourceLineNo">600</span>   *<a name="line.600"></a>
-<span class="sourceLineNo">601</span>   * @param scan  The scan to set.<a name="line.601"></a>
-<span class="sourceLineNo">602</span>   */<a name="line.602"></a>
-<span class="sourceLineNo">603</span>  public void setScan(Scan scan) {<a name="line.603"></a>
-<span class="sourceLineNo">604</span>    this.scan = scan;<a name="line.604"></a>
-<span class="sourceLineNo">605</span>  }<a name="line.605"></a>
-<span class="sourceLineNo">606</span><a name="line.606"></a>
-<span class="sourceLineNo">607</span>  /**<a name="line.607"></a>
-<span class="sourceLineNo">608</span>   * Allows subclasses to set the {@link TableRecordReader}.<a name="line.608"></a>
-<span class="sourceLineNo">609</span>   *<a name="line.609"></a>
-<span class="sourceLineNo">610</span>   * @param tableRecordReader A different {@link TableRecordReader}<a name="line.610"></a>
-<span class="sourceLineNo">611</span>   *   implementation.<a name="line.611"></a>
-<span class="sourceLineNo">612</span>   */<a name="line.612"></a>
-<span class="sourceLineNo">613</span>  protected void setTableRecordReader(TableRecordReader tableRecordReader) {<a name="line.613"></a>
-<span class="sourceLineNo">614</span>    this.tableRecordReader = tableRecordReader;<a name="line.614"></a>
-<span class="sourceLineNo">615</span>  }<a name="line.615"></a>
-<span class="sourceLineNo">616</span><a name="line.616"></a>
-<span class="sourceLineNo">617</span>  /**<a name="line.617"></a>
-<span class="sourceLineNo">618</span>   * Handle subclass specific set up.<a name="line.618"></a>
-<span class="sourceLineNo">619</span>   * Each of the entry points used by the MapReduce framework,<a name="line.619"></a>
-<span class="sourceLineNo">620</span>   * {@link #createRecordReader(InputSplit, TaskAttemptContext)} and {@link #getSplits(JobContext)},<a name="line.620"></a>
-<span class="sourceLineNo">621</span>   * will call {@link #initialize(JobContext)} as a convenient centralized location to handle<a name="line.621"></a>
-<span class="sourceLineNo">622</span>   * retrieving the necessary configuration information and calling<a name="line.622"></a>
-<span class="sourceLineNo">623</span>   * {@link #initializeTable(Connection, TableName)}.<a name="line.623"></a>
-<span class="sourceLineNo">624</span>   *<a name="line.624"></a>
-<span class="sourceLineNo">625</span>   * Subclasses should implement their initialize call such that it is safe to call multiple times.<a name="line.625"></a>
-<span class="sourceLineNo">626</span>   * The current TableInputFormatBase implementation relies on a non-null table reference to decide<a name="line.626"></a>
-<span class="sourceLineNo">627</span>   * if an initialize call is needed, but this behavior may change in the future. In particular,<a name="line.627"></a>
-<span class="sourceLineNo">628</span>   * it is critical that initializeTable not be called multiple times since this will leak<a name="line.628"></a>
-<span class="sourceLineNo">629</span>   * Connection instances.<a name="line.629"></a>
-<span class="sourceLineNo">630</span>   *<a name="line.630"></a>
-<span class="sourceLineNo">631</span>   */<a name="line.631"></a>
-<span class="sourceLineNo">632</span>  protected void initialize(JobContext context) throws IOException {<a name="line.632"></a>
-<span class="sourceLineNo">633</span>  }<a name="line.633"></a>
-<span class="sourceLineNo">634</span><a name="line.634"></a>
-<span class="sourceLineNo">635</span>  /**<a name="line.635"></a>
-<span class="sourceLineNo">636</span>   * Close the Table and related objects that were initialized via<a name="line.636"></a>
-<span class="sourceLineNo">637</span>   * {@link #initializeTable(Connection, TableName)}.<a name="line.637"></a>
-<span class="sourceLineNo">638</span>   *<a name="line.638"></a>
-<span class="sourceLineNo">639</span>   * @throws IOException<a name="line.639"></a>
-<span class="sourceLineNo">640</span>   */<a name="line.640"></a>
-<span class="sourceLineNo">641</span>  protected void closeTable() throws IOException {<a name="line.641"></a>
-<span class="sourceLineNo">642</span>    close(admin, table, regionLocator, connection);<a name="line.642"></a>
-<span class="sourceLineNo">643</span>    admin = null;<a name="line.643"></a>
-<span class="sourceLineNo">644</span>    table = null;<a name="line.644"></a>
-<span class="sourceLineNo">645</span>    regionLocator = null;<a name="line.645"></a>
-<span class="sourceLineNo">646</span>    connection = null;<a name="line.646"></a>
-<span class="sourceLineNo">647</span>  }<a name="line.647"></a>
-<span class="sourceLineNo">648</span><a name="line.648"></a>
-<span class="sourceLineNo">649</span>  private void close(Closeable... closables) throws IOException {<a name="line.649"></a>
-<span class="sourceLineNo">650</span>    for (Closeable c : closables) {<a name="line.650"></a>
-<span class="sourceLineNo">651</span>      if(c != null) { c.close(); }<a name="line.651"></a>
-<span class="sourceLineNo">652</span>    }<a name="line.652"></a>
-<span class="sourceLineNo">653</span>  }<a name="line.653"></a>
-<span class="sourceLineNo">654</span><a name="line.654"></a>
-<span class="sourceLineNo">655</span>}<a name="line.655"></a>
+<span class="sourceLineNo">531</span>   *<a name="line.531"></a>
+<span class="sourceLineNo">532</span>   * @param startKey Start key of the region<a name="line.532"></a>
+<span class="sourceLineNo">533</span>   * @param endKey End key of the region<a name="line.533"></a>
+<span class="sourceLineNo">534</span>   * @return true, if this region needs to be included as part of the input (default).<a name="line.534"></a>
+<span class="sourceLineNo">535</span>   *<a name="line.535"></a>
+<span class="sourceLineNo">536</span>   */<a name="line.536"></a>
+<span class="sourceLineNo">537</span>  protected boolean includeRegionInSplit(final byte[] startKey, final byte [] endKey) {<a name="line.537"></a>
+<span class="sourceLineNo">538</span>    return true;<a name="line.538"></a>
+<span class="sourceLineNo">539</span>  }<a name="line.539"></a>
+<span class="sourceLineNo">540</span><a name="line.540"></a>
+<span class="sourceLineNo">541</span>  /**<a name="line.541"></a>
+<span class="sourceLineNo">542</span>   * Allows subclasses to get the {@link RegionLocator}.<a name="line.542"></a>
+<span class="sourceLineNo">543</span>   */<a name="line.543"></a>
+<span class="sourceLineNo">544</span>  protected RegionLocator getRegionLocator() {<a name="line.544"></a>
+<span class="sourceLineNo">545</span>    if (regionLocator == null) {<a name="line.545"></a>
+<span class="sourceLineNo">546</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.546"></a>
+<span class="sourceLineNo">547</span>    }<a name="line.547"></a>
+<span class="sourceLineNo">548</span>    return regionLocator;<a name="line.548"></a>
+<span class="sourceLineNo">549</span>  }<a name="line.549"></a>
+<span class="sourceLineNo">550</span><a name="line.550"></a>
+<span class="sourceLineNo">551</span>  /**<a name="line.551"></a>
+<span class="sourceLineNo">552</span>   * Allows subclasses to get the {@link Table}.<a name="line.552"></a>
+<span class="sourceLineNo">553</span>   */<a name="line.553"></a>
+<span class="sourceLineNo">554</span>  protected Table getTable() {<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    if (table == null) {<a name="line.555"></a>
+<span class="sourceLineNo">556</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    }<a name="line.557"></a>
+<span class="sourceLineNo">558</span>    return table;<a name="line.558"></a>
+<span class="sourceLineNo">559</span>  }<a name="line.559"></a>
+<span class="sourceLineNo">560</span><a name="line.560"></a>
+<span class="sourceLineNo">561</span>  /**<a name="line.561"></a>
+<span class="sourceLineNo">562</span>   * Allows subclasses to get the {@link Admin}.<a name="line.562"></a>
+<span class="sourceLineNo">563</span>   */<a name="line.563"></a>
+<span class="sourceLineNo">564</span>  protected Admin getAdmin() {<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    if (admin == null) {<a name="line.565"></a>
+<span class="sourceLineNo">566</span>      throw new IllegalStateException(NOT_INITIALIZED);<a name="line.566"></a>
+<span class="sourceLineNo">567</span>    }<a name="line.567"></a>
+<span class="sourceLineNo">568</span>    return admin;<a name="line.568"></a>
+<span class="sourceLineNo">569</span>  }<a name="line.569"></a>
+<span class="sourceLineNo">570</span><a name="line.570"></a>
+<span class="sourceLineNo">571</span>  /**<a name="line.571"></a>
+<span class="sourceLineNo">572</span>   * Allows subclasses to initialize the table information.<a name="line.572"></a>
+<span class="sourceLineNo">573</span>   *<a name="line.573"></a>
+<span class="sourceLineNo">574</span>   * @param connection  The Connection to the HBase cluster. MUST be unmanaged. We will close.<a name="line.574"></a>
+<span class="sourceLineNo">575</span>   * @param tableName  The {@link TableName} of the table to process.<a name="line.575"></a>
+<span class="sourceLineNo">576</span>   * @throws IOException<a name="line.576"></a>
+<span class="sourceLineNo">577</span>   */<a name="line.577"></a>
+<span class="sourceLineNo">578</span>  protected void initializeTable(Connection connection, TableName tableName) throws IOException {<a name="line.578"></a>
+<span class="sourceLineNo">579</span>    if (this.table != null || this.connection != null) {<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      LOG.warn("initializeTable called multiple times. Overwriting connection and table " +<a name="line.580"></a>
+<span class="sourceLineNo">581</span>          "reference; TableInputFormatBase will not close these old references when done.");<a name="line.581"></a>
+<span class="sourceLineNo">582</span>    }<a name="line.582"></a>
+<span class="sourceLineNo">583</span>    this.table = connection.getTable(tableName);<a name="line.583"></a>
+<span class="sourceLineNo">584</span>    this.regionLocator = connection.getRegionLocator(tableName);<a name="line.584"></a>
+<span class="sourceLineNo">585</span>    this.admin = connection.getAdmin();<a name="line.585"></a>
+<span class="sourceLineNo">586</span>    this.connection = connection;<a name="line.586"></a>
+<span class="sourceLineNo">587</span>  }<a name="line.587"></a>
+<span class="sourceLineNo">588</span><a name="line.588"></a>
+<span class="sourceLineNo">589</span>  /**<a name="line.589"></a>
+<span class="sourceLineNo">590</span>   * Gets the scan defining the actual details like columns etc.<a name="line.590"></a>
+<span class="sourceLineNo">591</span>   *<a name="line.591"></a>
+<span class="sourceLineNo">592</span>   * @return The internal scan instance.<a name="line.592"></a>
+<span class="sourceLineNo">593</span>   */<a name="line.593"></a>
+<span class="sourceLineNo">594</span>  public Scan getScan() {<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    if (this.scan == null) this.scan = new Scan();<a name="line.595"></a>
+<span class="sourceLineNo">596</span>    return scan;<a name="line.596"></a>
+<span class="sourceLineNo">597</span>  }<a name="line.597"></a>
+<span class="sourceLineNo">598</span><a name="line.598"></a>
+<span class="sourceLineNo">599</span>  /**<a name="line.599"></a>
+<span class="sourceLineNo">600</span>   * Sets the scan defining the actual details like columns etc.<a name="line.600"></a>
+<span class="sourceLineNo">601</span>   *<a name="line.601"></a>
+<span class="sourceLineNo">602</span>   * @param scan  The scan to set.<a name="line.602"></a>
+<span class="sourceLineNo">603</span>   */<a name="line.603"></a>
+<span class="sourceLineNo">604</span>  public void setScan(Scan scan) {<a name="line.604"></a>
+<span class="sourceLineNo">605</span>    this.scan = scan;<a name="line.605"></a>
+<span class="sourceLineNo">606</span>  }<a name="line.606"></a>
+<span class="sourceLineNo">607</span><a name="line.607"></a>
+<span class="sourceLineNo">608</span>  /**<a name="line.608"></a>
+<span class="sourceLineNo">609</span>   * Allows subclasses to set the {@link TableRecordReader}.<a name="line.609"></a>
+<span class="sourceLineNo">610</span>   *<a name="line.610"></a>
+<span class="sourceLineNo">611</span>   * @param tableRecordReader A different {@link TableRecordReader}<a name="line.611"></a>
+<span class="sourceLineNo">612</span>   *   implementation.<a name="line.612"></a>
+<span class="sourceLineNo">613</span>   */<a name="line.613"></a>
+<span class="sourceLineNo">614</span>  protected void setTableRecordReader(TableRecordReader tableRecordReader) {<a name="line.614"></a>
+<span class="sourceLineNo">615</span>    this.tableRecordReader = tableRecordReader;<a name="line.615"></a>
+<span class="sourceLineNo">616</span>  }<a name="line.616"></a>
+<span class="sourceLineNo">617</span><a name="line.617"></a>
+<span class="sourceLineNo">618</span>  /**<a name="line.618"></a>
+<span class="sourceLineNo">619</span>   * Handle subclass specific set up.<a name="line.619"></a>
+<span class="sourceLineNo">620</span>   * Each of the entry points used by the MapReduce framework,<a name="line.620"></a>
+<span class="sourceLineNo">621</span>   * {@link #createRecordReader(InputSplit, TaskAttemptContext)} and {@link #getSplits(JobContext)},<a name="line.621"></a>
+<span class="sourceLineNo">622</span>   * will call {@link #initialize(JobContext)} as a convenient centralized location to handle<a name="line.622"></a>
+<span class="sourceLineNo">623</span>   * retrieving the necessary configuration information and calling<a name="line.623"></a>
+<span class="sourceLineNo">624</span>   * {@link #initializeTable(Connection, TableName)}.<a name="line.624"></a>
+<span class="sourceLineNo">625</span>   *<a name="line.625"></a>
+<span class="sourceLineNo">626</span>   * Subclasses should implement their initialize call such that it is safe to call multiple times.<a name="line.626"></a>
+<span class="sourceLineNo">627</span>   * The current TableInputFormatBase implementation relies on a non-null table reference to decide<a name="line.627"></a>
+<span class="sourceLineNo">628</span>   * if an initialize call is needed, but this behavior may change in the future. In particular,<a name="line.628"></a>
+<span class="sourceLineNo">629</span>   * it is critical that initializeTable not be called multiple times since this will leak<a name="line.629"></a>
+<span class="sourceLineNo">630</span>   * Connection instances.<a name="line.630"></a>
+<span class="sourceLineNo">631</span>   *<a name="line.631"></a>
+<span class="sourceLineNo">632</span>   */<a name="line.632"></a>
+<span class="sourceLineNo">633</span>  protected void initialize(JobContext context) throws IOException {<a name="line.633"></a>
+<span class="sourceLineNo">634</span>  }<a name="line.634"></a>
+<span class="sourceLineNo">635</span><a name="line.635"></a>
+<span class="sourceLineNo">636</span>  /**<a name="line.636"></a>
+<span class="sourceLineNo">637</span>   * Close the Table and related objects that were initialized via<a name="line.637"></a>
+<span class="sourceLineNo">638</span>   * {@link #initializeTable(Connection, TableName)}.<a name="line.638"></a>
+<span class="sourceLineNo">639</span>   *<a name="line.639"></a>
+<span class="sourceLineNo">640</span>   * @throws IOException<a name="line.640"></a>
+<span class="sourceLineNo">641</span>   */<a name="line.641"></a>
+<span class="sourceLineNo">642</span>  protected void closeTable() throws IOException {<a name="line.642"></a>
+<span class="sourceLineNo">643</span>    close(admin, table, regionLocator, connection);<a name="line.643"></a>
+<span class="sourceLineNo">644</span>    admin = null;<a name="line.644"></a>
+<span class="sourceLineNo">645</span>    table = null;<a name="line.645"></a>
+<span class="sourceLineNo">646</span>    regionLocator = null;<a name="line.646"></a>
+<span class="sourceLineNo">647</span>    connection = null;<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  }<a name="line.648"></a>
+<span class="sourceLineNo">649</span><a name="line.649"></a>
+<span class="sourceLineNo">650</span>  private void close(Closeable... closables) throws IOException {<a name="line.650"></a>
+<span class="sourceLineNo">651</span>    for (Closeable c : closables) {<a name="line.651"></a>
+<span class="sourceLineNo">652</span>      if(c != null) { c.close(); }<a name="line.652"></a>
+<span class="sourceLineNo">653</span>    }<a name="line.653"></a>
+<span class="sourceLineNo">654</span>  }<a name="line.654"></a>
+<span class="sourceLineNo">655</span><a name="line.655"></a>
+<span class="sourceLineNo">656</span>}<a name="line.656"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/2b3f2bee/book.html
----------------------------------------------------------------------
diff --git a/book.html b/book.html
index ff26207..70fd530 100644
--- a/book.html
+++ b/book.html
@@ -3638,7 +3638,7 @@ Some configurations would only appear in source code; the only way to identify t
 <dd>
 <div class="paragraph">
 <div class="title">Description</div>
-<p>The HFile format version to use for new files. Version 3 adds support for tags in hfiles (See <a href="http://hbase.apache.org/book.html#hbase.tags" class="bare">http://hbase.apache.org/book.html#hbase.tags</a>). Distributed Log Replay requires that tags are enabled. Also see the configuration 'hbase.replication.rpc.codec'.</p>
+<p>The HFile format version to use for new files. Version 3 adds support for tags in hfiles (See <a href="http://hbase.apache.org/book.html#hbase.tags" class="bare">http://hbase.apache.org/book.html#hbase.tags</a>). Also see the configuration 'hbase.replication.rpc.codec'.</p>
 </div>
 <div class="paragraph">
 <div class="title">Default</div>
@@ -4883,7 +4883,7 @@ Some configurations would only appear in source code; the only way to identify t
 <dd>
 <div class="paragraph">
 <div class="title">Description</div>
-<p>By default, in replication we can not make sure the order of operations in slave cluster is same as the order in master. If set REPLICATION_SCOPE to 2, we will push edits by the order of written. This configure is to set how long (in ms) we will wait before next checking if a log can not push right now because there are some logs written before it have not been pushed. A larger waiting will decrease the number of queries on hbase:meta but will enlarge the delay of replication. This feature relies on zk-less assignment, and conflicts with distributed log replay. So users must set hbase.assignment.usezk and hbase.master.distributed.log.replay to false to support it.</p>
+<p>By default, in replication we can not make sure the order of operations in slave cluster is same as the order in master. If set REPLICATION_SCOPE to 2, we will push edits by the order of written. This configure is to set how long (in ms) we will wait before next checking if a log can not push right now because there are some logs written before it have not been pushed. A larger waiting will decrease the number of queries on hbase:meta but will enlarge the delay of replication. This feature relies on zk-less assignment, so users must set hbase.assignment.usezk to false to support it.</p>
 </div>
 <div class="paragraph">
 <div class="title">Default</div>
@@ -6421,10 +6421,6 @@ ports.</p>
 <div class="title">If you have your own customer filters.</div>
 <p>See the release notes on the issue <a href="https://issues.apache.org/jira/browse/HBASE-12068">HBASE-12068 [Branch-1] Avoid need to always do KeyValueUtil#ensureKeyValue for Filter transformCell</a>; be sure to follow the recommendations therein.</p>
 </div>
-<div id="dlr" class="paragraph">
-<div class="title">Distributed Log Replay</div>
-<p><a href="#distributed.log.replay">Distributed Log Replay</a> is off by default in HBase 1.0.0. Enabling it can make a big difference improving HBase MTTR. Enable this feature if you are doing a clean stop/start when you are upgrading. You cannot rolling upgrade to this feature (caveat if you are running on a version of HBase in excess of HBase 0.98.4&#8201;&#8212;&#8201;see <a href="https://issues.apache.org/jira/browse/HBASE-12577">HBASE-12577 Disable distributed log replay by default</a> for more).</p>
-</div>
 <div class="paragraph">
 <div class="title">Mismatch Of <code>hbase.client.scanner.max.result.size</code> Between Client and Server</div>
 <p>If either the client or server version is lower than 0.98.11/1.0.0 and the server
@@ -14834,41 +14830,6 @@ If none are found, it throws an exception so that the log splitting can be retri
 </li>
 </ol>
 </div>
-<div class="sect5">
-<h6 id="distributed.log.replay"><a class="anchor" href="#distributed.log.replay"></a>Distributed Log Replay</h6>
-<div class="paragraph">
-<p>After a RegionServer fails, its failed regions are assigned to another RegionServer, which are marked as "recovering" in ZooKeeper.
-A split log worker directly replays edits from the WAL of the failed RegionServer to the regions at its new location.
-When a region is in "recovering" state, it can accept writes but no reads (including Append and Increment), region splits or merges.</p>
-</div>
-<div class="paragraph">
-<p>Distributed Log Replay extends the <a href="#distributed.log.splitting">Enabling or Disabling Distributed Log Splitting</a> framework.
-It works by directly replaying WAL edits to another RegionServer instead of creating <em>recovered.edits</em> files.
-It provides the following advantages over distributed log splitting alone:</p>
-</div>
-<div class="ulist">
-<ul>
-<li>
-<p>It eliminates the overhead of writing and reading a large number of <em>recovered.edits</em> files.
-It is not unusual for thousands of <em>recovered.edits</em> files to be created and written concurrently during a RegionServer recovery.
-Many small random writes can degrade overall system performance.</p>
-</li>
-<li>
-<p>It allows writes even when a region is in recovering state.
-It only takes seconds for a recovering region to accept writes again.</p>
-</li>
-</ul>
-</div>
-<div class="paragraph">
-<div class="title">Enabling Distributed Log Replay</div>
-<p>To enable distributed log replay, set <code>hbase.master.distributed.log.replay</code> to <code>true</code>.
-This will be the default for HBase 0.99 (<a href="https://issues.apache.org/jira/browse/HBASE-10888">HBASE-10888</a>).</p>
-</div>
-<div class="paragraph">
-<p>You must also enable HFile version 3 (which is the default HFile format starting in HBase 0.99.
-See <a href="https://issues.apache.org/jira/browse/HBASE-10855">HBASE-10855</a>). Distributed log replay is unsafe for rolling upgrades.</p>
-</div>
-</div>
 </div>
 </div>
 <div class="sect3">
@@ -35484,7 +35445,7 @@ The server will return cellblocks compressed using this same compressor as long
 <div id="footer">
 <div id="footer-text">
 Version 3.0.0-SNAPSHOT<br>
-Last updated 2017-11-07 14:29:34 UTC
+Last updated 2017-11-09 14:29:37 UTC
 </div>
 </div>
 </body>


Mime
View raw message