hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1711891 [45/50] - in /hbase/hbase.apache.org/trunk: ./ apidocs/ apidocs/org/apache/hadoop/hbase/ apidocs/org/apache/hadoop/hbase/class-use/ apidocs/org/apache/hadoop/hbase/client/ apidocs/org/apache/hadoop/hbase/client/class-use/ apidocs/o...
Date Mon, 02 Nov 2015 03:51:05 GMT
Modified: hbase/hbase.apache.org/trunk/xref/org/apache/hadoop/hbase/master/CatalogJanitor.html
URL: http://svn.apache.org/viewvc/hbase/hbase.apache.org/trunk/xref/org/apache/hadoop/hbase/master/CatalogJanitor.html?rev=1711891&r1=1711890&r2=1711891&view=diff
==============================================================================
--- hbase/hbase.apache.org/trunk/xref/org/apache/hadoop/hbase/master/CatalogJanitor.html (original)
+++ hbase/hbase.apache.org/trunk/xref/org/apache/hadoop/hbase/master/CatalogJanitor.html Mon Nov  2 03:51:02 2015
@@ -123,8 +123,8 @@
 <a class="jxr_linenumber" name="113" href="#113">113</a> <em class="jxr_javadoccomment">   *         parent regioninfos</em>
 <a class="jxr_linenumber" name="114" href="#114">114</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
 <a class="jxr_linenumber" name="115" href="#115">115</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="116" href="#116">116</a>   Triple&lt;Integer, Map&lt;HRegionInfo, Result&gt;, Map&lt;HRegionInfo, Result&gt;&gt; getMergedRegionsAndSplitParents()
-<a class="jxr_linenumber" name="117" href="#117">117</a>       <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="116" href="#116">116</a>   Triple&lt;Integer, Map&lt;HRegionInfo, Result&gt;, Map&lt;HRegionInfo, Result&gt;&gt;
+<a class="jxr_linenumber" name="117" href="#117">117</a>     getMergedRegionsAndSplitParents() <strong class="jxr_keyword">throws</strong> IOException {
 <a class="jxr_linenumber" name="118" href="#118">118</a>     <strong class="jxr_keyword">return</strong> getMergedRegionsAndSplitParents(<strong class="jxr_keyword">null</strong>);
 <a class="jxr_linenumber" name="119" href="#119">119</a>   }
 <a class="jxr_linenumber" name="120" href="#120">120</a> 
@@ -138,8 +138,8 @@
 <a class="jxr_linenumber" name="128" href="#128">128</a> <em class="jxr_javadoccomment">   *         parent regioninfos</em>
 <a class="jxr_linenumber" name="129" href="#129">129</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
 <a class="jxr_linenumber" name="130" href="#130">130</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="131" href="#131">131</a>   Triple&lt;Integer, Map&lt;HRegionInfo, Result&gt;, Map&lt;HRegionInfo, Result&gt;&gt; getMergedRegionsAndSplitParents(
-<a class="jxr_linenumber" name="132" href="#132">132</a>       <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName) <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="131" href="#131">131</a>   Triple&lt;Integer, Map&lt;HRegionInfo, Result&gt;, Map&lt;HRegionInfo, Result&gt;&gt;
+<a class="jxr_linenumber" name="132" href="#132">132</a>     getMergedRegionsAndSplitParents(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName) <strong class="jxr_keyword">throws</strong> IOException {
 <a class="jxr_linenumber" name="133" href="#133">133</a>     <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isTableSpecified = (tableName != <strong class="jxr_keyword">null</strong>);
 <a class="jxr_linenumber" name="134" href="#134">134</a>     <em class="jxr_comment">// TODO: Only works with single hbase:meta region currently.  Fix.</em>
 <a class="jxr_linenumber" name="135" href="#135">135</a>     <strong class="jxr_keyword">final</strong> AtomicInteger count = <strong class="jxr_keyword">new</strong> AtomicInteger(0);
@@ -155,7 +155,7 @@
 <a class="jxr_linenumber" name="145" href="#145">145</a>       <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> visit(<a href="../../../../../org/apache/hadoop/hbase/client/Result.html">Result</a> r) <strong class="jxr_keyword">throws</strong> IOException {
 <a class="jxr_linenumber" name="146" href="#146">146</a>         <strong class="jxr_keyword">if</strong> (r == <strong class="jxr_keyword">null</strong> || r.isEmpty()) <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
 <a class="jxr_linenumber" name="147" href="#147">147</a>         count.incrementAndGet();
-<a class="jxr_linenumber" name="148" href="#148">148</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> info = HRegionInfo.getHRegionInfo(r);
+<a class="jxr_linenumber" name="148" href="#148">148</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> info = MetaTableAccessor.getHRegionInfo(r);
 <a class="jxr_linenumber" name="149" href="#149">149</a>         <strong class="jxr_keyword">if</strong> (info == <strong class="jxr_keyword">null</strong>) <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>; <em class="jxr_comment">// Keep scanning</em>
 <a class="jxr_linenumber" name="150" href="#150">150</a>         <strong class="jxr_keyword">if</strong> (isTableSpecified
 <a class="jxr_linenumber" name="151" href="#151">151</a>             &amp;&amp; info.getTable().compareTo(tableName) &gt; 0) {
@@ -235,215 +235,216 @@
 <a class="jxr_linenumber" name="225" href="#225">225</a>       <strong class="jxr_keyword">int</strong> mergeCleaned = 0;
 <a class="jxr_linenumber" name="226" href="#226">226</a>       Map&lt;HRegionInfo, Result&gt; mergedRegions = scanTriple.getSecond();
 <a class="jxr_linenumber" name="227" href="#227">227</a>       <strong class="jxr_keyword">for</strong> (Map.Entry&lt;HRegionInfo, Result&gt; e : mergedRegions.entrySet()) {
-<a class="jxr_linenumber" name="228" href="#228">228</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> regionA = HRegionInfo.getHRegionInfo(e.getValue(),
-<a class="jxr_linenumber" name="229" href="#229">229</a>             HConstants.MERGEA_QUALIFIER);
-<a class="jxr_linenumber" name="230" href="#230">230</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> regionB = HRegionInfo.getHRegionInfo(e.getValue(),
-<a class="jxr_linenumber" name="231" href="#231">231</a>             HConstants.MERGEB_QUALIFIER);
-<a class="jxr_linenumber" name="232" href="#232">232</a>         <strong class="jxr_keyword">if</strong> (regionA == <strong class="jxr_keyword">null</strong> || regionB == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="233" href="#233">233</a>           LOG.warn(<span class="jxr_string">"Unexpected references regionA="</span>
-<a class="jxr_linenumber" name="234" href="#234">234</a>               + (regionA == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">"null"</span> : regionA.getRegionNameAsString())
-<a class="jxr_linenumber" name="235" href="#235">235</a>               + <span class="jxr_string">",regionB="</span>
-<a class="jxr_linenumber" name="236" href="#236">236</a>               + (regionB == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">"null"</span> : regionB.getRegionNameAsString())
-<a class="jxr_linenumber" name="237" href="#237">237</a>               + <span class="jxr_string">" in merged region "</span> + e.getKey().getRegionNameAsString());
-<a class="jxr_linenumber" name="238" href="#238">238</a>         } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="239" href="#239">239</a>           <strong class="jxr_keyword">if</strong> (cleanMergeRegion(e.getKey(), regionA, regionB)) {
-<a class="jxr_linenumber" name="240" href="#240">240</a>             mergeCleaned++;
-<a class="jxr_linenumber" name="241" href="#241">241</a>           }
-<a class="jxr_linenumber" name="242" href="#242">242</a>         }
-<a class="jxr_linenumber" name="243" href="#243">243</a>       }
-<a class="jxr_linenumber" name="244" href="#244">244</a>       <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="245" href="#245">245</a> <em class="jxr_javadoccomment">       * clean split parents</em>
-<a class="jxr_linenumber" name="246" href="#246">246</a> <em class="jxr_javadoccomment">       */</em>
-<a class="jxr_linenumber" name="247" href="#247">247</a>       Map&lt;HRegionInfo, Result&gt; splitParents = scanTriple.getThird();
-<a class="jxr_linenumber" name="248" href="#248">248</a> 
-<a class="jxr_linenumber" name="249" href="#249">249</a>       <em class="jxr_comment">// Now work on our list of found parents. See if any we can clean up.</em>
-<a class="jxr_linenumber" name="250" href="#250">250</a>       <strong class="jxr_keyword">int</strong> splitCleaned = 0;
-<a class="jxr_linenumber" name="251" href="#251">251</a>       <em class="jxr_comment">// regions whose parents are still around</em>
-<a class="jxr_linenumber" name="252" href="#252">252</a>       HashSet&lt;String&gt; parentNotCleaned = <strong class="jxr_keyword">new</strong> HashSet&lt;String&gt;();
-<a class="jxr_linenumber" name="253" href="#253">253</a>       <strong class="jxr_keyword">for</strong> (Map.Entry&lt;HRegionInfo, Result&gt; e : splitParents.entrySet()) {
-<a class="jxr_linenumber" name="254" href="#254">254</a>         <strong class="jxr_keyword">if</strong> (!parentNotCleaned.contains(e.getKey().getEncodedName()) &amp;&amp;
-<a class="jxr_linenumber" name="255" href="#255">255</a>             cleanParent(e.getKey(), e.getValue())) {
-<a class="jxr_linenumber" name="256" href="#256">256</a>           splitCleaned++;
-<a class="jxr_linenumber" name="257" href="#257">257</a>         } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="258" href="#258">258</a>           <em class="jxr_comment">// We could not clean the parent, so it's daughters should not be cleaned either (HBASE-6160)</em>
-<a class="jxr_linenumber" name="259" href="#259">259</a>           PairOfSameType&lt;HRegionInfo&gt; daughters = HRegionInfo.getDaughterRegions(e.getValue());
-<a class="jxr_linenumber" name="260" href="#260">260</a>           parentNotCleaned.add(daughters.getFirst().getEncodedName());
-<a class="jxr_linenumber" name="261" href="#261">261</a>           parentNotCleaned.add(daughters.getSecond().getEncodedName());
-<a class="jxr_linenumber" name="262" href="#262">262</a>         }
-<a class="jxr_linenumber" name="263" href="#263">263</a>       }
-<a class="jxr_linenumber" name="264" href="#264">264</a>       <strong class="jxr_keyword">if</strong> ((mergeCleaned + splitCleaned) != 0) {
-<a class="jxr_linenumber" name="265" href="#265">265</a>         LOG.info(<span class="jxr_string">"Scanned "</span> + count + <span class="jxr_string">" catalog row(s), gc'd "</span> + mergeCleaned
-<a class="jxr_linenumber" name="266" href="#266">266</a>             + <span class="jxr_string">" unreferenced merged region(s) and "</span> + splitCleaned
-<a class="jxr_linenumber" name="267" href="#267">267</a>             + <span class="jxr_string">" unreferenced parent region(s)"</span>);
-<a class="jxr_linenumber" name="268" href="#268">268</a>       } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (LOG.isTraceEnabled()) {
-<a class="jxr_linenumber" name="269" href="#269">269</a>         LOG.trace(<span class="jxr_string">"Scanned "</span> + count + <span class="jxr_string">" catalog row(s), gc'd "</span> + mergeCleaned
-<a class="jxr_linenumber" name="270" href="#270">270</a>             + <span class="jxr_string">" unreferenced merged region(s) and "</span> + splitCleaned
-<a class="jxr_linenumber" name="271" href="#271">271</a>             + <span class="jxr_string">" unreferenced parent region(s)"</span>);
-<a class="jxr_linenumber" name="272" href="#272">272</a>       }
-<a class="jxr_linenumber" name="273" href="#273">273</a>       <strong class="jxr_keyword">return</strong> mergeCleaned + splitCleaned;
-<a class="jxr_linenumber" name="274" href="#274">274</a>     } <strong class="jxr_keyword">finally</strong> {
-<a class="jxr_linenumber" name="275" href="#275">275</a>       alreadyRunning.set(false);
-<a class="jxr_linenumber" name="276" href="#276">276</a>     }
-<a class="jxr_linenumber" name="277" href="#277">277</a>   }
-<a class="jxr_linenumber" name="278" href="#278">278</a> 
-<a class="jxr_linenumber" name="279" href="#279">279</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="280" href="#280">280</a> <em class="jxr_javadoccomment">   * Compare HRegionInfos in a way that has split parents sort BEFORE their</em>
-<a class="jxr_linenumber" name="281" href="#281">281</a> <em class="jxr_javadoccomment">   * daughters.</em>
-<a class="jxr_linenumber" name="282" href="#282">282</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="283" href="#283">283</a>   <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/hadoop/hbase/master/CatalogJanitor.html">SplitParentFirstComparator</a> <strong class="jxr_keyword">implements</strong> Comparator&lt;HRegionInfo&gt; {
-<a class="jxr_linenumber" name="284" href="#284">284</a>     Comparator&lt;byte[]&gt; rowEndKeyComparator = <strong class="jxr_keyword">new</strong> Bytes.RowEndKeyComparator();
-<a class="jxr_linenumber" name="285" href="#285">285</a>     @Override
-<a class="jxr_linenumber" name="286" href="#286">286</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> left, <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> right) {
-<a class="jxr_linenumber" name="287" href="#287">287</a>       <em class="jxr_comment">// This comparator differs from the one HRegionInfo in that it sorts</em>
-<a class="jxr_linenumber" name="288" href="#288">288</a>       <em class="jxr_comment">// parent before daughters.</em>
-<a class="jxr_linenumber" name="289" href="#289">289</a>       <strong class="jxr_keyword">if</strong> (left == <strong class="jxr_keyword">null</strong>) <strong class="jxr_keyword">return</strong> -1;
-<a class="jxr_linenumber" name="290" href="#290">290</a>       <strong class="jxr_keyword">if</strong> (right == <strong class="jxr_keyword">null</strong>) <strong class="jxr_keyword">return</strong> 1;
-<a class="jxr_linenumber" name="291" href="#291">291</a>       <em class="jxr_comment">// Same table name.</em>
-<a class="jxr_linenumber" name="292" href="#292">292</a>       <strong class="jxr_keyword">int</strong> result = left.getTable().compareTo(right.getTable());
-<a class="jxr_linenumber" name="293" href="#293">293</a>       <strong class="jxr_keyword">if</strong> (result != 0) <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="294" href="#294">294</a>       <em class="jxr_comment">// Compare start keys.</em>
-<a class="jxr_linenumber" name="295" href="#295">295</a>       result = Bytes.compareTo(left.getStartKey(), right.getStartKey());
-<a class="jxr_linenumber" name="296" href="#296">296</a>       <strong class="jxr_keyword">if</strong> (result != 0) <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="297" href="#297">297</a>       <em class="jxr_comment">// Compare end keys, but flip the operands so parent comes first</em>
-<a class="jxr_linenumber" name="298" href="#298">298</a>       result = rowEndKeyComparator.compare(right.getEndKey(), left.getEndKey());
-<a class="jxr_linenumber" name="299" href="#299">299</a> 
-<a class="jxr_linenumber" name="300" href="#300">300</a>       <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="301" href="#301">301</a>     }
-<a class="jxr_linenumber" name="302" href="#302">302</a>   }
-<a class="jxr_linenumber" name="303" href="#303">303</a> 
-<a class="jxr_linenumber" name="304" href="#304">304</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="305" href="#305">305</a> <em class="jxr_javadoccomment">   * If daughters no longer hold reference to the parents, delete the parent.</em>
-<a class="jxr_linenumber" name="306" href="#306">306</a> <em class="jxr_javadoccomment">   * @param parent HRegionInfo of split offlined parent</em>
-<a class="jxr_linenumber" name="307" href="#307">307</a> <em class="jxr_javadoccomment">   * @param rowContent Content of &lt;code&gt;parent&lt;/code&gt; row in</em>
-<a class="jxr_linenumber" name="308" href="#308">308</a> <em class="jxr_javadoccomment">   * &lt;code&gt;metaRegionName&lt;/code&gt;</em>
-<a class="jxr_linenumber" name="309" href="#309">309</a> <em class="jxr_javadoccomment">   * @return True if we removed &lt;code&gt;parent&lt;/code&gt; from meta table and from</em>
-<a class="jxr_linenumber" name="310" href="#310">310</a> <em class="jxr_javadoccomment">   * the filesystem.</em>
-<a class="jxr_linenumber" name="311" href="#311">311</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
-<a class="jxr_linenumber" name="312" href="#312">312</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="313" href="#313">313</a>   <strong class="jxr_keyword">boolean</strong> cleanParent(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> parent, <a href="../../../../../org/apache/hadoop/hbase/client/Result.html">Result</a> rowContent)
-<a class="jxr_linenumber" name="314" href="#314">314</a>   <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="315" href="#315">315</a>     <strong class="jxr_keyword">boolean</strong> result = false;
-<a class="jxr_linenumber" name="316" href="#316">316</a>     <em class="jxr_comment">// Check whether it is a merged region and not clean reference</em>
-<a class="jxr_linenumber" name="317" href="#317">317</a>     <em class="jxr_comment">// No necessary to check MERGEB_QUALIFIER because these two qualifiers will</em>
-<a class="jxr_linenumber" name="318" href="#318">318</a>     <em class="jxr_comment">// be inserted/deleted together</em>
-<a class="jxr_linenumber" name="319" href="#319">319</a>     <strong class="jxr_keyword">if</strong> (rowContent.getValue(HConstants.CATALOG_FAMILY,
-<a class="jxr_linenumber" name="320" href="#320">320</a>         HConstants.MERGEA_QUALIFIER) != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="321" href="#321">321</a>       <em class="jxr_comment">// wait cleaning merge region first</em>
-<a class="jxr_linenumber" name="322" href="#322">322</a>       <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="323" href="#323">323</a>     }
-<a class="jxr_linenumber" name="324" href="#324">324</a>     <em class="jxr_comment">// Run checks on each daughter split.</em>
-<a class="jxr_linenumber" name="325" href="#325">325</a>     PairOfSameType&lt;HRegionInfo&gt; daughters = HRegionInfo.getDaughterRegions(rowContent);
-<a class="jxr_linenumber" name="326" href="#326">326</a>     Pair&lt;Boolean, Boolean&gt; a = checkDaughterInFs(parent, daughters.getFirst());
-<a class="jxr_linenumber" name="327" href="#327">327</a>     Pair&lt;Boolean, Boolean&gt; b = checkDaughterInFs(parent, daughters.getSecond());
-<a class="jxr_linenumber" name="328" href="#328">328</a>     <strong class="jxr_keyword">if</strong> (hasNoReferences(a) &amp;&amp; hasNoReferences(b)) {
-<a class="jxr_linenumber" name="329" href="#329">329</a>       LOG.debug(<span class="jxr_string">"Deleting region "</span> + parent.getRegionNameAsString() +
-<a class="jxr_linenumber" name="330" href="#330">330</a>         <span class="jxr_string">" because daughter splits no longer hold references"</span>);
-<a class="jxr_linenumber" name="331" href="#331">331</a>       FileSystem fs = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getFileSystem();
-<a class="jxr_linenumber" name="332" href="#332">332</a>       <strong class="jxr_keyword">if</strong> (LOG.isTraceEnabled()) LOG.trace(<span class="jxr_string">"Archiving parent region: "</span> + parent);
-<a class="jxr_linenumber" name="333" href="#333">333</a>       HFileArchiver.archiveRegion(<strong class="jxr_keyword">this</strong>.services.getConfiguration(), fs, parent);
-<a class="jxr_linenumber" name="334" href="#334">334</a>       MetaTableAccessor.deleteRegion(<strong class="jxr_keyword">this</strong>.connection, parent);
-<a class="jxr_linenumber" name="335" href="#335">335</a>       result = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="336" href="#336">336</a>     }
-<a class="jxr_linenumber" name="337" href="#337">337</a>     <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="338" href="#338">338</a>   }
-<a class="jxr_linenumber" name="339" href="#339">339</a> 
-<a class="jxr_linenumber" name="340" href="#340">340</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="341" href="#341">341</a> <em class="jxr_javadoccomment">   * @param p A pair where the first boolean says whether or not the daughter</em>
-<a class="jxr_linenumber" name="342" href="#342">342</a> <em class="jxr_javadoccomment">   * region directory exists in the filesystem and then the second boolean says</em>
-<a class="jxr_linenumber" name="343" href="#343">343</a> <em class="jxr_javadoccomment">   * whether the daughter has references to the parent.</em>
-<a class="jxr_linenumber" name="344" href="#344">344</a> <em class="jxr_javadoccomment">   * @return True the passed &lt;code&gt;p&lt;/code&gt; signifies no references.</em>
-<a class="jxr_linenumber" name="345" href="#345">345</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="346" href="#346">346</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> hasNoReferences(<strong class="jxr_keyword">final</strong> Pair&lt;Boolean, Boolean&gt; p) {
-<a class="jxr_linenumber" name="347" href="#347">347</a>     <strong class="jxr_keyword">return</strong> !p.getFirst() || !p.getSecond();
-<a class="jxr_linenumber" name="348" href="#348">348</a>   }
-<a class="jxr_linenumber" name="349" href="#349">349</a> 
-<a class="jxr_linenumber" name="350" href="#350">350</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="351" href="#351">351</a> <em class="jxr_javadoccomment">   * Checks if a daughter region -- either splitA or splitB -- still holds</em>
-<a class="jxr_linenumber" name="352" href="#352">352</a> <em class="jxr_javadoccomment">   * references to parent.</em>
-<a class="jxr_linenumber" name="353" href="#353">353</a> <em class="jxr_javadoccomment">   * @param parent Parent region</em>
-<a class="jxr_linenumber" name="354" href="#354">354</a> <em class="jxr_javadoccomment">   * @param daughter Daughter region</em>
-<a class="jxr_linenumber" name="355" href="#355">355</a> <em class="jxr_javadoccomment">   * @return A pair where the first boolean says whether or not the daughter</em>
-<a class="jxr_linenumber" name="356" href="#356">356</a> <em class="jxr_javadoccomment">   * region directory exists in the filesystem and then the second boolean says</em>
-<a class="jxr_linenumber" name="357" href="#357">357</a> <em class="jxr_javadoccomment">   * whether the daughter has references to the parent.</em>
-<a class="jxr_linenumber" name="358" href="#358">358</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
-<a class="jxr_linenumber" name="359" href="#359">359</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="360" href="#360">360</a>   Pair&lt;Boolean, Boolean&gt; checkDaughterInFs(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> parent, <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> daughter)
-<a class="jxr_linenumber" name="361" href="#361">361</a>   <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="362" href="#362">362</a>     <strong class="jxr_keyword">if</strong> (daughter == <strong class="jxr_keyword">null</strong>)  {
-<a class="jxr_linenumber" name="363" href="#363">363</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.FALSE, Boolean.FALSE);
-<a class="jxr_linenumber" name="364" href="#364">364</a>     }
-<a class="jxr_linenumber" name="365" href="#365">365</a> 
-<a class="jxr_linenumber" name="366" href="#366">366</a>     FileSystem fs = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getFileSystem();
-<a class="jxr_linenumber" name="367" href="#367">367</a>     Path rootdir = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getRootDir();
-<a class="jxr_linenumber" name="368" href="#368">368</a>     Path tabledir = FSUtils.getTableDir(rootdir, daughter.getTable());
-<a class="jxr_linenumber" name="369" href="#369">369</a> 
-<a class="jxr_linenumber" name="370" href="#370">370</a>     Path daughterRegionDir = <strong class="jxr_keyword">new</strong> Path(tabledir, daughter.getEncodedName());
-<a class="jxr_linenumber" name="371" href="#371">371</a> 
-<a class="jxr_linenumber" name="372" href="#372">372</a>     <a href="../../../../../org/apache/hadoop/hbase/regionserver/HRegionFileSystem.html">HRegionFileSystem</a> regionFs = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="373" href="#373">373</a> 
-<a class="jxr_linenumber" name="374" href="#374">374</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="375" href="#375">375</a>       <strong class="jxr_keyword">if</strong> (!FSUtils.isExists(fs, daughterRegionDir)) {
-<a class="jxr_linenumber" name="376" href="#376">376</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.FALSE, Boolean.FALSE);
-<a class="jxr_linenumber" name="377" href="#377">377</a>       }
-<a class="jxr_linenumber" name="378" href="#378">378</a>     } <strong class="jxr_keyword">catch</strong> (IOException ioe) {
-<a class="jxr_linenumber" name="379" href="#379">379</a>       LOG.warn(<span class="jxr_string">"Error trying to determine if daughter region exists, "</span> +
-<a class="jxr_linenumber" name="380" href="#380">380</a>                <span class="jxr_string">"assuming exists and has references"</span>, ioe);
-<a class="jxr_linenumber" name="381" href="#381">381</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.TRUE);
-<a class="jxr_linenumber" name="382" href="#382">382</a>     }
-<a class="jxr_linenumber" name="383" href="#383">383</a> 
-<a class="jxr_linenumber" name="384" href="#384">384</a>     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="385" href="#385">385</a>       regionFs = HRegionFileSystem.openRegionFromFileSystem(
-<a class="jxr_linenumber" name="386" href="#386">386</a>           <strong class="jxr_keyword">this</strong>.services.getConfiguration(), fs, tabledir, daughter, <strong class="jxr_keyword">true</strong>);
-<a class="jxr_linenumber" name="387" href="#387">387</a>     } <strong class="jxr_keyword">catch</strong> (IOException e) {
-<a class="jxr_linenumber" name="388" href="#388">388</a>       LOG.warn(<span class="jxr_string">"Error trying to determine referenced files from : "</span> + daughter.getEncodedName()
-<a class="jxr_linenumber" name="389" href="#389">389</a>           + <span class="jxr_string">", to: "</span> + parent.getEncodedName() + <span class="jxr_string">" assuming has references"</span>, e);
-<a class="jxr_linenumber" name="390" href="#390">390</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.TRUE);
-<a class="jxr_linenumber" name="391" href="#391">391</a>     }
-<a class="jxr_linenumber" name="392" href="#392">392</a> 
-<a class="jxr_linenumber" name="393" href="#393">393</a>     <strong class="jxr_keyword">boolean</strong> references = false;
-<a class="jxr_linenumber" name="394" href="#394">394</a>     <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a> parentDescriptor = getTableDescriptor(parent.getTable());
-<a class="jxr_linenumber" name="395" href="#395">395</a>     <strong class="jxr_keyword">for</strong> (HColumnDescriptor family: parentDescriptor.getFamilies()) {
-<a class="jxr_linenumber" name="396" href="#396">396</a>       <strong class="jxr_keyword">if</strong> ((references = regionFs.hasReferences(family.getNameAsString()))) {
-<a class="jxr_linenumber" name="397" href="#397">397</a>         <strong class="jxr_keyword">break</strong>;
-<a class="jxr_linenumber" name="398" href="#398">398</a>       }
-<a class="jxr_linenumber" name="399" href="#399">399</a>     }
-<a class="jxr_linenumber" name="400" href="#400">400</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.valueOf(references));
-<a class="jxr_linenumber" name="401" href="#401">401</a>   }
-<a class="jxr_linenumber" name="402" href="#402">402</a> 
-<a class="jxr_linenumber" name="403" href="#403">403</a>   <strong class="jxr_keyword">private</strong> <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a> getTableDescriptor(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName)
-<a class="jxr_linenumber" name="404" href="#404">404</a>       <strong class="jxr_keyword">throws</strong> FileNotFoundException, IOException {
-<a class="jxr_linenumber" name="405" href="#405">405</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.services.getTableDescriptors().get(tableName);
-<a class="jxr_linenumber" name="406" href="#406">406</a>   }
-<a class="jxr_linenumber" name="407" href="#407">407</a> 
-<a class="jxr_linenumber" name="408" href="#408">408</a>   <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="409" href="#409">409</a> <em class="jxr_javadoccomment">   * Checks if the specified region has merge qualifiers, if so, try to clean</em>
-<a class="jxr_linenumber" name="410" href="#410">410</a> <em class="jxr_javadoccomment">   * them</em>
-<a class="jxr_linenumber" name="411" href="#411">411</a> <em class="jxr_javadoccomment">   * @param region</em>
-<a class="jxr_linenumber" name="412" href="#412">412</a> <em class="jxr_javadoccomment">   * @return true if the specified region doesn't have merge qualifier now</em>
-<a class="jxr_linenumber" name="413" href="#413">413</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
-<a class="jxr_linenumber" name="414" href="#414">414</a> <em class="jxr_javadoccomment">   */</em>
-<a class="jxr_linenumber" name="415" href="#415">415</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> cleanMergeQualifier(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> region)
-<a class="jxr_linenumber" name="416" href="#416">416</a>       <strong class="jxr_keyword">throws</strong> IOException {
-<a class="jxr_linenumber" name="417" href="#417">417</a>     <em class="jxr_comment">// Get merge regions if it is a merged region and already has merge</em>
-<a class="jxr_linenumber" name="418" href="#418">418</a>     <em class="jxr_comment">// qualifier</em>
-<a class="jxr_linenumber" name="419" href="#419">419</a>     Pair&lt;HRegionInfo, HRegionInfo&gt; mergeRegions = <a href="../../../../../org/apache/hadoop/hbase/MetaTableAccessor.html">MetaTableAccessor</a>
-<a class="jxr_linenumber" name="420" href="#420">420</a>         .getRegionsFromMergeQualifier(<strong class="jxr_keyword">this</strong>.services.getConnection(),
-<a class="jxr_linenumber" name="421" href="#421">421</a>           region.getRegionName());
-<a class="jxr_linenumber" name="422" href="#422">422</a>     <strong class="jxr_keyword">if</strong> (mergeRegions == <strong class="jxr_keyword">null</strong>
-<a class="jxr_linenumber" name="423" href="#423">423</a>         || (mergeRegions.getFirst() == <strong class="jxr_keyword">null</strong> &amp;&amp; mergeRegions.getSecond() == <strong class="jxr_keyword">null</strong>)) {
-<a class="jxr_linenumber" name="424" href="#424">424</a>       <em class="jxr_comment">// It doesn't have merge qualifier, no need to clean</em>
-<a class="jxr_linenumber" name="425" href="#425">425</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="426" href="#426">426</a>     }
-<a class="jxr_linenumber" name="427" href="#427">427</a>     <em class="jxr_comment">// It shouldn't happen, we must insert/delete these two qualifiers together</em>
-<a class="jxr_linenumber" name="428" href="#428">428</a>     <strong class="jxr_keyword">if</strong> (mergeRegions.getFirst() == <strong class="jxr_keyword">null</strong> || mergeRegions.getSecond() == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="429" href="#429">429</a>       LOG.error(<span class="jxr_string">"Merged region "</span> + region.getRegionNameAsString()
-<a class="jxr_linenumber" name="430" href="#430">430</a>           + <span class="jxr_string">" has only one merge qualifier in META."</span>);
-<a class="jxr_linenumber" name="431" href="#431">431</a>       <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="432" href="#432">432</a>     }
-<a class="jxr_linenumber" name="433" href="#433">433</a>     <strong class="jxr_keyword">return</strong> cleanMergeRegion(region, mergeRegions.getFirst(),
-<a class="jxr_linenumber" name="434" href="#434">434</a>         mergeRegions.getSecond());
-<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="228" href="#228">228</a>         PairOfSameType&lt;HRegionInfo&gt; p = MetaTableAccessor.getMergeRegions(e.getValue());
+<a class="jxr_linenumber" name="229" href="#229">229</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> regionA = p.getFirst();
+<a class="jxr_linenumber" name="230" href="#230">230</a>         <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> regionB = p.getSecond();
+<a class="jxr_linenumber" name="231" href="#231">231</a>         <strong class="jxr_keyword">if</strong> (regionA == <strong class="jxr_keyword">null</strong> || regionB == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="232" href="#232">232</a>           LOG.warn(<span class="jxr_string">"Unexpected references regionA="</span>
+<a class="jxr_linenumber" name="233" href="#233">233</a>               + (regionA == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">"null"</span> : regionA.getRegionNameAsString())
+<a class="jxr_linenumber" name="234" href="#234">234</a>               + <span class="jxr_string">",regionB="</span>
+<a class="jxr_linenumber" name="235" href="#235">235</a>               + (regionB == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">"null"</span> : regionB.getRegionNameAsString())
+<a class="jxr_linenumber" name="236" href="#236">236</a>               + <span class="jxr_string">" in merged region "</span> + e.getKey().getRegionNameAsString());
+<a class="jxr_linenumber" name="237" href="#237">237</a>         } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="238" href="#238">238</a>           <strong class="jxr_keyword">if</strong> (cleanMergeRegion(e.getKey(), regionA, regionB)) {
+<a class="jxr_linenumber" name="239" href="#239">239</a>             mergeCleaned++;
+<a class="jxr_linenumber" name="240" href="#240">240</a>           }
+<a class="jxr_linenumber" name="241" href="#241">241</a>         }
+<a class="jxr_linenumber" name="242" href="#242">242</a>       }
+<a class="jxr_linenumber" name="243" href="#243">243</a>       <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="244" href="#244">244</a> <em class="jxr_javadoccomment">       * clean split parents</em>
+<a class="jxr_linenumber" name="245" href="#245">245</a> <em class="jxr_javadoccomment">       */</em>
+<a class="jxr_linenumber" name="246" href="#246">246</a>       Map&lt;HRegionInfo, Result&gt; splitParents = scanTriple.getThird();
+<a class="jxr_linenumber" name="247" href="#247">247</a> 
+<a class="jxr_linenumber" name="248" href="#248">248</a>       <em class="jxr_comment">// Now work on our list of found parents. See if any we can clean up.</em>
+<a class="jxr_linenumber" name="249" href="#249">249</a>       <strong class="jxr_keyword">int</strong> splitCleaned = 0;
+<a class="jxr_linenumber" name="250" href="#250">250</a>       <em class="jxr_comment">// regions whose parents are still around</em>
+<a class="jxr_linenumber" name="251" href="#251">251</a>       HashSet&lt;String&gt; parentNotCleaned = <strong class="jxr_keyword">new</strong> HashSet&lt;String&gt;();
+<a class="jxr_linenumber" name="252" href="#252">252</a>       <strong class="jxr_keyword">for</strong> (Map.Entry&lt;HRegionInfo, Result&gt; e : splitParents.entrySet()) {
+<a class="jxr_linenumber" name="253" href="#253">253</a>         <strong class="jxr_keyword">if</strong> (!parentNotCleaned.contains(e.getKey().getEncodedName()) &amp;&amp;
+<a class="jxr_linenumber" name="254" href="#254">254</a>             cleanParent(e.getKey(), e.getValue())) {
+<a class="jxr_linenumber" name="255" href="#255">255</a>           splitCleaned++;
+<a class="jxr_linenumber" name="256" href="#256">256</a>         } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="257" href="#257">257</a>           <em class="jxr_comment">// We could not clean the parent, so it's daughters should not be</em>
+<a class="jxr_linenumber" name="258" href="#258">258</a>           <em class="jxr_comment">// cleaned either (HBASE-6160)</em>
+<a class="jxr_linenumber" name="259" href="#259">259</a>           PairOfSameType&lt;HRegionInfo&gt; daughters =
+<a class="jxr_linenumber" name="260" href="#260">260</a>               MetaTableAccessor.getDaughterRegions(e.getValue());
+<a class="jxr_linenumber" name="261" href="#261">261</a>           parentNotCleaned.add(daughters.getFirst().getEncodedName());
+<a class="jxr_linenumber" name="262" href="#262">262</a>           parentNotCleaned.add(daughters.getSecond().getEncodedName());
+<a class="jxr_linenumber" name="263" href="#263">263</a>         }
+<a class="jxr_linenumber" name="264" href="#264">264</a>       }
+<a class="jxr_linenumber" name="265" href="#265">265</a>       <strong class="jxr_keyword">if</strong> ((mergeCleaned + splitCleaned) != 0) {
+<a class="jxr_linenumber" name="266" href="#266">266</a>         LOG.info(<span class="jxr_string">"Scanned "</span> + count + <span class="jxr_string">" catalog row(s), gc'd "</span> + mergeCleaned
+<a class="jxr_linenumber" name="267" href="#267">267</a>             + <span class="jxr_string">" unreferenced merged region(s) and "</span> + splitCleaned
+<a class="jxr_linenumber" name="268" href="#268">268</a>             + <span class="jxr_string">" unreferenced parent region(s)"</span>);
+<a class="jxr_linenumber" name="269" href="#269">269</a>       } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (LOG.isTraceEnabled()) {
+<a class="jxr_linenumber" name="270" href="#270">270</a>         LOG.trace(<span class="jxr_string">"Scanned "</span> + count + <span class="jxr_string">" catalog row(s), gc'd "</span> + mergeCleaned
+<a class="jxr_linenumber" name="271" href="#271">271</a>             + <span class="jxr_string">" unreferenced merged region(s) and "</span> + splitCleaned
+<a class="jxr_linenumber" name="272" href="#272">272</a>             + <span class="jxr_string">" unreferenced parent region(s)"</span>);
+<a class="jxr_linenumber" name="273" href="#273">273</a>       }
+<a class="jxr_linenumber" name="274" href="#274">274</a>       <strong class="jxr_keyword">return</strong> mergeCleaned + splitCleaned;
+<a class="jxr_linenumber" name="275" href="#275">275</a>     } <strong class="jxr_keyword">finally</strong> {
+<a class="jxr_linenumber" name="276" href="#276">276</a>       alreadyRunning.set(false);
+<a class="jxr_linenumber" name="277" href="#277">277</a>     }
+<a class="jxr_linenumber" name="278" href="#278">278</a>   }
+<a class="jxr_linenumber" name="279" href="#279">279</a> 
+<a class="jxr_linenumber" name="280" href="#280">280</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="281" href="#281">281</a> <em class="jxr_javadoccomment">   * Compare HRegionInfos in a way that has split parents sort BEFORE their</em>
+<a class="jxr_linenumber" name="282" href="#282">282</a> <em class="jxr_javadoccomment">   * daughters.</em>
+<a class="jxr_linenumber" name="283" href="#283">283</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="284" href="#284">284</a>   <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/hadoop/hbase/master/CatalogJanitor.html">SplitParentFirstComparator</a> <strong class="jxr_keyword">implements</strong> Comparator&lt;HRegionInfo&gt; {
+<a class="jxr_linenumber" name="285" href="#285">285</a>     Comparator&lt;byte[]&gt; rowEndKeyComparator = <strong class="jxr_keyword">new</strong> Bytes.RowEndKeyComparator();
+<a class="jxr_linenumber" name="286" href="#286">286</a>     @Override
+<a class="jxr_linenumber" name="287" href="#287">287</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> left, <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> right) {
+<a class="jxr_linenumber" name="288" href="#288">288</a>       <em class="jxr_comment">// This comparator differs from the one HRegionInfo in that it sorts</em>
+<a class="jxr_linenumber" name="289" href="#289">289</a>       <em class="jxr_comment">// parent before daughters.</em>
+<a class="jxr_linenumber" name="290" href="#290">290</a>       <strong class="jxr_keyword">if</strong> (left == <strong class="jxr_keyword">null</strong>) <strong class="jxr_keyword">return</strong> -1;
+<a class="jxr_linenumber" name="291" href="#291">291</a>       <strong class="jxr_keyword">if</strong> (right == <strong class="jxr_keyword">null</strong>) <strong class="jxr_keyword">return</strong> 1;
+<a class="jxr_linenumber" name="292" href="#292">292</a>       <em class="jxr_comment">// Same table name.</em>
+<a class="jxr_linenumber" name="293" href="#293">293</a>       <strong class="jxr_keyword">int</strong> result = left.getTable().compareTo(right.getTable());
+<a class="jxr_linenumber" name="294" href="#294">294</a>       <strong class="jxr_keyword">if</strong> (result != 0) <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="295" href="#295">295</a>       <em class="jxr_comment">// Compare start keys.</em>
+<a class="jxr_linenumber" name="296" href="#296">296</a>       result = Bytes.compareTo(left.getStartKey(), right.getStartKey());
+<a class="jxr_linenumber" name="297" href="#297">297</a>       <strong class="jxr_keyword">if</strong> (result != 0) <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="298" href="#298">298</a>       <em class="jxr_comment">// Compare end keys, but flip the operands so parent comes first</em>
+<a class="jxr_linenumber" name="299" href="#299">299</a>       result = rowEndKeyComparator.compare(right.getEndKey(), left.getEndKey());
+<a class="jxr_linenumber" name="300" href="#300">300</a> 
+<a class="jxr_linenumber" name="301" href="#301">301</a>       <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="302" href="#302">302</a>     }
+<a class="jxr_linenumber" name="303" href="#303">303</a>   }
+<a class="jxr_linenumber" name="304" href="#304">304</a> 
+<a class="jxr_linenumber" name="305" href="#305">305</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="306" href="#306">306</a> <em class="jxr_javadoccomment">   * If daughters no longer hold reference to the parents, delete the parent.</em>
+<a class="jxr_linenumber" name="307" href="#307">307</a> <em class="jxr_javadoccomment">   * @param parent HRegionInfo of split offlined parent</em>
+<a class="jxr_linenumber" name="308" href="#308">308</a> <em class="jxr_javadoccomment">   * @param rowContent Content of &lt;code&gt;parent&lt;/code&gt; row in</em>
+<a class="jxr_linenumber" name="309" href="#309">309</a> <em class="jxr_javadoccomment">   * &lt;code&gt;metaRegionName&lt;/code&gt;</em>
+<a class="jxr_linenumber" name="310" href="#310">310</a> <em class="jxr_javadoccomment">   * @return True if we removed &lt;code&gt;parent&lt;/code&gt; from meta table and from</em>
+<a class="jxr_linenumber" name="311" href="#311">311</a> <em class="jxr_javadoccomment">   * the filesystem.</em>
+<a class="jxr_linenumber" name="312" href="#312">312</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
+<a class="jxr_linenumber" name="313" href="#313">313</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="314" href="#314">314</a>   <strong class="jxr_keyword">boolean</strong> cleanParent(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> parent, <a href="../../../../../org/apache/hadoop/hbase/client/Result.html">Result</a> rowContent)
+<a class="jxr_linenumber" name="315" href="#315">315</a>   <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="316" href="#316">316</a>     <strong class="jxr_keyword">boolean</strong> result = false;
+<a class="jxr_linenumber" name="317" href="#317">317</a>     <em class="jxr_comment">// Check whether it is a merged region and not clean reference</em>
+<a class="jxr_linenumber" name="318" href="#318">318</a>     <em class="jxr_comment">// No necessary to check MERGEB_QUALIFIER because these two qualifiers will</em>
+<a class="jxr_linenumber" name="319" href="#319">319</a>     <em class="jxr_comment">// be inserted/deleted together</em>
+<a class="jxr_linenumber" name="320" href="#320">320</a>     <strong class="jxr_keyword">if</strong> (rowContent.getValue(HConstants.CATALOG_FAMILY,
+<a class="jxr_linenumber" name="321" href="#321">321</a>         HConstants.MERGEA_QUALIFIER) != <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="322" href="#322">322</a>       <em class="jxr_comment">// wait cleaning merge region first</em>
+<a class="jxr_linenumber" name="323" href="#323">323</a>       <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="324" href="#324">324</a>     }
+<a class="jxr_linenumber" name="325" href="#325">325</a>     <em class="jxr_comment">// Run checks on each daughter split.</em>
+<a class="jxr_linenumber" name="326" href="#326">326</a>     PairOfSameType&lt;HRegionInfo&gt; daughters = MetaTableAccessor.getDaughterRegions(rowContent);
+<a class="jxr_linenumber" name="327" href="#327">327</a>     Pair&lt;Boolean, Boolean&gt; a = checkDaughterInFs(parent, daughters.getFirst());
+<a class="jxr_linenumber" name="328" href="#328">328</a>     Pair&lt;Boolean, Boolean&gt; b = checkDaughterInFs(parent, daughters.getSecond());
+<a class="jxr_linenumber" name="329" href="#329">329</a>     <strong class="jxr_keyword">if</strong> (hasNoReferences(a) &amp;&amp; hasNoReferences(b)) {
+<a class="jxr_linenumber" name="330" href="#330">330</a>       LOG.debug(<span class="jxr_string">"Deleting region "</span> + parent.getRegionNameAsString() +
+<a class="jxr_linenumber" name="331" href="#331">331</a>         <span class="jxr_string">" because daughter splits no longer hold references"</span>);
+<a class="jxr_linenumber" name="332" href="#332">332</a>       FileSystem fs = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getFileSystem();
+<a class="jxr_linenumber" name="333" href="#333">333</a>       <strong class="jxr_keyword">if</strong> (LOG.isTraceEnabled()) LOG.trace(<span class="jxr_string">"Archiving parent region: "</span> + parent);
+<a class="jxr_linenumber" name="334" href="#334">334</a>       HFileArchiver.archiveRegion(<strong class="jxr_keyword">this</strong>.services.getConfiguration(), fs, parent);
+<a class="jxr_linenumber" name="335" href="#335">335</a>       MetaTableAccessor.deleteRegion(<strong class="jxr_keyword">this</strong>.connection, parent);
+<a class="jxr_linenumber" name="336" href="#336">336</a>       result = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="337" href="#337">337</a>     }
+<a class="jxr_linenumber" name="338" href="#338">338</a>     <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="339" href="#339">339</a>   }
+<a class="jxr_linenumber" name="340" href="#340">340</a> 
+<a class="jxr_linenumber" name="341" href="#341">341</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="342" href="#342">342</a> <em class="jxr_javadoccomment">   * @param p A pair where the first boolean says whether or not the daughter</em>
+<a class="jxr_linenumber" name="343" href="#343">343</a> <em class="jxr_javadoccomment">   * region directory exists in the filesystem and then the second boolean says</em>
+<a class="jxr_linenumber" name="344" href="#344">344</a> <em class="jxr_javadoccomment">   * whether the daughter has references to the parent.</em>
+<a class="jxr_linenumber" name="345" href="#345">345</a> <em class="jxr_javadoccomment">   * @return True the passed &lt;code&gt;p&lt;/code&gt; signifies no references.</em>
+<a class="jxr_linenumber" name="346" href="#346">346</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="347" href="#347">347</a>   <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> hasNoReferences(<strong class="jxr_keyword">final</strong> Pair&lt;Boolean, Boolean&gt; p) {
+<a class="jxr_linenumber" name="348" href="#348">348</a>     <strong class="jxr_keyword">return</strong> !p.getFirst() || !p.getSecond();
+<a class="jxr_linenumber" name="349" href="#349">349</a>   }
+<a class="jxr_linenumber" name="350" href="#350">350</a> 
+<a class="jxr_linenumber" name="351" href="#351">351</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="352" href="#352">352</a> <em class="jxr_javadoccomment">   * Checks if a daughter region -- either splitA or splitB -- still holds</em>
+<a class="jxr_linenumber" name="353" href="#353">353</a> <em class="jxr_javadoccomment">   * references to parent.</em>
+<a class="jxr_linenumber" name="354" href="#354">354</a> <em class="jxr_javadoccomment">   * @param parent Parent region</em>
+<a class="jxr_linenumber" name="355" href="#355">355</a> <em class="jxr_javadoccomment">   * @param daughter Daughter region</em>
+<a class="jxr_linenumber" name="356" href="#356">356</a> <em class="jxr_javadoccomment">   * @return A pair where the first boolean says whether or not the daughter</em>
+<a class="jxr_linenumber" name="357" href="#357">357</a> <em class="jxr_javadoccomment">   * region directory exists in the filesystem and then the second boolean says</em>
+<a class="jxr_linenumber" name="358" href="#358">358</a> <em class="jxr_javadoccomment">   * whether the daughter has references to the parent.</em>
+<a class="jxr_linenumber" name="359" href="#359">359</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
+<a class="jxr_linenumber" name="360" href="#360">360</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="361" href="#361">361</a>   Pair&lt;Boolean, Boolean&gt; checkDaughterInFs(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> parent, <strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> daughter)
+<a class="jxr_linenumber" name="362" href="#362">362</a>   <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="363" href="#363">363</a>     <strong class="jxr_keyword">if</strong> (daughter == <strong class="jxr_keyword">null</strong>)  {
+<a class="jxr_linenumber" name="364" href="#364">364</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.FALSE, Boolean.FALSE);
+<a class="jxr_linenumber" name="365" href="#365">365</a>     }
+<a class="jxr_linenumber" name="366" href="#366">366</a> 
+<a class="jxr_linenumber" name="367" href="#367">367</a>     FileSystem fs = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getFileSystem();
+<a class="jxr_linenumber" name="368" href="#368">368</a>     Path rootdir = <strong class="jxr_keyword">this</strong>.services.getMasterFileSystem().getRootDir();
+<a class="jxr_linenumber" name="369" href="#369">369</a>     Path tabledir = FSUtils.getTableDir(rootdir, daughter.getTable());
+<a class="jxr_linenumber" name="370" href="#370">370</a> 
+<a class="jxr_linenumber" name="371" href="#371">371</a>     Path daughterRegionDir = <strong class="jxr_keyword">new</strong> Path(tabledir, daughter.getEncodedName());
+<a class="jxr_linenumber" name="372" href="#372">372</a> 
+<a class="jxr_linenumber" name="373" href="#373">373</a>     <a href="../../../../../org/apache/hadoop/hbase/regionserver/HRegionFileSystem.html">HRegionFileSystem</a> regionFs = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="374" href="#374">374</a> 
+<a class="jxr_linenumber" name="375" href="#375">375</a>     <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="376" href="#376">376</a>       <strong class="jxr_keyword">if</strong> (!FSUtils.isExists(fs, daughterRegionDir)) {
+<a class="jxr_linenumber" name="377" href="#377">377</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.FALSE, Boolean.FALSE);
+<a class="jxr_linenumber" name="378" href="#378">378</a>       }
+<a class="jxr_linenumber" name="379" href="#379">379</a>     } <strong class="jxr_keyword">catch</strong> (IOException ioe) {
+<a class="jxr_linenumber" name="380" href="#380">380</a>       LOG.warn(<span class="jxr_string">"Error trying to determine if daughter region exists, "</span> +
+<a class="jxr_linenumber" name="381" href="#381">381</a>                <span class="jxr_string">"assuming exists and has references"</span>, ioe);
+<a class="jxr_linenumber" name="382" href="#382">382</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.TRUE);
+<a class="jxr_linenumber" name="383" href="#383">383</a>     }
+<a class="jxr_linenumber" name="384" href="#384">384</a> 
+<a class="jxr_linenumber" name="385" href="#385">385</a>     <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="386" href="#386">386</a>       regionFs = HRegionFileSystem.openRegionFromFileSystem(
+<a class="jxr_linenumber" name="387" href="#387">387</a>           <strong class="jxr_keyword">this</strong>.services.getConfiguration(), fs, tabledir, daughter, <strong class="jxr_keyword">true</strong>);
+<a class="jxr_linenumber" name="388" href="#388">388</a>     } <strong class="jxr_keyword">catch</strong> (IOException e) {
+<a class="jxr_linenumber" name="389" href="#389">389</a>       LOG.warn(<span class="jxr_string">"Error trying to determine referenced files from : "</span> + daughter.getEncodedName()
+<a class="jxr_linenumber" name="390" href="#390">390</a>           + <span class="jxr_string">", to: "</span> + parent.getEncodedName() + <span class="jxr_string">" assuming has references"</span>, e);
+<a class="jxr_linenumber" name="391" href="#391">391</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.TRUE);
+<a class="jxr_linenumber" name="392" href="#392">392</a>     }
+<a class="jxr_linenumber" name="393" href="#393">393</a> 
+<a class="jxr_linenumber" name="394" href="#394">394</a>     <strong class="jxr_keyword">boolean</strong> references = false;
+<a class="jxr_linenumber" name="395" href="#395">395</a>     <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a> parentDescriptor = getTableDescriptor(parent.getTable());
+<a class="jxr_linenumber" name="396" href="#396">396</a>     <strong class="jxr_keyword">for</strong> (HColumnDescriptor family: parentDescriptor.getFamilies()) {
+<a class="jxr_linenumber" name="397" href="#397">397</a>       <strong class="jxr_keyword">if</strong> ((references = regionFs.hasReferences(family.getNameAsString()))) {
+<a class="jxr_linenumber" name="398" href="#398">398</a>         <strong class="jxr_keyword">break</strong>;
+<a class="jxr_linenumber" name="399" href="#399">399</a>       }
+<a class="jxr_linenumber" name="400" href="#400">400</a>     }
+<a class="jxr_linenumber" name="401" href="#401">401</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Pair&lt;Boolean, Boolean&gt;(Boolean.TRUE, Boolean.valueOf(references));
+<a class="jxr_linenumber" name="402" href="#402">402</a>   }
+<a class="jxr_linenumber" name="403" href="#403">403</a> 
+<a class="jxr_linenumber" name="404" href="#404">404</a>   <strong class="jxr_keyword">private</strong> <a href="../../../../../org/apache/hadoop/hbase/HTableDescriptor.html">HTableDescriptor</a> getTableDescriptor(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/TableName.html">TableName</a> tableName)
+<a class="jxr_linenumber" name="405" href="#405">405</a>       <strong class="jxr_keyword">throws</strong> FileNotFoundException, IOException {
+<a class="jxr_linenumber" name="406" href="#406">406</a>     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.services.getTableDescriptors().get(tableName);
+<a class="jxr_linenumber" name="407" href="#407">407</a>   }
+<a class="jxr_linenumber" name="408" href="#408">408</a> 
+<a class="jxr_linenumber" name="409" href="#409">409</a>   <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="410" href="#410">410</a> <em class="jxr_javadoccomment">   * Checks if the specified region has merge qualifiers, if so, try to clean</em>
+<a class="jxr_linenumber" name="411" href="#411">411</a> <em class="jxr_javadoccomment">   * them</em>
+<a class="jxr_linenumber" name="412" href="#412">412</a> <em class="jxr_javadoccomment">   * @param region</em>
+<a class="jxr_linenumber" name="413" href="#413">413</a> <em class="jxr_javadoccomment">   * @return true if the specified region doesn't have merge qualifier now</em>
+<a class="jxr_linenumber" name="414" href="#414">414</a> <em class="jxr_javadoccomment">   * @throws IOException</em>
+<a class="jxr_linenumber" name="415" href="#415">415</a> <em class="jxr_javadoccomment">   */</em>
+<a class="jxr_linenumber" name="416" href="#416">416</a>   <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> cleanMergeQualifier(<strong class="jxr_keyword">final</strong> <a href="../../../../../org/apache/hadoop/hbase/HRegionInfo.html">HRegionInfo</a> region)
+<a class="jxr_linenumber" name="417" href="#417">417</a>       <strong class="jxr_keyword">throws</strong> IOException {
+<a class="jxr_linenumber" name="418" href="#418">418</a>     <em class="jxr_comment">// Get merge regions if it is a merged region and already has merge</em>
+<a class="jxr_linenumber" name="419" href="#419">419</a>     <em class="jxr_comment">// qualifier</em>
+<a class="jxr_linenumber" name="420" href="#420">420</a>     Pair&lt;HRegionInfo, HRegionInfo&gt; mergeRegions = <a href="../../../../../org/apache/hadoop/hbase/MetaTableAccessor.html">MetaTableAccessor</a>
+<a class="jxr_linenumber" name="421" href="#421">421</a>         .getRegionsFromMergeQualifier(<strong class="jxr_keyword">this</strong>.services.getConnection(),
+<a class="jxr_linenumber" name="422" href="#422">422</a>           region.getRegionName());
+<a class="jxr_linenumber" name="423" href="#423">423</a>     <strong class="jxr_keyword">if</strong> (mergeRegions == <strong class="jxr_keyword">null</strong>
+<a class="jxr_linenumber" name="424" href="#424">424</a>         || (mergeRegions.getFirst() == <strong class="jxr_keyword">null</strong> &amp;&amp; mergeRegions.getSecond() == <strong class="jxr_keyword">null</strong>)) {
+<a class="jxr_linenumber" name="425" href="#425">425</a>       <em class="jxr_comment">// It doesn't have merge qualifier, no need to clean</em>
+<a class="jxr_linenumber" name="426" href="#426">426</a>       <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="427" href="#427">427</a>     }
+<a class="jxr_linenumber" name="428" href="#428">428</a>     <em class="jxr_comment">// It shouldn't happen, we must insert/delete these two qualifiers together</em>
+<a class="jxr_linenumber" name="429" href="#429">429</a>     <strong class="jxr_keyword">if</strong> (mergeRegions.getFirst() == <strong class="jxr_keyword">null</strong> || mergeRegions.getSecond() == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="430" href="#430">430</a>       LOG.error(<span class="jxr_string">"Merged region "</span> + region.getRegionNameAsString()
+<a class="jxr_linenumber" name="431" href="#431">431</a>           + <span class="jxr_string">" has only one merge qualifier in META."</span>);
+<a class="jxr_linenumber" name="432" href="#432">432</a>       <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="433" href="#433">433</a>     }
+<a class="jxr_linenumber" name="434" href="#434">434</a>     <strong class="jxr_keyword">return</strong> cleanMergeRegion(region, mergeRegions.getFirst(),
+<a class="jxr_linenumber" name="435" href="#435">435</a>         mergeRegions.getSecond());
+<a class="jxr_linenumber" name="436" href="#436">436</a>   }
+<a class="jxr_linenumber" name="437" href="#437">437</a> }
 </pre>
 <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
 </html>



Mime
View raw message