hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [05/48] hbase-site git commit: Published site at 4bfeccb87a94cfe232ea8fc9a6f40ff5b8d3b1c5.
Date Fri, 18 Dec 2015 16:42:38 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d917c66a/xref/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
----------------------------------------------------------------------
diff --git a/xref/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html b/xref/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
index f8ae7d0..ced1bbd 100644
--- a/xref/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
+++ b/xref/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html
@@ -435,654 +435,655 @@
 <a class="jxr_linenumber" name="425" href="#425">425</a> <em class="jxr_javadoccomment">   * @param hfilesDir directory containing list of hfiles to be loaded into the table</em>
 <a class="jxr_linenumber" name="426" href="#426">426</a> <em class="jxr_javadoccomment">   * @param table table to which hfiles should be loaded</em>
 <a class="jxr_linenumber" name="427" href="#427">427</a> <em class="jxr_javadoccomment">   * @param queue queue which needs to be loaded into the table</em>
-<a class="jxr_linenumber" name="428" href="#428">428</a> <em class="jxr_javadoccomment">   * @throws IOException If any I/O or network error occurred</em>
-<a class="jxr_linenumber" name="429" href="#429">429</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="430" href="#430">430</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> prepareHFileQueue(Path hfofDir, <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, Deque&lt;LoadQueueItem&gt; queue,
-<a class="jxr_linenumber" name="431" href="#431">431</a>       <strong class="jxr_keyword">boolean</strong> validateHFile) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="432" href="#432">432</a>     discoverLoadQueue(queue, hfofDir, validateHFile);
-<a class="jxr_linenumber" name="433" href="#433">433</a>     validateFamiliesInHFiles(table, queue);
-<a class="jxr_linenumber" name="434" href="#434">434</a>   }
-<a class="jxr_linenumber" name="435" href="#435">435</a> 
-<a class="jxr_linenumber" name="436" href="#436">436</a>   <em class="jxr_comment">// Initialize a thread pool</em>
-<a class="jxr_linenumber" name="437" href="#437">437</a>   <strong class="jxr_keyword">private</strong> ExecutorService createExecutorService() {
-<a class="jxr_linenumber" name="438" href="#438">438</a>     ThreadFactoryBuilder builder = <strong class="jxr_keyword">new</strong> ThreadFactoryBuilder();
-<a class="jxr_linenumber" name="439" href="#439">439</a>     builder.setNameFormat(<span class="jxr_string">"LoadIncrementalHFiles-%1$d"</span>);
-<a class="jxr_linenumber" name="440" href="#440">440</a>     ExecutorService pool = <strong class="jxr_keyword">new</strong> ThreadPoolExecutor(nrThreads, nrThreads, 60, TimeUnit.SECONDS,
-<a class="jxr_linenumber" name="441" href="#441">441</a>         <strong class="jxr_keyword">new</strong> LinkedBlockingQueue&lt;Runnable&gt;(), builder.build());
-<a class="jxr_linenumber" name="442" href="#442">442</a>     ((ThreadPoolExecutor) pool).allowCoreThreadTimeOut(<strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="443" href="#443">443</a>     <strong class="jxr_keyword">return</strong> pool;
-<a class="jxr_linenumber" name="444" href="#444">444</a>   }
-<a class="jxr_linenumber" name="445" href="#445">445</a> 
-<a class="jxr_linenumber" name="446" href="#446">446</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="447" href="#447">447</a> <em class="jxr_javadoccomment">   * Checks whether there is any invalid family name in HFiles to be bulk loaded.</em>
-<a class="jxr_linenumber" name="448" href="#448">448</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="449" href="#449">449</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> validateFamiliesInHFiles(<a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, Deque&lt;LoadQueueItem&gt; queue)
-<a class="jxr_linenumber" name="450" href="#450">450</a>       <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="451" href="#451">451</a>     Collection&lt;HColumnDescriptor&gt; families = table.getTableDescriptor().getFamilies();
-<a class="jxr_linenumber" name="452" href="#452">452</a>     List&lt;String&gt; familyNames = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;(families.size());
-<a class="jxr_linenumber" name="453" href="#453">453</a>     <strong class="jxr_keyword">for</strong> (HColumnDescriptor family : families) {
-<a class="jxr_linenumber" name="454" href="#454">454</a>       familyNames.add(family.getNameAsString());
-<a class="jxr_linenumber" name="455" href="#455">455</a>     }
-<a class="jxr_linenumber" name="456" href="#456">456</a>     List&lt;String&gt; unmatchedFamilies = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;();
-<a class="jxr_linenumber" name="457" href="#457">457</a>     Iterator&lt;LoadQueueItem&gt; queueIter = queue.iterator();
-<a class="jxr_linenumber" name="458" href="#458">458</a>     <strong class="jxr_keyword">while</strong> (queueIter.hasNext()) {
-<a class="jxr_linenumber" name="459" href="#459">459</a>       <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a> lqi = queueIter.next();
-<a class="jxr_linenumber" name="460" href="#460">460</a>       String familyNameInHFile = Bytes.toString(lqi.family);
-<a class="jxr_linenumber" name="461" href="#461">461</a>       <strong class="jxr_keyword">if</strong> (!familyNames.contains(familyNameInHFile)) {
-<a class="jxr_linenumber" name="462" href="#462">462</a>         unmatchedFamilies.add(familyNameInHFile);
-<a class="jxr_linenumber" name="463" href="#463">463</a>       }
-<a class="jxr_linenumber" name="464" href="#464">464</a>     }
-<a class="jxr_linenumber" name="465" href="#465">465</a>     <strong class="jxr_keyword">if</strong> (unmatchedFamilies.size() &gt; 0) {
-<a class="jxr_linenumber" name="466" href="#466">466</a>       String msg =
-<a class="jxr_linenumber" name="467" href="#467">467</a>           <span class="jxr_string">"Unmatched family names found: unmatched family names in HFiles to be bulkloaded: "</span>
-<a class="jxr_linenumber" name="468" href="#468">468</a>               + unmatchedFamilies + <span class="jxr_string">"; valid family names of table "</span> + table.getName() + <span class="jxr_string">" are: "</span>
-<a class="jxr_linenumber" name="469" href="#469">469</a>               + familyNames;
-<a class="jxr_linenumber" name="470" href="#470">470</a>       LOG.error(msg);
-<a class="jxr_linenumber" name="471" href="#471">471</a>       <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(msg);
-<a class="jxr_linenumber" name="472" href="#472">472</a>     }
-<a class="jxr_linenumber" name="473" href="#473">473</a>   }
-<a class="jxr_linenumber" name="474" href="#474">474</a> 
-<a class="jxr_linenumber" name="475" href="#475">475</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="476" href="#476">476</a> <em class="jxr_javadoccomment">   * Used by the replication sink to load the hfiles from the source cluster. It does the following,</em>
-<a class="jxr_linenumber" name="477" href="#477">477</a> <em class="jxr_javadoccomment">   * 1. {@link LoadIncrementalHFiles#groupOrSplitPhase(Table, ExecutorService, Deque, Pair)} 2.</em>
-<a class="jxr_linenumber" name="478" href="#478">478</a> <em class="jxr_javadoccomment">   * {@link</em>
-<a class="jxr_linenumber" name="479" href="#479">479</a> <em class="jxr_javadoccomment">   * LoadIncrementalHFiles#bulkLoadPhase(Table, Connection, ExecutorService, Deque, Multimap)}</em>
-<a class="jxr_linenumber" name="480" href="#480">480</a> <em class="jxr_javadoccomment">   * @param table Table to which these hfiles should be loaded to</em>
-<a class="jxr_linenumber" name="481" href="#481">481</a> <em class="jxr_javadoccomment">   * @param conn Connection to use</em>
-<a class="jxr_linenumber" name="482" href="#482">482</a> <em class="jxr_javadoccomment">   * @param queue {@link LoadQueueItem} has hfiles yet to be loaded</em>
-<a class="jxr_linenumber" name="483" href="#483">483</a> <em class="jxr_javadoccomment">   * @param startEndKeys starting and ending row keys of the region</em>
-<a class="jxr_linenumber" name="484" href="#484">484</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="485" href="#485">485</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> loadHFileQueue(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Connection.html">Connection</a> conn, Deque&lt;LoadQueueItem&gt; queue,
-<a class="jxr_linenumber" name="486" href="#486">486</a>       Pair&lt;byte[][], byte[][]&gt; startEndKeys) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="487" href="#487">487</a>     ExecutorService pool = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="488" href="#488">488</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="489" href="#489">489</a>       pool = createExecutorService();
-<a class="jxr_linenumber" name="490" href="#490">490</a>       Multimap&lt;ByteBuffer, LoadQueueItem&gt; regionGroups =
-<a class="jxr_linenumber" name="491" href="#491">491</a>           groupOrSplitPhase(table, pool, queue, startEndKeys);
-<a class="jxr_linenumber" name="492" href="#492">492</a>       bulkLoadPhase(table, conn, pool, queue, regionGroups);
-<a class="jxr_linenumber" name="493" href="#493">493</a>     } <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="494" href="#494">494</a>       <strong class="jxr_keyword">if</strong> (pool != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="495" href="#495">495</a>         pool.shutdown();
-<a class="jxr_linenumber" name="496" href="#496">496</a>       }
-<a class="jxr_linenumber" name="497" href="#497">497</a>     }
-<a class="jxr_linenumber" name="498" href="#498">498</a>   }
-<a class="jxr_linenumber" name="499" href="#499">499</a> 
-<a class="jxr_linenumber" name="500" href="#500">500</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="501" href="#501">501</a> <em class="jxr_javadoccomment">   * This takes the LQI's grouped by likely regions and attempts to bulk load</em>
-<a class="jxr_linenumber" name="502" href="#502">502</a> <em class="jxr_javadoccomment">   * them.  Any failures are re-queued for another pass with the</em>
-<a class="jxr_linenumber" name="503" href="#503">503</a> <em class="jxr_javadoccomment">   * groupOrSplitPhase.</em>
-<a class="jxr_linenumber" name="504" href="#504">504</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="505" href="#505">505</a>   <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> bulkLoadPhase(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Connection.html">Connection</a> conn,
-<a class="jxr_linenumber" name="506" href="#506">506</a>       ExecutorService pool, Deque&lt;LoadQueueItem&gt; queue,
-<a class="jxr_linenumber" name="507" href="#507">507</a>       <strong class="jxr_keyword">final</strong> Multimap&lt;ByteBuffer, LoadQueueItem&gt; regionGroups) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="508" href="#508">508</a>     <em class="jxr_comment">// atomically bulk load the groups.</em>
-<a class="jxr_linenumber" name="509" href="#509">509</a>     Set&lt;Future&lt;List&lt;LoadQueueItem&gt;&gt;&gt; loadingFutures = <strong class="jxr_keyword">new</strong> HashSet&lt;Future&lt;List&lt;LoadQueueItem&gt;&gt;&gt;();
-<a class="jxr_linenumber" name="510" href="#510">510</a>     <strong class="jxr_keyword">for</strong> (Entry&lt;ByteBuffer, ? <strong class="jxr_keyword">extends</strong> Collection&lt;LoadQueueItem&gt;&gt; e: regionGroups.asMap().entrySet()){
-<a class="jxr_linenumber" name="511" href="#511">511</a>       <strong class="jxr_keyword">final</strong> byte[] first = e.getKey().array();
-<a class="jxr_linenumber" name="512" href="#512">512</a>       <strong class="jxr_keyword">final</strong> Collection&lt;LoadQueueItem&gt; lqis =  e.getValue();
-<a class="jxr_linenumber" name="513" href="#513">513</a> 
-<a class="jxr_linenumber" name="514" href="#514">514</a>       <strong class="jxr_keyword">final</strong> Callable&lt;List&lt;LoadQueueItem&gt;&gt; call = <strong class="jxr_keyword">new</strong> Callable&lt;List&lt;LoadQueueItem&gt;&gt;() {
-<a class="jxr_linenumber" name="515" href="#515">515</a>         @Override
-<a class="jxr_linenumber" name="516" href="#516">516</a>         <strong class="jxr_keyword">public</strong> List&lt;LoadQueueItem&gt; call() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="517" href="#517">517</a>           List&lt;LoadQueueItem&gt; toRetry =
-<a class="jxr_linenumber" name="518" href="#518">518</a>               tryAtomicRegionLoad(conn, table.getName(), first, lqis);
-<a class="jxr_linenumber" name="519" href="#519">519</a>           <strong class="jxr_keyword">return</strong> toRetry;
-<a class="jxr_linenumber" name="520" href="#520">520</a>         }
-<a class="jxr_linenumber" name="521" href="#521">521</a>       };
-<a class="jxr_linenumber" name="522" href="#522">522</a>       loadingFutures.add(pool.submit(call));
-<a class="jxr_linenumber" name="523" href="#523">523</a>     }
-<a class="jxr_linenumber" name="524" href="#524">524</a> 
-<a class="jxr_linenumber" name="525" href="#525">525</a>     <em class="jxr_comment">// get all the results.</em>
-<a class="jxr_linenumber" name="526" href="#526">526</a>     <strong class="jxr_keyword">for</strong> (Future&lt;List&lt;LoadQueueItem&gt;&gt; future : loadingFutures) {
-<a class="jxr_linenumber" name="527" href="#527">527</a>       <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="528" href="#528">528</a>         List&lt;LoadQueueItem&gt; toRetry = future.get();
-<a class="jxr_linenumber" name="529" href="#529">529</a> 
-<a class="jxr_linenumber" name="530" href="#530">530</a>         <em class="jxr_comment">// LQIs that are requeued to be regrouped.</em>
-<a class="jxr_linenumber" name="531" href="#531">531</a>         queue.addAll(toRetry);
-<a class="jxr_linenumber" name="532" href="#532">532</a> 
-<a class="jxr_linenumber" name="533" href="#533">533</a>       } <strong class="jxr_keyword">catch</strong> (ExecutionException e1) {
-<a class="jxr_linenumber" name="534" href="#534">534</a>         Throwable t = e1.getCause();
-<a class="jxr_linenumber" name="535" href="#535">535</a>         <strong class="jxr_keyword">if</strong> (t instanceof IOException) {
-<a class="jxr_linenumber" name="536" href="#536">536</a>           <em class="jxr_comment">// At this point something unrecoverable has happened.</em>
-<a class="jxr_linenumber" name="537" href="#537">537</a>           <em class="jxr_comment">// TODO Implement bulk load recovery</em>
-<a class="jxr_linenumber" name="538" href="#538">538</a>           <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<span class="jxr_string">"BulkLoad encountered an unrecoverable problem"</span>, t);
-<a class="jxr_linenumber" name="539" href="#539">539</a>         }
-<a class="jxr_linenumber" name="540" href="#540">540</a>         LOG.error(<span class="jxr_string">"Unexpected execution exception during bulk load"</span>, e1);
-<a class="jxr_linenumber" name="541" href="#541">541</a>         <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(t);
-<a class="jxr_linenumber" name="542" href="#542">542</a>       } <strong class="jxr_keyword">catch</strong> (InterruptedException e1) {
-<a class="jxr_linenumber" name="543" href="#543">543</a>         LOG.error(<span class="jxr_string">"Unexpected interrupted exception during bulk load"</span>, e1);
-<a class="jxr_linenumber" name="544" href="#544">544</a>         <strong class="jxr_keyword">throw</strong> (InterruptedIOException)<strong class="jxr_keyword">new</strong> InterruptedIOException().initCause(e1);
-<a class="jxr_linenumber" name="545" href="#545">545</a>       }
-<a class="jxr_linenumber" name="546" href="#546">546</a>     }
-<a class="jxr_linenumber" name="547" href="#547">547</a>   }
-<a class="jxr_linenumber" name="548" href="#548">548</a> 
-<a class="jxr_linenumber" name="549" href="#549">549</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> checkHFilesCountPerRegionPerFamily(
-<a class="jxr_linenumber" name="550" href="#550">550</a>       <strong class="jxr_keyword">final</strong> Multimap&lt;ByteBuffer, LoadQueueItem&gt; regionGroups) {
-<a class="jxr_linenumber" name="551" href="#551">551</a>     <strong class="jxr_keyword">for</strong> (Entry&lt;ByteBuffer,
-<a class="jxr_linenumber" name="552" href="#552">552</a>         ? <strong class="jxr_keyword">extends</strong> Collection&lt;LoadQueueItem&gt;&gt; e: regionGroups.asMap().entrySet()) {
-<a class="jxr_linenumber" name="553" href="#553">553</a>       <strong class="jxr_keyword">final</strong> Collection&lt;LoadQueueItem&gt; lqis =  e.getValue();
-<a class="jxr_linenumber" name="554" href="#554">554</a>       HashMap&lt;byte[], MutableInt&gt; filesMap = <strong class="jxr_keyword">new</strong> HashMap&lt;byte[], MutableInt&gt;();
-<a class="jxr_linenumber" name="555" href="#555">555</a>       <strong class="jxr_keyword">for</strong> (LoadQueueItem lqi: lqis) {
-<a class="jxr_linenumber" name="556" href="#556">556</a>         MutableInt count = filesMap.get(lqi.family);
-<a class="jxr_linenumber" name="557" href="#557">557</a>         <strong class="jxr_keyword">if</strong> (count == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="558" href="#558">558</a>           count = <strong class="jxr_keyword">new</strong> MutableInt();
-<a class="jxr_linenumber" name="559" href="#559">559</a>           filesMap.put(lqi.family, count);
-<a class="jxr_linenumber" name="560" href="#560">560</a>         }
-<a class="jxr_linenumber" name="561" href="#561">561</a>         count.increment();
-<a class="jxr_linenumber" name="562" href="#562">562</a>         <strong class="jxr_keyword">if</strong> (count.intValue() &gt; maxFilesPerRegionPerFamily) {
-<a class="jxr_linenumber" name="563" href="#563">563</a>           LOG.error(<span class="jxr_string">"Trying to load more than "</span> + maxFilesPerRegionPerFamily
-<a class="jxr_linenumber" name="564" href="#564">564</a>             + <span class="jxr_string">" hfiles to family "</span> + Bytes.toStringBinary(lqi.family)
-<a class="jxr_linenumber" name="565" href="#565">565</a>             + <span class="jxr_string">" of region with start key "</span>
-<a class="jxr_linenumber" name="566" href="#566">566</a>             + Bytes.toStringBinary(e.getKey()));
-<a class="jxr_linenumber" name="567" href="#567">567</a>           <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="568" href="#568">568</a>         }
-<a class="jxr_linenumber" name="569" href="#569">569</a>       }
-<a class="jxr_linenumber" name="570" href="#570">570</a>     }
-<a class="jxr_linenumber" name="571" href="#571">571</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="572" href="#572">572</a>   }
-<a class="jxr_linenumber" name="573" href="#573">573</a> 
-<a class="jxr_linenumber" name="574" href="#574">574</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="575" href="#575">575</a> <em class="jxr_javadoccomment">   * @return A map that groups LQI by likely bulk load region targets.</em>
-<a class="jxr_linenumber" name="576" href="#576">576</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="577" href="#577">577</a>   <strong class="jxr_keyword">private</strong> Multimap&lt;ByteBuffer, LoadQueueItem&gt; groupOrSplitPhase(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table,
-<a class="jxr_linenumber" name="578" href="#578">578</a>       ExecutorService pool, Deque&lt;LoadQueueItem&gt; queue,
-<a class="jxr_linenumber" name="579" href="#579">579</a>       <strong class="jxr_keyword">final</strong> Pair&lt;byte[][], byte[][]&gt; startEndKeys) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="580" href="#580">580</a>     <em class="jxr_comment">// &lt;region start key, LQI&gt; need synchronized only within this scope of this</em>
-<a class="jxr_linenumber" name="581" href="#581">581</a>     <em class="jxr_comment">// phase because of the puts that happen in futures.</em>
-<a class="jxr_linenumber" name="582" href="#582">582</a>     Multimap&lt;ByteBuffer, LoadQueueItem&gt; rgs = HashMultimap.create();
-<a class="jxr_linenumber" name="583" href="#583">583</a>     <strong class="jxr_keyword">final</strong> Multimap&lt;ByteBuffer, LoadQueueItem&gt; regionGroups = Multimaps.synchronizedMultimap(rgs);
-<a class="jxr_linenumber" name="584" href="#584">584</a> 
-<a class="jxr_linenumber" name="585" href="#585">585</a>     <em class="jxr_comment">// drain LQIs and figure out bulk load groups</em>
-<a class="jxr_linenumber" name="586" href="#586">586</a>     Set&lt;Future&lt;List&lt;LoadQueueItem&gt;&gt;&gt; splittingFutures = <strong class="jxr_keyword">new</strong> HashSet&lt;Future&lt;List&lt;LoadQueueItem&gt;&gt;&gt;();
-<a class="jxr_linenumber" name="587" href="#587">587</a>     <strong class="jxr_keyword">while</strong> (!queue.isEmpty()) {
-<a class="jxr_linenumber" name="588" href="#588">588</a>       <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a> item = queue.remove();
-<a class="jxr_linenumber" name="589" href="#589">589</a> 
-<a class="jxr_linenumber" name="590" href="#590">590</a>       <strong class="jxr_keyword">final</strong> Callable&lt;List&lt;LoadQueueItem&gt;&gt; call = <strong class="jxr_keyword">new</strong> Callable&lt;List&lt;LoadQueueItem&gt;&gt;() {
-<a class="jxr_linenumber" name="591" href="#591">591</a>         @Override
-<a class="jxr_linenumber" name="592" href="#592">592</a>         <strong class="jxr_keyword">public</strong> List&lt;LoadQueueItem&gt; call() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="593" href="#593">593</a>           List&lt;LoadQueueItem&gt; splits = groupOrSplit(regionGroups, item, table, startEndKeys);
-<a class="jxr_linenumber" name="594" href="#594">594</a>           <strong class="jxr_keyword">return</strong> splits;
-<a class="jxr_linenumber" name="595" href="#595">595</a>         }
-<a class="jxr_linenumber" name="596" href="#596">596</a>       };
-<a class="jxr_linenumber" name="597" href="#597">597</a>       splittingFutures.add(pool.submit(call));
-<a class="jxr_linenumber" name="598" href="#598">598</a>     }
-<a class="jxr_linenumber" name="599" href="#599">599</a>     <em class="jxr_comment">// get all the results.  All grouping and splitting must finish before</em>
-<a class="jxr_linenumber" name="600" href="#600">600</a>     <em class="jxr_comment">// we can attempt the atomic loads.</em>
-<a class="jxr_linenumber" name="601" href="#601">601</a>     <strong class="jxr_keyword">for</strong> (Future&lt;List&lt;LoadQueueItem&gt;&gt; lqis : splittingFutures) {
-<a class="jxr_linenumber" name="602" href="#602">602</a>       <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="603" href="#603">603</a>         List&lt;LoadQueueItem&gt; splits = lqis.get();
-<a class="jxr_linenumber" name="604" href="#604">604</a>         <strong class="jxr_keyword">if</strong> (splits != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="605" href="#605">605</a>           queue.addAll(splits);
-<a class="jxr_linenumber" name="606" href="#606">606</a>         }
-<a class="jxr_linenumber" name="607" href="#607">607</a>       } <strong class="jxr_keyword">catch</strong> (ExecutionException e1) {
-<a class="jxr_linenumber" name="608" href="#608">608</a>         Throwable t = e1.getCause();
-<a class="jxr_linenumber" name="609" href="#609">609</a>         <strong class="jxr_keyword">if</strong> (t instanceof IOException) {
-<a class="jxr_linenumber" name="610" href="#610">610</a>           LOG.error(<span class="jxr_string">"IOException during splitting"</span>, e1);
-<a class="jxr_linenumber" name="611" href="#611">611</a>           <strong class="jxr_keyword">throw</strong> (IOException)t; <em class="jxr_comment">// would have been thrown if not parallelized,</em>
-<a class="jxr_linenumber" name="612" href="#612">612</a>         }
-<a class="jxr_linenumber" name="613" href="#613">613</a>         LOG.error(<span class="jxr_string">"Unexpected execution exception during splitting"</span>, e1);
-<a class="jxr_linenumber" name="614" href="#614">614</a>         <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(t);
-<a class="jxr_linenumber" name="615" href="#615">615</a>       } <strong class="jxr_keyword">catch</strong> (InterruptedException e1) {
-<a class="jxr_linenumber" name="616" href="#616">616</a>         LOG.error(<span class="jxr_string">"Unexpected interrupted exception during splitting"</span>, e1);
-<a class="jxr_linenumber" name="617" href="#617">617</a>         <strong class="jxr_keyword">throw</strong> (InterruptedIOException)<strong class="jxr_keyword">new</strong> InterruptedIOException().initCause(e1);
-<a class="jxr_linenumber" name="618" href="#618">618</a>       }
-<a class="jxr_linenumber" name="619" href="#619">619</a>     }
-<a class="jxr_linenumber" name="620" href="#620">620</a>     <strong class="jxr_keyword">return</strong> regionGroups;
-<a class="jxr_linenumber" name="621" href="#621">621</a>   }
-<a class="jxr_linenumber" name="622" href="#622">622</a> 
-<a class="jxr_linenumber" name="623" href="#623">623</a>   <em class="jxr_comment">// unique file name for the table</em>
-<a class="jxr_linenumber" name="624" href="#624">624</a>   <strong class="jxr_keyword">private</strong> String getUniqueName() {
-<a class="jxr_linenumber" name="625" href="#625">625</a>     <strong class="jxr_keyword">return</strong> UUID.randomUUID().toString().replaceAll(<span class="jxr_string">"-"</span>, <span class="jxr_string">""</span>);
-<a class="jxr_linenumber" name="626" href="#626">626</a>   }
-<a class="jxr_linenumber" name="627" href="#627">627</a> 
-<a class="jxr_linenumber" name="628" href="#628">628</a>   <strong class="jxr_keyword">protected</strong> List&lt;LoadQueueItem&gt; splitStoreFile(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a> item,
-<a class="jxr_linenumber" name="629" href="#629">629</a>       <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, byte[] startKey,
-<a class="jxr_linenumber" name="630" href="#630">630</a>       byte[] splitKey) <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="631" href="#631">631</a>     <strong class="jxr_keyword">final</strong> Path hfilePath = item.hfilePath;
-<a class="jxr_linenumber" name="632" href="#632">632</a> 
-<a class="jxr_linenumber" name="633" href="#633">633</a>     <em class="jxr_comment">// We use a '_' prefix which is ignored when walking directory trees</em>
-<a class="jxr_linenumber" name="634" href="#634">634</a>     <em class="jxr_comment">// above.</em>
-<a class="jxr_linenumber" name="635" href="#635">635</a>     <strong class="jxr_keyword">final</strong> String TMP_DIR = <span class="jxr_string">"_tmp"</span>;
-<a class="jxr_linenumber" name="636" href="#636">636</a>     Path tmpDir = item.hfilePath.getParent();
-<a class="jxr_linenumber" name="637" href="#637">637</a>     <strong class="jxr_keyword">if</strong> (!tmpDir.getName().equals(TMP_DIR)) {
-<a class="jxr_linenumber" name="638" href="#638">638</a>       tmpDir = <strong class="jxr_keyword">new</strong> Path(tmpDir, TMP_DIR);
-<a class="jxr_linenumber" name="639" href="#639">639</a>     }
-<a class="jxr_linenumber" name="640" href="#640">640</a> 
-<a class="jxr_linenumber" name="641" href="#641">641</a>     LOG.info(<span class="jxr_string">"HFile at "</span> + hfilePath + <span class="jxr_string">" no longer fits inside a single "</span> +
-<a class="jxr_linenumber" name="642" href="#642">642</a>     <span class="jxr_string">"region. Splitting..."</span>);
-<a class="jxr_linenumber" name="643" href="#643">643</a> 
-<a class="jxr_linenumber" name="644" href="#644">644</a>     String uniqueName = getUniqueName();
-<a class="jxr_linenumber" name="645" href="#645">645</a>     <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> familyDesc = table.getTableDescriptor().getFamily(item.family);
-<a class="jxr_linenumber" name="646" href="#646">646</a> 
-<a class="jxr_linenumber" name="647" href="#647">647</a>     Path botOut = <strong class="jxr_keyword">new</strong> Path(tmpDir, uniqueName + <span class="jxr_string">".bottom"</span>);
-<a class="jxr_linenumber" name="648" href="#648">648</a>     Path topOut = <strong class="jxr_keyword">new</strong> Path(tmpDir, uniqueName + <span class="jxr_string">".top"</span>);
-<a class="jxr_linenumber" name="649" href="#649">649</a>     splitStoreFile(getConf(), hfilePath, familyDesc, splitKey, botOut, topOut);
-<a class="jxr_linenumber" name="650" href="#650">650</a> 
-<a class="jxr_linenumber" name="651" href="#651">651</a>     FileSystem fs = tmpDir.getFileSystem(getConf());
-<a class="jxr_linenumber" name="652" href="#652">652</a>     fs.setPermission(tmpDir, FsPermission.valueOf(<span class="jxr_string">"-rwxrwxrwx"</span>));
-<a class="jxr_linenumber" name="653" href="#653">653</a>     fs.setPermission(botOut, FsPermission.valueOf(<span class="jxr_string">"-rwxrwxrwx"</span>));
-<a class="jxr_linenumber" name="654" href="#654">654</a>     fs.setPermission(topOut, FsPermission.valueOf(<span class="jxr_string">"-rwxrwxrwx"</span>));
-<a class="jxr_linenumber" name="655" href="#655">655</a> 
-<a class="jxr_linenumber" name="656" href="#656">656</a>     <em class="jxr_comment">// Add these back at the *front* of the queue, so there's a lower</em>
-<a class="jxr_linenumber" name="657" href="#657">657</a>     <em class="jxr_comment">// chance that the region will just split again before we get there.</em>
-<a class="jxr_linenumber" name="658" href="#658">658</a>     List&lt;LoadQueueItem&gt; lqis = <strong class="jxr_keyword">new</strong> ArrayList&lt;LoadQueueItem&gt;(2);
-<a class="jxr_linenumber" name="659" href="#659">659</a>     lqis.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a>(item.family, botOut));
-<a class="jxr_linenumber" name="660" href="#660">660</a>     lqis.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a>(item.family, topOut));
-<a class="jxr_linenumber" name="661" href="#661">661</a> 
-<a class="jxr_linenumber" name="662" href="#662">662</a>     LOG.info(<span class="jxr_string">"Successfully split into new HFiles "</span> + botOut + <span class="jxr_string">" and "</span> + topOut);
-<a class="jxr_linenumber" name="663" href="#663">663</a>     <strong class="jxr_keyword">return</strong> lqis;
-<a class="jxr_linenumber" name="664" href="#664">664</a>   }
-<a class="jxr_linenumber" name="665" href="#665">665</a> 
-<a class="jxr_linenumber" name="666" href="#666">666</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="667" href="#667">667</a> <em class="jxr_javadoccomment">   * Attempt to assign the given load queue item into its target region group.</em>
-<a class="jxr_linenumber" name="668" href="#668">668</a> <em class="jxr_javadoccomment">   * If the hfile boundary no longer fits into a region, physically splits</em>
-<a class="jxr_linenumber" name="669" href="#669">669</a> <em class="jxr_javadoccomment">   * the hfile such that the new bottom half will fit and returns the list of</em>
-<a class="jxr_linenumber" name="670" href="#670">670</a> <em class="jxr_javadoccomment">   * LQI's corresponding to the resultant hfiles.</em>
-<a class="jxr_linenumber" name="671" href="#671">671</a> <em class="jxr_javadoccomment">   *</em>
-<a class="jxr_linenumber" name="672" href="#672">672</a> <em class="jxr_javadoccomment">   * protected for testing</em>
-<a class="jxr_linenumber" name="673" href="#673">673</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
-<a class="jxr_linenumber" name="674" href="#674">674</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="675" href="#675">675</a>   <strong class="jxr_keyword">protected</strong> List&lt;LoadQueueItem&gt; groupOrSplit(Multimap&lt;ByteBuffer, LoadQueueItem&gt; regionGroups,
-<a class="jxr_linenumber" name="676" href="#676">676</a>       <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadQueueItem</a> item, <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table,
-<a class="jxr_linenumber" name="677" href="#677">677</a>       <strong class="jxr_keyword">final</strong> Pair&lt;byte[][], byte[][]&gt; startEndKeys)
-<a class="jxr_linenumber" name="678" href="#678">678</a>       <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="679" href="#679">679</a>     <strong class="jxr_keyword">final</strong> Path hfilePath = item.hfilePath;
-<a class="jxr_linenumber" name="680" href="#680">680</a>     <em class="jxr_comment">// fs is the source filesystem</em>
-<a class="jxr_linenumber" name="681" href="#681">681</a>     <strong class="jxr_keyword">if</strong> (fs == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="682" href="#682">682</a>       fs = hfilePath.getFileSystem(getConf());
-<a class="jxr_linenumber" name="683" href="#683">683</a>     }
-<a class="jxr_linenumber" name="684" href="#684">684</a>     HFile.Reader hfr = HFile.createReader(fs, hfilePath,
-<a class="jxr_linenumber" name="685" href="#685">685</a>         <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/io/hfile/CacheConfig.html">CacheConfig</a>(getConf()), getConf());
-<a class="jxr_linenumber" name="686" href="#686">686</a>     <strong class="jxr_keyword">final</strong> byte[] first, last;
-<a class="jxr_linenumber" name="687" href="#687">687</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="688" href="#688">688</a>       hfr.loadFileInfo();
-<a class="jxr_linenumber" name="689" href="#689">689</a>       first = hfr.getFirstRowKey();
-<a class="jxr_linenumber" name="690" href="#690">690</a>       last = hfr.getLastRowKey();
-<a class="jxr_linenumber" name="691" href="#691">691</a>     }  <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="692" href="#692">692</a>       hfr.close();
-<a class="jxr_linenumber" name="693" href="#693">693</a>     }
-<a class="jxr_linenumber" name="694" href="#694">694</a> 
-<a class="jxr_linenumber" name="695" href="#695">695</a>     LOG.info(<span class="jxr_string">"Trying to load hfile="</span> + hfilePath +
-<a class="jxr_linenumber" name="696" href="#696">696</a>         <span class="jxr_string">" first="</span> + Bytes.toStringBinary(first) +
-<a class="jxr_linenumber" name="697" href="#697">697</a>         <span class="jxr_string">" last="</span>  + Bytes.toStringBinary(last));
-<a class="jxr_linenumber" name="698" href="#698">698</a>     <strong class="jxr_keyword">if</strong> (first == <strong class="jxr_keyword">null</strong> || last == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="699" href="#699">699</a>       assert first == <strong class="jxr_keyword">null</strong> &amp;&amp; last == <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="700" href="#700">700</a>       <em class="jxr_comment">// TODO what if this is due to a bad HFile?</em>
-<a class="jxr_linenumber" name="701" href="#701">701</a>       LOG.info(<span class="jxr_string">"hfile "</span> + hfilePath + <span class="jxr_string">" has no entries, skipping"</span>);
-<a class="jxr_linenumber" name="702" href="#702">702</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="703" href="#703">703</a>     }
-<a class="jxr_linenumber" name="704" href="#704">704</a>     <strong class="jxr_keyword">if</strong> (Bytes.compareTo(first, last) &gt; 0) {
-<a class="jxr_linenumber" name="705" href="#705">705</a>       <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(
-<a class="jxr_linenumber" name="706" href="#706">706</a>       <span class="jxr_string">"Invalid range: "</span> + Bytes.toStringBinary(first) +
-<a class="jxr_linenumber" name="707" href="#707">707</a>       <span class="jxr_string">" &gt; "</span> + Bytes.toStringBinary(last));
-<a class="jxr_linenumber" name="708" href="#708">708</a>     }
-<a class="jxr_linenumber" name="709" href="#709">709</a>     <strong class="jxr_keyword">int</strong> idx = Arrays.binarySearch(startEndKeys.getFirst(), first,
-<a class="jxr_linenumber" name="710" href="#710">710</a>         Bytes.BYTES_COMPARATOR);
-<a class="jxr_linenumber" name="711" href="#711">711</a>     <strong class="jxr_keyword">if</strong> (idx &lt; 0) {
-<a class="jxr_linenumber" name="712" href="#712">712</a>       <em class="jxr_comment">// not on boundary, returns -(insertion index).  Calculate region it</em>
-<a class="jxr_linenumber" name="713" href="#713">713</a>       <em class="jxr_comment">// would be in.</em>
-<a class="jxr_linenumber" name="714" href="#714">714</a>       idx = -(idx + 1) - 1;
-<a class="jxr_linenumber" name="715" href="#715">715</a>     }
-<a class="jxr_linenumber" name="716" href="#716">716</a>     <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> indexForCallable = idx;
-<a class="jxr_linenumber" name="717" href="#717">717</a> 
-<a class="jxr_linenumber" name="718" href="#718">718</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="719" href="#719">719</a> <em class="jxr_javadoccomment">     * we can consider there is a region hole in following conditions. 1) if idx &lt; 0,then first</em>
-<a class="jxr_linenumber" name="720" href="#720">720</a> <em class="jxr_javadoccomment">     * region info is lost. 2) if the endkey of a region is not equal to the startkey of the next</em>
-<a class="jxr_linenumber" name="721" href="#721">721</a> <em class="jxr_javadoccomment">     * region. 3) if the endkey of the last region is not empty.</em>
-<a class="jxr_linenumber" name="722" href="#722">722</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="723" href="#723">723</a>     <strong class="jxr_keyword">if</strong> (indexForCallable &lt; 0) {
-<a class="jxr_linenumber" name="724" href="#724">724</a>       <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<span class="jxr_string">"The first region info for table "</span>
-<a class="jxr_linenumber" name="725" href="#725">725</a>           + table.getName()
-<a class="jxr_linenumber" name="726" href="#726">726</a>           + <span class="jxr_string">" cann't be found in hbase:meta.Please use hbck tool to fix it first."</span>);
-<a class="jxr_linenumber" name="727" href="#727">727</a>     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> ((indexForCallable == startEndKeys.getFirst().length - 1)
-<a class="jxr_linenumber" name="728" href="#728">728</a>         &amp;&amp; !Bytes.equals(startEndKeys.getSecond()[indexForCallable], HConstants.EMPTY_BYTE_ARRAY)) {
-<a class="jxr_linenumber" name="729" href="#729">729</a>       <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<span class="jxr_string">"The last region info for table "</span>
-<a class="jxr_linenumber" name="730" href="#730">730</a>           + table.getName()
-<a class="jxr_linenumber" name="731" href="#731">731</a>           + <span class="jxr_string">" cann't be found in hbase:meta.Please use hbck tool to fix it first."</span>);
-<a class="jxr_linenumber" name="732" href="#732">732</a>     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (indexForCallable + 1 &lt; startEndKeys.getFirst().length
-<a class="jxr_linenumber" name="733" href="#733">733</a>         &amp;&amp; !(Bytes.compareTo(startEndKeys.getSecond()[indexForCallable],
-<a class="jxr_linenumber" name="734" href="#734">734</a>           startEndKeys.getFirst()[indexForCallable + 1]) == 0)) {
-<a class="jxr_linenumber" name="735" href="#735">735</a>       <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IOException(<span class="jxr_string">"The endkey of one region for table "</span>
-<a class="jxr_linenumber" name="736" href="#736">736</a>           + table.getName()
-<a class="jxr_linenumber" name="737" href="#737">737</a>           + <span class="jxr_string">" is not equal to the startkey of the next region in hbase:meta."</span>
-<a class="jxr_linenumber" name="738" href="#738">738</a>           + <span class="jxr_string">"Please use hbck tool to fix it first."</span>);
-<a class="jxr_linenumber" name="739" href="#739">739</a>     }
-<a class="jxr_linenumber" name="740" href="#740">740</a> 
-<a class="jxr_linenumber" name="741" href="#741">741</a>     <strong class="jxr_keyword">boolean</strong> lastKeyInRange =
-<a class="jxr_linenumber" name="742" href="#742">742</a>       Bytes.compareTo(last, startEndKeys.getSecond()[idx]) &lt; 0 ||
-<a class="jxr_linenumber" name="743" href="#743">743</a>       Bytes.equals(startEndKeys.getSecond()[idx], HConstants.EMPTY_BYTE_ARRAY);
-<a class="jxr_linenumber" name="744" href="#744">744</a>     <strong class="jxr_keyword">if</strong> (!lastKeyInRange) {
-<a class="jxr_linenumber" name="745" href="#745">745</a>       List&lt;LoadQueueItem&gt; lqis = splitStoreFile(item, table,
-<a class="jxr_linenumber" name="746" href="#746">746</a>           startEndKeys.getFirst()[indexForCallable],
-<a class="jxr_linenumber" name="747" href="#747">747</a>           startEndKeys.getSecond()[indexForCallable]);
-<a class="jxr_linenumber" name="748" href="#748">748</a>       <strong class="jxr_keyword">return</strong> lqis;
-<a class="jxr_linenumber" name="749" href="#749">749</a>     }
-<a class="jxr_linenumber" name="750" href="#750">750</a> 
-<a class="jxr_linenumber" name="751" href="#751">751</a>     <em class="jxr_comment">// group regions.</em>
-<a class="jxr_linenumber" name="752" href="#752">752</a>     regionGroups.put(ByteBuffer.wrap(startEndKeys.getFirst()[idx]), item);
-<a class="jxr_linenumber" name="753" href="#753">753</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="754" href="#754">754</a>   }
-<a class="jxr_linenumber" name="755" href="#755">755</a> 
-<a class="jxr_linenumber" name="756" href="#756">756</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="757" href="#757">757</a> <em class="jxr_javadoccomment">   * Attempts to do an atomic load of many hfiles into a region.  If it fails,</em>
-<a class="jxr_linenumber" name="758" href="#758">758</a> <em class="jxr_javadoccomment">   * it returns a list of hfiles that need to be retried.  If it is successful</em>
-<a class="jxr_linenumber" name="759" href="#759">759</a> <em class="jxr_javadoccomment">   * it will return an empty list.</em>
-<a class="jxr_linenumber" name="760" href="#760">760</a> <em class="jxr_javadoccomment">   *</em>
-<a class="jxr_linenumber" name="761" href="#761">761</a> <em class="jxr_javadoccomment">   * NOTE: To maintain row atomicity guarantees, region server callable should</em>
-<a class="jxr_linenumber" name="762" href="#762">762</a> <em class="jxr_javadoccomment">   * succeed atomically and fails atomically.</em>
-<a class="jxr_linenumber" name="763" href="#763">763</a> <em class="jxr_javadoccomment">   *</em>
-<a class="jxr_linenumber" name="764" href="#764">764</a> <em class="jxr_javadoccomment">   * Protected for testing.</em>
-<a class="jxr_linenumber" name="765" href="#765">765</a> <em class="jxr_javadoccomment">   *</em>
-<a class="jxr_linenumber" name="766" href="#766">766</a> <em class="jxr_javadoccomment">   * @return empty list if success, list of items to retry on recoverable</em>
-<a class="jxr_linenumber" name="767" href="#767">767</a> <em class="jxr_javadoccomment">   * failure</em>
-<a class="jxr_linenumber" name="768" href="#768">768</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="769" href="#769">769</a>   <strong class="jxr_keyword">protected</strong> List&lt;LoadQueueItem&gt; tryAtomicRegionLoad(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/client/Connection.html">Connection</a> conn,
-<a class="jxr_linenumber" name="770" href="#770">770</a>       <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName, <strong class="jxr_keyword">final</strong> byte[] first, <strong class="jxr_keyword">final</strong> Collection&lt;LoadQueueItem&gt; lqis)
-<a class="jxr_linenumber" name="771" href="#771">771</a>   <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="772" href="#772">772</a>     <strong class="jxr_keyword">final</strong> List&lt;Pair&lt;byte[], String&gt;&gt; famPaths =
-<a class="jxr_linenumber" name="773" href="#773">773</a>       <strong class="jxr_keyword">new</strong> ArrayList&lt;Pair&lt;byte[], String&gt;&gt;(lqis.size());
-<a class="jxr_linenumber" name="774" href="#774">774</a>     <strong class="jxr_keyword">for</strong> (LoadQueueItem lqi : lqis) {
-<a class="jxr_linenumber" name="775" href="#775">775</a>       famPaths.add(Pair.newPair(lqi.family, lqi.hfilePath.toString()));
-<a class="jxr_linenumber" name="776" href="#776">776</a>     }
-<a class="jxr_linenumber" name="777" href="#777">777</a> 
-<a class="jxr_linenumber" name="778" href="#778">778</a>     <strong class="jxr_keyword">final</strong> RegionServerCallable&lt;Boolean&gt; svrCallable =
-<a class="jxr_linenumber" name="779" href="#779">779</a>         <strong class="jxr_keyword">new</strong> RegionServerCallable&lt;Boolean&gt;(conn, tableName, first) {
-<a class="jxr_linenumber" name="780" href="#780">780</a>       @Override
-<a class="jxr_linenumber" name="781" href="#781">781</a>       <strong class="jxr_keyword">public</strong> Boolean call(<strong class="jxr_keyword">int</strong> callTimeout) <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="782" href="#782">782</a>         <a href="../../../../../org/apache/hadoop/hbase/client/coprocessor/SecureBulkLoadClient.html">SecureBulkLoadClient</a> secureClient = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="783" href="#783">783</a>         <strong class="jxr_keyword">boolean</strong> success = false;
-<a class="jxr_linenumber" name="784" href="#784">784</a> 
-<a class="jxr_linenumber" name="785" href="#785">785</a>         <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="786" href="#786">786</a>           LOG.debug(<span class="jxr_string">"Going to connect to server "</span> + getLocation() + <span class="jxr_string">" for row "</span>
-<a class="jxr_linenumber" name="787" href="#787">787</a>               + Bytes.toStringBinary(getRow()) + <span class="jxr_string">" with hfile group "</span> + famPaths);
-<a class="jxr_linenumber" name="788" href="#788">788</a>           byte[] regionName = getLocation().getRegionInfo().getRegionName();
-<a class="jxr_linenumber" name="789" href="#789">789</a>           <strong class="jxr_keyword">if</strong> (!isSecureBulkLoadEndpointAvailable()) {
-<a class="jxr_linenumber" name="790" href="#790">790</a>             success = ProtobufUtil.bulkLoadHFile(getStub(), famPaths, regionName, assignSeqIds);
-<a class="jxr_linenumber" name="791" href="#791">791</a>           } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="792" href="#792">792</a>             <strong class="jxr_keyword">try</strong> (Table table = conn.getTable(getTableName())) {
-<a class="jxr_linenumber" name="793" href="#793">793</a>               secureClient = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/client/coprocessor/SecureBulkLoadClient.html">SecureBulkLoadClient</a>(table);
-<a class="jxr_linenumber" name="794" href="#794">794</a>               success = secureClient.bulkLoadHFiles(famPaths, fsDelegationToken.getUserToken(),
-<a class="jxr_linenumber" name="795" href="#795">795</a>                 bulkToken, getLocation().getRegionInfo().getStartKey());
-<a class="jxr_linenumber" name="796" href="#796">796</a>             }
-<a class="jxr_linenumber" name="797" href="#797">797</a>           }
-<a class="jxr_linenumber" name="798" href="#798">798</a>           <strong class="jxr_keyword">return</strong> success;
-<a class="jxr_linenumber" name="799" href="#799">799</a>         } <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="800" href="#800">800</a>           <em class="jxr_comment">//Best effort copying of files that might not have been imported</em>
-<a class="jxr_linenumber" name="801" href="#801">801</a>           <em class="jxr_comment">//from the staging directory back to original location</em>
-<a class="jxr_linenumber" name="802" href="#802">802</a>           <em class="jxr_comment">//in user directory</em>
-<a class="jxr_linenumber" name="803" href="#803">803</a>           <strong class="jxr_keyword">if</strong>(secureClient != <strong class="jxr_keyword">null</strong> &amp;&amp; !success) {
-<a class="jxr_linenumber" name="804" href="#804">804</a>             FileSystem targetFs = FileSystem.get(getConf());
-<a class="jxr_linenumber" name="805" href="#805">805</a>          <em class="jxr_comment">// fs is the source filesystem</em>
-<a class="jxr_linenumber" name="806" href="#806">806</a>             <strong class="jxr_keyword">if</strong>(fs == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="807" href="#807">807</a>               fs = lqis.iterator().next().hfilePath.getFileSystem(getConf());
-<a class="jxr_linenumber" name="808" href="#808">808</a>             }
-<a class="jxr_linenumber" name="809" href="#809">809</a>             <em class="jxr_comment">// Check to see if the source and target filesystems are the same</em>
-<a class="jxr_linenumber" name="810" href="#810">810</a>             <em class="jxr_comment">// If they are the same filesystem, we will try move the files back</em>
-<a class="jxr_linenumber" name="811" href="#811">811</a>             <em class="jxr_comment">// because previously we moved them to the staging directory.</em>
-<a class="jxr_linenumber" name="812" href="#812">812</a>             <strong class="jxr_keyword">if</strong> (FSHDFSUtils.isSameHdfs(getConf(), fs, targetFs)) {
-<a class="jxr_linenumber" name="813" href="#813">813</a>               <strong class="jxr_keyword">for</strong>(Pair&lt;byte[], String&gt; el : famPaths) {
-<a class="jxr_linenumber" name="814" href="#814">814</a>                 Path hfileStagingPath = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="815" href="#815">815</a>                 Path hfileOrigPath = <strong class="jxr_keyword">new</strong> Path(el.getSecond());
-<a class="jxr_linenumber" name="816" href="#816">816</a>                 <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="817" href="#817">817</a>                   hfileStagingPath= <strong class="jxr_keyword">new</strong> Path(secureClient.getStagingPath(bulkToken, el.getFirst()),
-<a class="jxr_linenumber" name="818" href="#818">818</a>                     hfileOrigPath.getName());
-<a class="jxr_linenumber" name="819" href="#819">819</a>                   <strong class="jxr_keyword">if</strong>(targetFs.rename(hfileStagingPath, hfileOrigPath)) {
-<a class="jxr_linenumber" name="820" href="#820">820</a>                     LOG.debug(<span class="jxr_string">"Moved back file "</span> + hfileOrigPath + <span class="jxr_string">" from "</span> +
-<a class="jxr_linenumber" name="821" href="#821">821</a>                         hfileStagingPath);
-<a class="jxr_linenumber" name="822" href="#822">822</a>                   } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong>(targetFs.exists(hfileStagingPath)){
-<a class="jxr_linenumber" name="823" href="#823">823</a>                     LOG.debug(<span class="jxr_string">"Unable to move back file "</span> + hfileOrigPath + <span class="jxr_string">" from "</span> +
-<a class="jxr_linenumber" name="824" href="#824">824</a>                         hfileStagingPath);
-<a class="jxr_linenumber" name="825" href="#825">825</a>                   }
-<a class="jxr_linenumber" name="826" href="#826">826</a>                 } <strong class="jxr_keyword">catch</strong>(Exception ex) {
-<a class="jxr_linenumber" name="827" href="#827">827</a>                   LOG.debug(<span class="jxr_string">"Unable to move back file "</span> + hfileOrigPath + <span class="jxr_string">" from "</span> +
-<a class="jxr_linenumber" name="828" href="#828">828</a>                       hfileStagingPath, ex);
-<a class="jxr_linenumber" name="829" href="#829">829</a>                 }
-<a class="jxr_linenumber" name="830" href="#830">830</a>               }
-<a class="jxr_linenumber" name="831" href="#831">831</a>             }
-<a class="jxr_linenumber" name="832" href="#832">832</a>           }
-<a class="jxr_linenumber" name="833" href="#833">833</a>         }
-<a class="jxr_linenumber" name="834" href="#834">834</a>       }
-<a class="jxr_linenumber" name="835" href="#835">835</a>     };
-<a class="jxr_linenumber" name="836" href="#836">836</a> 
-<a class="jxr_linenumber" name="837" href="#837">837</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="838" href="#838">838</a>       List&lt;LoadQueueItem&gt; toRetry = <strong class="jxr_keyword">new</strong> ArrayList&lt;LoadQueueItem&gt;();
-<a class="jxr_linenumber" name="839" href="#839">839</a>       Configuration conf = getConf();
-<a class="jxr_linenumber" name="840" href="#840">840</a>       <strong class="jxr_keyword">boolean</strong> success = RpcRetryingCallerFactory.instantiate(conf,
-<a class="jxr_linenumber" name="841" href="#841">841</a>           <strong class="jxr_keyword">null</strong>).&lt;Boolean&gt; newCaller()
-<a class="jxr_linenumber" name="842" href="#842">842</a>           .callWithRetries(svrCallable, Integer.MAX_VALUE);
-<a class="jxr_linenumber" name="843" href="#843">843</a>       <strong class="jxr_keyword">if</strong> (!success) {
-<a class="jxr_linenumber" name="844" href="#844">844</a>         LOG.warn(<span class="jxr_string">"Attempt to bulk load region containing "</span>
-<a class="jxr_linenumber" name="845" href="#845">845</a>             + Bytes.toStringBinary(first) + <span class="jxr_string">" into table "</span>
-<a class="jxr_linenumber" name="846" href="#846">846</a>             + tableName  + <span class="jxr_string">" with files "</span> + lqis
-<a class="jxr_linenumber" name="847" href="#847">847</a>             + <span class="jxr_string">" failed.  This is recoverable and they will be retried."</span>);
-<a class="jxr_linenumber" name="848" href="#848">848</a>         toRetry.addAll(lqis); <em class="jxr_comment">// return lqi's to retry</em>
-<a class="jxr_linenumber" name="849" href="#849">849</a>       }
-<a class="jxr_linenumber" name="850" href="#850">850</a>       <em class="jxr_comment">// success</em>
-<a class="jxr_linenumber" name="851" href="#851">851</a>       <strong class="jxr_keyword">return</strong> toRetry;
-<a class="jxr_linenumber" name="852" href="#852">852</a>     } <strong class="jxr_keyword">catch</strong> (IOException e) {
-<a class="jxr_linenumber" name="853" href="#853">853</a>       LOG.error(<span class="jxr_string">"Encountered unrecoverable error from region server, additional details: "</span>
-<a class="jxr_linenumber" name="854" href="#854">854</a>           + svrCallable.getExceptionMessageAdditionalDetail(), e);
-<a class="jxr_linenumber" name="855" href="#855">855</a>       <strong class="jxr_keyword">throw</strong> e;
-<a class="jxr_linenumber" name="856" href="#856">856</a>     }
-<a class="jxr_linenumber" name="857" href="#857">857</a>   }
-<a class="jxr_linenumber" name="858" href="#858">858</a> 
-<a class="jxr_linenumber" name="859" href="#859">859</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> isSecureBulkLoadEndpointAvailable() {
-<a class="jxr_linenumber" name="860" href="#860">860</a>     String classes = getConf().get(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, <span class="jxr_string">""</span>);
-<a class="jxr_linenumber" name="861" href="#861">861</a>     <strong class="jxr_keyword">return</strong> classes.contains(<span class="jxr_string">"org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint"</span>);
-<a class="jxr_linenumber" name="862" href="#862">862</a>   }
-<a class="jxr_linenumber" name="863" href="#863">863</a> 
-<a class="jxr_linenumber" name="864" href="#864">864</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="865" href="#865">865</a> <em class="jxr_javadoccomment">   * Split a storefile into a top and bottom half, maintaining</em>
-<a class="jxr_linenumber" name="866" href="#866">866</a> <em class="jxr_javadoccomment">   * the metadata, recreating bloom filters, etc.</em>
-<a class="jxr_linenumber" name="867" href="#867">867</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="868" href="#868">868</a>   <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> splitStoreFile(
-<a class="jxr_linenumber" name="869" href="#869">869</a>       Configuration conf, Path inFile,
-<a class="jxr_linenumber" name="870" href="#870">870</a>       <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> familyDesc, byte[] splitKey,
-<a class="jxr_linenumber" name="871" href="#871">871</a>       Path bottomOut, Path topOut) <strong class="jxr_keyword">throws</strong> IOException
-<a class="jxr_linenumber" name="872" href="#872">872</a>   {
-<a class="jxr_linenumber" name="873" href="#873">873</a>     <em class="jxr_comment">// Open reader with no block cache, and not in-memory</em>
-<a class="jxr_linenumber" name="874" href="#874">874</a>     <a href="../../../../../org/apache/hadoop/hbase/io/Reference.html">Reference</a> topReference = Reference.createTopReference(splitKey);
-<a class="jxr_linenumber" name="875" href="#875">875</a>     <a href="../../../../../org/apache/hadoop/hbase/io/Reference.html">Reference</a> bottomReference = Reference.createBottomReference(splitKey);
-<a class="jxr_linenumber" name="876" href="#876">876</a> 
-<a class="jxr_linenumber" name="877" href="#877">877</a>     copyHFileHalf(conf, inFile, topOut, topReference, familyDesc);
-<a class="jxr_linenumber" name="878" href="#878">878</a>     copyHFileHalf(conf, inFile, bottomOut, bottomReference, familyDesc);
-<a class="jxr_linenumber" name="879" href="#879">879</a>   }
-<a class="jxr_linenumber" name="880" href="#880">880</a> 
-<a class="jxr_linenumber" name="881" href="#881">881</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="882" href="#882">882</a> <em class="jxr_javadoccomment">   * Copy half of an HFile into a new HFile.</em>
-<a class="jxr_linenumber" name="883" href="#883">883</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="884" href="#884">884</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> copyHFileHalf(
-<a class="jxr_linenumber" name="885" href="#885">885</a>       Configuration conf, Path inFile, Path outFile, <a href="../../../../../org/apache/hadoop/hbase/io/Reference.html">Reference</a> reference,
-<a class="jxr_linenumber" name="886" href="#886">886</a>       <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> familyDescriptor)
-<a class="jxr_linenumber" name="887" href="#887">887</a>   <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="888" href="#888">888</a>     FileSystem fs = inFile.getFileSystem(conf);
-<a class="jxr_linenumber" name="889" href="#889">889</a>     <a href="../../../../../org/apache/hadoop/hbase/io/hfile/CacheConfig.html">CacheConfig</a> cacheConf = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/io/hfile/CacheConfig.html">CacheConfig</a>(conf);
-<a class="jxr_linenumber" name="890" href="#890">890</a>     <a href="../../../../../org/apache/hadoop/hbase/io/HalfStoreFileReader.html">HalfStoreFileReader</a> halfReader = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="891" href="#891">891</a>     StoreFile.Writer halfWriter = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="892" href="#892">892</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="893" href="#893">893</a>       halfReader = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/io/HalfStoreFileReader.html">HalfStoreFileReader</a>(fs, inFile, cacheConf, reference, conf);
-<a class="jxr_linenumber" name="894" href="#894">894</a>       Map&lt;byte[], byte[]&gt; fileInfo = halfReader.loadFileInfo();
-<a class="jxr_linenumber" name="895" href="#895">895</a> 
-<a class="jxr_linenumber" name="896" href="#896">896</a>       <strong class="jxr_keyword">int</strong> blocksize = familyDescriptor.getBlocksize();
-<a class="jxr_linenumber" name="897" href="#897">897</a>       Algorithm compression = familyDescriptor.getCompressionType();
-<a class="jxr_linenumber" name="898" href="#898">898</a>       <a href="../../../../../org/apache/hadoop/hbase/regionserver/BloomType.html">BloomType</a> bloomFilterType = familyDescriptor.getBloomFilterType();
-<a class="jxr_linenumber" name="899" href="#899">899</a>       <a href="../../../../../org/apache/hadoop/hbase/io/hfile/HFileContext.html">HFileContext</a> hFileContext = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/io/hfile/HFileContextBuilder.html">HFileContextBuilder</a>()
-<a class="jxr_linenumber" name="900" href="#900">900</a>                                   .withCompression(compression)
-<a class="jxr_linenumber" name="901" href="#901">901</a>                                   .withChecksumType(HStore.getChecksumType(conf))
-<a class="jxr_linenumber" name="902" href="#902">902</a>                                   .withBytesPerCheckSum(HStore.getBytesPerChecksum(conf))
-<a class="jxr_linenumber" name="903" href="#903">903</a>                                   .withBlockSize(blocksize)
-<a class="jxr_linenumber" name="904" href="#904">904</a>                                   .withDataBlockEncoding(familyDescriptor.getDataBlockEncoding())
-<a class="jxr_linenumber" name="905" href="#905">905</a>                                   .build();
-<a class="jxr_linenumber" name="906" href="#906">906</a>       halfWriter = <strong class="jxr_keyword">new</strong> StoreFile.WriterBuilder(conf, cacheConf,
-<a class="jxr_linenumber" name="907" href="#907">907</a>           fs)
-<a class="jxr_linenumber" name="908" href="#908">908</a>               .withFilePath(outFile)
-<a class="jxr_linenumber" name="909" href="#909">909</a>               .withBloomType(bloomFilterType)
-<a class="jxr_linenumber" name="910" href="#910">910</a>               .withFileContext(hFileContext)
-<a class="jxr_linenumber" name="911" href="#911">911</a>               .build();
-<a class="jxr_linenumber" name="912" href="#912">912</a>       <a href="../../../../../org/apache/hadoop/hbase/io/hfile/HFileScanner.html">HFileScanner</a> scanner = halfReader.getScanner(false, false, false);
-<a class="jxr_linenumber" name="913" href="#913">913</a>       scanner.seekTo();
-<a class="jxr_linenumber" name="914" href="#914">914</a>       <strong class="jxr_keyword">do</strong> {
-<a class="jxr_linenumber" name="915" href="#915">915</a>         halfWriter.append(scanner.getCell());
-<a class="jxr_linenumber" name="916" href="#916">916</a>       } <strong class="jxr_keyword">while</strong> (scanner.next());
-<a class="jxr_linenumber" name="917" href="#917">917</a> 
-<a class="jxr_linenumber" name="918" href="#918">918</a>       <strong class="jxr_keyword">for</strong> (Map.Entry&lt;byte[],byte[]&gt; entry : fileInfo.entrySet()) {
-<a class="jxr_linenumber" name="919" href="#919">919</a>         <strong class="jxr_keyword">if</strong> (shouldCopyHFileMetaKey(entry.getKey())) {
-<a class="jxr_linenumber" name="920" href="#920">920</a>           halfWriter.appendFileInfo(entry.getKey(), entry.getValue());
-<a class="jxr_linenumber" name="921" href="#921">921</a>         }
-<a class="jxr_linenumber" name="922" href="#922">922</a>       }
-<a class="jxr_linenumber" name="923" href="#923">923</a>     } <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="924" href="#924">924</a>       <strong class="jxr_keyword">if</strong> (halfWriter != <strong class="jxr_keyword">null</strong>) halfWriter.close();
-<a class="jxr_linenumber" name="925" href="#925">925</a>       <strong class="jxr_keyword">if</strong> (halfReader != <strong class="jxr_keyword">null</strong>) halfReader.close(cacheConf.shouldEvictOnClose());
-<a class="jxr_linenumber" name="926" href="#926">926</a>     }
-<a class="jxr_linenumber" name="927" href="#927">927</a>   }
-<a class="jxr_linenumber" name="928" href="#928">928</a> 
-<a class="jxr_linenumber" name="929" href="#929">929</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> shouldCopyHFileMetaKey(byte[] key) {
-<a class="jxr_linenumber" name="930" href="#930">930</a>     <strong class="jxr_keyword">return</strong> !HFile.isReservedFileInfoKey(key);
-<a class="jxr_linenumber" name="931" href="#931">931</a>   }
-<a class="jxr_linenumber" name="932" href="#932">932</a> 
-<a class="jxr_linenumber" name="933" href="#933">933</a>   <em class="jxr_comment">/*</em>
-<a class="jxr_linenumber" name="934" href="#934">934</a> <em class="jxr_comment">   * Infers region boundaries for a new table.</em>
-<a class="jxr_linenumber" name="935" href="#935">935</a> <em class="jxr_comment">   * Parameter:</em>
-<a class="jxr_linenumber" name="936" href="#936">936</a> <em class="jxr_comment">   *   bdryMap is a map between keys to an integer belonging to {+1, -1}</em>
-<a class="jxr_linenumber" name="937" href="#937">937</a> <em class="jxr_comment">   *     If a key is a start key of a file, then it maps to +1</em>
-<a class="jxr_linenumber" name="938" href="#938">938</a> <em class="jxr_comment">   *     If a key is an end key of a file, then it maps to -1</em>
-<a class="jxr_linenumber" name="939" href="#939">939</a> <em class="jxr_comment">   * Algo:</em>
-<a class="jxr_linenumber" name="940" href="#940">940</a> <em class="jxr_comment">   * 1) Poll on the keys in order:</em>
-<a class="jxr_linenumber" name="941" href="#941">941</a> <em class="jxr_comment">   *    a) Keep adding the mapped values to these keys (runningSum)</em>
-<a class="jxr_linenumber" name="942" href="#942">942</a> <em class="jxr_comment">   *    b) Each time runningSum reaches 0, add the start Key from when the runningSum had started to</em>
-<a class="jxr_linenumber" name="943" href="#943">943</a> <em class="jxr_comment">   *       a boundary list.</em>
-<a class="jxr_linenumber" name="944" href="#944">944</a> <em class="jxr_comment">   * 2) Return the boundary list.</em>
-<a class="jxr_linenumber" name="945" href="#945">945</a> <em class="jxr_comment">   */</em>
-<a class="jxr_linenumber" name="946" href="#946">946</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> byte[][] inferBoundaries(TreeMap&lt;byte[], Integer&gt; bdryMap) {
-<a class="jxr_linenumber" name="947" href="#947">947</a>     ArrayList&lt;byte[]&gt; keysArray = <strong class="jxr_keyword">new</strong> ArrayList&lt;byte[]&gt;();
-<a class="jxr_linenumber" name="948" href="#948">948</a>     <strong class="jxr_keyword">int</strong> runningValue = 0;
-<a class="jxr_linenumber" name="949" href="#949">949</a>     byte[] currStartKey = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="950" href="#950">950</a>     <strong class="jxr_keyword">boolean</strong> firstBoundary = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="951" href="#951">951</a> 
-<a class="jxr_linenumber" name="952" href="#952">952</a>     <strong class="jxr_keyword">for</strong> (Map.Entry&lt;byte[], Integer&gt; item: bdryMap.entrySet()) {
-<a class="jxr_linenumber" name="953" href="#953">953</a>       <strong class="jxr_keyword">if</strong> (runningValue == 0) currStartKey = item.getKey();
-<a class="jxr_linenumber" name="954" href="#954">954</a>       runningValue += item.getValue();
-<a class="jxr_linenumber" name="955" href="#955">955</a>       <strong class="jxr_keyword">if</strong> (runningValue == 0) {
-<a class="jxr_linenumber" name="956" href="#956">956</a>         <strong class="jxr_keyword">if</strong> (!firstBoundary) keysArray.add(currStartKey);
-<a class="jxr_linenumber" name="957" href="#957">957</a>         firstBoundary = false;
-<a class="jxr_linenumber" name="958" href="#958">958</a>       }
-<a class="jxr_linenumber" name="959" href="#959">959</a>     }
-<a class="jxr_linenumber" name="960" href="#960">960</a> 
-<a class="jxr_linenumber" name="961" href="#961">961</a>     <strong class="jxr_keyword">return</strong> keysArray.toArray(<strong class="jxr_keyword">new</strong> byte[0][0]);
-<a class="jxr_linenumber" name="962" href="#962">962</a>   }
-<a class="jxr_linenumber" name="963" href="#963">963</a> 
-<a class="jxr_linenumber" name="964" href="#964">964</a>   <em class="jxr_comment">/*</em>
-<a class="jxr_linenumber" name="965" href="#965">965</a> <em class="jxr_comment">   * If the table is created for the first time, then "completebulkload" reads the files twice.</em>
-<a class="jxr_linenumber" name="966" href="#966">966</a> <em class="jxr_comment">   * More modifications necessary if we want to avoid doing it.</em>
-<a class="jxr_linenumber" name="967" href="#967">967</a> <em class="jxr_comment">   */</em>
-<a class="jxr_linenumber" name="968" href="#968">968</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> createTable(<a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName, String dirPath, <a href="../../../../../org/apache/hadoop/hbase/client/Admin.html">Admin</a> admin) <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="969" href="#969">969</a>     <strong class="jxr_keyword">final</strong> Path hfofDir = <strong class="jxr_keyword">new</strong> Path(dirPath);
-<a class="jxr_linenumber" name="970" href="#970">970</a>     <strong class="jxr_keyword">final</strong> FileSystem fs = hfofDir.getFileSystem(getConf());
-<a class="jxr_linenumber" name="971" href="#971">971</a> 
-<a class="jxr_linenumber" name="972" href="#972">972</a>     <em class="jxr_comment">// Add column families</em>
-<a class="jxr_linenumber" name="973" href="#973">973</a>     <em class="jxr_comment">// Build a set of keys</em>
-<a class="jxr_linenumber" name="974" href="#974">974</a>     <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a> htd = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a>(tableName);
-<a class="jxr_linenumber" name="975" href="#975">975</a>     <strong class="jxr_keyword">final</strong> TreeMap&lt;byte[], Integer&gt; map = <strong class="jxr_keyword">new</strong> TreeMap&lt;byte[], Integer&gt;(Bytes.BYTES_COMPARATOR);
-<a class="jxr_linenumber" name="976" href="#976">976</a>     visitBulkHFiles(fs, hfofDir, <strong class="jxr_keyword">new</strong> BulkHFileVisitor&lt;HColumnDescriptor&gt;() {
-<a class="jxr_linenumber" name="977" href="#977">977</a>       @Override
-<a class="jxr_linenumber" name="978" href="#978">978</a>       <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> bulkFamily(<strong class="jxr_keyword">final</strong> byte[] familyName) {
-<a class="jxr_linenumber" name="979" href="#979">979</a>         <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> hcd = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a>(familyName);
-<a class="jxr_linenumber" name="980" href="#980">980</a>         htd.addFamily(hcd);
-<a class="jxr_linenumber" name="981" href="#981">981</a>         <strong class="jxr_keyword">return</strong> hcd;
-<a class="jxr_linenumber" name="982" href="#982">982</a>       }
-<a class="jxr_linenumber" name="983" href="#983">983</a>       @Override
-<a class="jxr_linenumber" name="984" href="#984">984</a>       <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> bulkHFile(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HColumnDescriptor.html">HColumnDescriptor</a> hcd, <strong class="jxr_keyword">final</strong> FileStatus hfileStatus)
-<a class="jxr_linenumber" name="985" href="#985">985</a>           <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="986" href="#986">986</a>         Path hfile = hfileStatus.getPath();
-<a class="jxr_linenumber" name="987" href="#987">987</a>         HFile.Reader reader = HFile.createReader(fs, hfile,
-<a class="jxr_linenumber" name="988" href="#988">988</a>             <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/io/hfile/CacheConfig.html">CacheConfig</a>(getConf()), getConf());
-<a class="jxr_linenumber" name="989" href="#989">989</a>         <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="990" href="#990">990</a>           <strong class="jxr_keyword">if</strong> (hcd.getCompressionType() != reader.getFileContext().getCompression()) {
-<a class="jxr_linenumber" name="991" href="#991">991</a>             hcd.setCompressionType(reader.getFileContext().getCompression());
-<a class="jxr_linenumber" name="992" href="#992">992</a>             LOG.info(<span class="jxr_string">"Setting compression "</span> + hcd.getCompressionType().name() +
-<a class="jxr_linenumber" name="993" href="#993">993</a>                      <span class="jxr_string">" for family "</span> + hcd.toString());
-<a class="jxr_linenumber" name="994" href="#994">994</a>           }
-<a class="jxr_linenumber" name="995" href="#995">995</a>           reader.loadFileInfo();
-<a class="jxr_linenumber" name="996" href="#996">996</a>           byte[] first = reader.getFirstRowKey();
-<a class="jxr_linenumber" name="997" href="#997">997</a>           byte[] last  = reader.getLastRowKey();
-<a class="jxr_linenumber" name="998" href="#998">998</a> 
-<a class="jxr_linenumber" name="999" href="#999">999</a>           LOG.info(<span class="jxr_string">"Trying to figure out region boundaries hfile="</span> + hfile +
-<a class="jxr_linenumber" name="1000" href="#1000">1000</a>             <span class="jxr_string">" first="</span> + Bytes.toStringBinary(first) +
-<a class="jxr_linenumber" name="1001" href="#1001">1001</a>             <span class="jxr_string">" last="</span>  + Bytes.toStringBinary(last));
-<a class="jxr_linenumber" name="1002" href="#1002">1002</a> 
-<a class="jxr_linenumber" name="1003" href="#1003">1003</a>           <em class="jxr_comment">// To eventually infer start key-end key boundaries</em>
-<a class="jxr_linenumber" name="1004" href="#1004">1004</a>           Integer value = map.containsKey(first)? map.get(first):0;
-<a class="jxr_linenumber" name="1005" href="#1005">1005</a>           map.put(first, value+1);
-<a class="jxr_linenumber" name="1006" href="#1006">1006</a> 
-<a class="jxr_linenumber" name="1007" href="#1007">1007</a>           value = map.containsKey(last)? map.get(last):0;
-<a class="jxr_linenumber" name="1008" href="#1008">1008</a>           map.put(last, value-1);
-<a class="jxr_linenumber" name="1009" href="#1009">1009</a>         } <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="1010" href="#1010">1010</a>           reader.close();
-<a class="jxr_linenumber" name="1011" href="#1011">1011</a>         }
-<a class="jxr_linenumber" name="1012" href="#1012">1012</a>       }
-<a class="jxr_linenumber" name="1013" href="#1013">1013</a>     });
-<a class="jxr_linenumber" name="1014" href="#1014">1014</a> 
-<a class="jxr_linenumber" name="1015" href="#1015">1015</a>     byte[][] keys = LoadIncrementalHFiles.inferBoundaries(map);
-<a class="jxr_linenumber" name="1016" href="#1016">1016</a>     admin.createTable(htd, keys);
-<a class="jxr_linenumber" name="1017" href="#1017">1017</a> 
-<a class="jxr_linenumber" name="1018" href="#1018">1018</a>     LOG.info(<span class="jxr_string">"Table "</span>+ tableName +<span class="jxr_string">" is available!!"</span>);
-<a class="jxr_linenumber" name="1019" href="#1019">1019</a>   }
-<a class="jxr_linenumber" name="1020" href="#1020">1020</a> 
-<a class="jxr_linenumber" name="1021" href="#1021">1021</a>   @Override
-<a class="jxr_linenumber" name="1022" href="#1022">1022</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> run(String[] args) <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="1023" href="#1023">1023</a>     <strong class="jxr_keyword">if</strong> (args.length != 2) {
-<a class="jxr_linenumber" name="1024" href="#1024">1024</a>       usage();
-<a class="jxr_linenumber" name="1025" href="#1025">1025</a>       <strong class="jxr_keyword">return</strong> -1;
-<a class="jxr_linenumber" name="1026" href="#1026">1026</a>     }
-<a class="jxr_linenumber" name="1027" href="#1027">1027</a> 
-<a class="jxr_linenumber" name="1028" href="#1028">1028</a>     initialize();
-<a class="jxr_linenumber" name="1029" href="#1029">1029</a>     <strong class="jxr_keyword">try</strong> (Connection connection = ConnectionFactory.createConnection(getConf());
-<a class="jxr_linenumber" name="1030" href="#1030">1030</a>         <a href="../../../../../org/apache/hadoop/hbase/client/Admin.html">Admin</a> admin = connection.getAdmin()) {
-<a class="jxr_linenumber" name="1031" href="#1031">1031</a>       String dirPath = args[0];
-<a class="jxr_linenumber" name="1032" href="#1032">1032</a>       <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName = TableName.valueOf(args[1]);
-<a class="jxr_linenumber" name="1033" href="#1033">1033</a> 
-<a class="jxr_linenumber" name="1034" href="#1034">1034</a>       <strong class="jxr_keyword">boolean</strong> tableExists = admin.tableExists(tableName);
-<a class="jxr_linenumber" name="1035" href="#1035">1035</a>       <strong class="jxr_keyword">if</strong> (!tableExists) {
-<a class="jxr_linenumber" name="1036" href="#1036">1036</a>         <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"yes"</span>.equalsIgnoreCase(getConf().get(CREATE_TABLE_CONF_KEY, <span class="jxr_string">"yes"</span>))) {
-<a class="jxr_linenumber" name="1037" href="#1037">1037</a>           <strong class="jxr_keyword">this</strong>.createTable(tableName, dirPath, admin);
-<a class="jxr_linenumber" name="1038" href="#1038">1038</a>         } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="1039" href="#1039">1039</a>           String errorMsg = format(<span class="jxr_string">"Table '%s' does not exist."</span>, tableName);
-<a class="jxr_linenumber" name="1040" href="#1040">1040</a>           LOG.error(errorMsg);
-<a class="jxr_linenumber" name="1041" href="#1041">1041</a>           <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/TableNotFoundException.html">TableNotFoundException</a>(errorMsg);
-<a class="jxr_linenumber" name="1042" href="#1042">1042</a>         }
-<a class="jxr_linenumber" name="1043" href="#1043">1043</a>       }
-<a class="jxr_linenumber" name="1044" href="#1044">1044</a> 
-<a class="jxr_linenumber" name="1045" href="#1045">1045</a>       Path hfofDir = <strong class="jxr_keyword">new</strong> Path(dirPath);
-<a class="jxr_linenumber" name="1046" href="#1046">1046</a> 
-<a class="jxr_linenumber" name="1047" href="#1047">1047</a>       <strong class="jxr_keyword">try</strong> (Table table = connection.getTable(tableName);
-<a class="jxr_linenumber" name="1048" href="#1048">1048</a>           <a href="../../../../../org/apache/hadoop/hbase/client/RegionLocator.html">RegionLocator</a> locator = connection.getRegionLocator(tableName)) {
-<a class="jxr_linenumber" name="1049" href="#1049">1049</a>           doBulkLoad(hfofDir, admin, table, locator);
-<a class="jxr_linenumber" name="1050" href="#1050">1050</a>       }
-<a class="jxr_linenumber" name="1051" href="#1051">1051</a>     }
-<a class="jxr_linenumber" name="1052" href="#1052">1052</a> 
-<a class="jxr_linenumber" name="1053" href="#1053">1053</a>     <strong class="jxr_keyword">return</strong> 0;
-<a class="jxr_linenumber" name="1054" href="#1054">1054</a>   }
-<a class="jxr_linenumber" name="1055" href="#1055">1055</a> 
-<a class="jxr_linenumber" name="1056" href="#1056">1056</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> main(String[] args) <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="1057" href="#1057">1057</a>     Configuration conf = HBaseConfiguration.create();
-<a class="jxr_linenumber" name="1058" href="#1058">1058</a>     <strong class="jxr_keyword">int</strong> ret = ToolRunner.run(conf, <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.html">LoadIncrementalHFiles</a>(), args);
-<a class="jxr_linenumber" name="1059" href="#1059">1059</a>     System.exit(ret);
-<a class="jxr_linenumber" name="1060" href="#1060">1060</a>   }
-<a class="jxr_linenumber" name="1061" href="#1061">1061</a> 
-<a class="jxr_linenumber" name="1062" href="#1062">1062</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="1063" href="#1063">1063</a> <em class="jxr_javadoccomment">   * Called from replication sink, where it manages bulkToken(staging directory) by itself. This is</em>
-<a class="jxr_linenumber" name="1064" href="#1064">1064</a> <em class="jxr_javadoccomment">   * used only when {@link SecureBulkLoadEndpoint} is configured in hbase.coprocessor.region.classes</em>
-<a class="jxr_linenumber" name="1065" href="#1065">1065</a> <em class="jxr_javadoccomment">   * property. This directory is used as a temporary directory where all files are initially</em>
-<a class="jxr_linenumber" name="1066" href="#1066">1066</a> <em class="jxr_javadoccomment">   * copied/moved from user given directory, set all the required file permissions and then from</em>
-<a class="jxr_linenumber" name="1067" href="#1067">1067</a> <em class="jxr_javadoccomment">   * their it is finally loaded into a table. This should be set only when, one would like to manage</em>
-<a class="jxr_linenumber" name="1068" href="#1068">1068</a> <em class="jxr_javadoccomment">   * the staging directory by itself. Otherwise this tool will handle this by itself.</em>
-<a class="jxr_linenumber" name="1069" href="#1069">1069</a> <em class="jxr_javadoccomment">   * @param stagingDir staging directory path</em>
-<a class="jxr_linenumber" name="1070" href="#1070">1070</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="1071" href="#1071">1071</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setBulkToken(String stagingDir) {
-<a class="jxr_linenumber" name="1072" href="#1072">1072</a>     <strong class="jxr_keyword">this</strong>.bulkToken = stagingDir;
-<a class="jxr_linenumber" name="1073" href="#1073">1073</a>   }
-<a class="jxr_linenumber" name="1074" href="#1074">1074</a> 
-<a class="jxr_linenumber" name="1075" href="#1075">1075</a> }
+<a class="jxr_linenumber" name="428" href="#428">428</a> <em class="jxr_javadoccomment">   * @param validateHFile if true hfiles will be validated for its format</em>
+<a class="jxr_linenumber" name="429" href="#429">429</a> <em class="jxr_javadoccomment">   * @throws IOException If any I/O or network error occurred</em>
+<a class="jxr_linenumber" name="430" href="#430">430</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="431" href="#431">431</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> prepareHFileQueue(Path hfilesDir, <a href="../../../../../org/apache/hadoop/hbase/client/Table.html">Table</a> table, Deque&lt;LoadQueueItem&gt; queue,
+<a class="jxr_linenumber" name="432" href="#432">432</a>       <strong class="jxr_keyword">boolean</strong> validateHFile) <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="433" href="#433">433</a>     discoverLoadQueue(queue, hfilesDir, validateHFile);
+<a class="jxr_linenumber" name="434" href="#434">434</a>     validateFamiliesInHFiles(table, queue);
+<a class="jxr_linenumber" name="435" href="#435">435</a>   }
+<a class="jxr_linenumber" name="436" href="#436">436</a> 
+<a class="jxr_linenumber" name="437" href="#437">437</a>   <em class="jxr_comment">// Initialize a thread pool</em>
+<a class="jxr_linenumber" name="438" href="#438">438</a>   <strong class="jxr_keyword">private</strong> ExecutorService createExecutorService() {
+<a class="jxr_linenumber" name="439" href="#439">439</a>     ThreadFactoryBuilder builder = <strong class="jxr_keyword">new</strong> ThreadFactoryBuilder();
+<a class="jxr_linenumber" name="440" href="#440">440</a>     builder.setNameFormat(<span class="jxr_string">"LoadIncrementalHFiles-%1$d"</span>);
+<a class="jxr_linenumber" name="441" href="#441">441</a>     ExecutorService pool = <strong class="jxr_keyword">new</strong> ThreadPoolExecutor(nrThreads, nrThreads, 60, TimeUnit.SECONDS,
+<a class="jxr_linenumber" name="442" href="#442">442</a>         <strong class="jxr_keyword">new</strong> LinkedBlockingQueue&lt;Runnable&gt;(), builder.build());
+<a class="jxr_linenumber" name="443" href="#443">443</a>     ((ThreadPoolExecutor) pool).allowCoreThreadTimeOut(<strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="444" href="#444">444</a>     <strong class="jxr_keyword">return</strong> pool;
+<a class="jxr_linenumber" name="445" href="#445">445</a>   }
+<a class="jxr_linenumber" name="446" href="#446">446</a> 
+<a class="jxr_linenumber" name="447" href="#447">447</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="448" href="#448">448</a> <em class="jxr_javadoccomment">   * Checks whether there is any invalid family name in HFiles to be bulk loaded.</em>
+<a class="jxr_linenumber" name="449" href="#449">449</a> <em class="jxr_javadoccom

<TRUNCATED>

Mime
View raw message