hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [12/32] hbase-site git commit: Published site at a07e755625382d3904c935c21a4f240ede6d2f43.
Date Mon, 13 Aug 2018 14:49:45 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/75e49c45/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.PlanComparator.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.PlanComparator.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.PlanComparator.html
index 9267f53..c688159 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.PlanComparator.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.PlanComparator.html
@@ -26,213 +26,239 @@
 <span class="sourceLineNo">018</span> */<a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.master.normalizer;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.ArrayList;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.Collections;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.Comparator;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HBaseIOException;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.RegionMetrics;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.ServerName;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.Size;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.TableName;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.client.MasterSwitchType;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.master.MasterRpcServices;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.master.normalizer.NormalizationPlan.PlanType;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.slf4j.Logger;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.slf4j.LoggerFactory;<a name="line.38"></a>
-<span class="sourceLineNo">039</span><a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.40"></a>
+<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.ArrayList;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.util.Collections;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.Comparator;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.List;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HBaseIOException;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.RegionMetrics;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.ServerName;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.Size;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.TableName;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.MasterSwitchType;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.master.MasterRpcServices;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.master.normalizer.NormalizationPlan.PlanType;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.slf4j.Logger;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.slf4j.LoggerFactory;<a name="line.40"></a>
 <span class="sourceLineNo">041</span><a name="line.41"></a>
-<span class="sourceLineNo">042</span>/**<a name="line.42"></a>
-<span class="sourceLineNo">043</span> * Simple implementation of region normalizer.<a name="line.43"></a>
-<span class="sourceLineNo">044</span> *<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * Logic in use:<a name="line.45"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>/**<a name="line.44"></a>
+<span class="sourceLineNo">045</span> * Simple implementation of region normalizer.<a name="line.45"></a>
 <span class="sourceLineNo">046</span> *<a name="line.46"></a>
-<span class="sourceLineNo">047</span> *  &lt;ol&gt;<a name="line.47"></a>
-<span class="sourceLineNo">048</span> *  &lt;li&gt; Get all regions of a given table<a name="line.48"></a>
-<span class="sourceLineNo">049</span> *  &lt;li&gt; Get avg size S of each region (by total size of store files reported in RegionMetrics)<a name="line.49"></a>
-<span class="sourceLineNo">050</span> *  &lt;li&gt; Seek every single region one by one. If a region R0 is bigger than S * 2, it is<a name="line.50"></a>
-<span class="sourceLineNo">051</span> *  kindly requested to split. Thereon evaluate the next region R1<a name="line.51"></a>
-<span class="sourceLineNo">052</span> *  &lt;li&gt; Otherwise, if R0 + R1 is smaller than S, R0 and R1 are kindly requested to merge.<a name="line.52"></a>
-<span class="sourceLineNo">053</span> *  Thereon evaluate the next region R2<a name="line.53"></a>
-<span class="sourceLineNo">054</span> *  &lt;li&gt; Otherwise, R1 is evaluated<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * &lt;/ol&gt;<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * &lt;p&gt;<a name="line.56"></a>
-<span class="sourceLineNo">057</span> * Region sizes are coarse and approximate on the order of megabytes. Additionally,<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * "empty" regions (less than 1MB, with the previous note) are not merged away. This<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * is by design to prevent normalization from undoing the pre-splitting of a table.<a name="line.59"></a>
-<span class="sourceLineNo">060</span> */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>@InterfaceAudience.Private<a name="line.61"></a>
-<span class="sourceLineNo">062</span>public class SimpleRegionNormalizer implements RegionNormalizer {<a name="line.62"></a>
-<span class="sourceLineNo">063</span><a name="line.63"></a>
-<span class="sourceLineNo">064</span>  private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class);<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  private int minRegionCount;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>  private MasterServices masterServices;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>  private MasterRpcServices masterRpcServices;<a name="line.67"></a>
-<span class="sourceLineNo">068</span>  private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length];<a name="line.68"></a>
-<span class="sourceLineNo">069</span><a name="line.69"></a>
-<span class="sourceLineNo">070</span>  public SimpleRegionNormalizer() {<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    minRegionCount = HBaseConfiguration.create().getInt("hbase.normalizer.min.region.count", 3);<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  }<a name="line.72"></a>
-<span class="sourceLineNo">073</span>  /**<a name="line.73"></a>
-<span class="sourceLineNo">074</span>   * Set the master service.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>   * @param masterServices inject instance of MasterServices<a name="line.75"></a>
-<span class="sourceLineNo">076</span>   */<a name="line.76"></a>
-<span class="sourceLineNo">077</span>  @Override<a name="line.77"></a>
-<span class="sourceLineNo">078</span>  public void setMasterServices(MasterServices masterServices) {<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    this.masterServices = masterServices;<a name="line.79"></a>
-<span class="sourceLineNo">080</span>  }<a name="line.80"></a>
-<span class="sourceLineNo">081</span><a name="line.81"></a>
-<span class="sourceLineNo">082</span>  @Override<a name="line.82"></a>
-<span class="sourceLineNo">083</span>  public void setMasterRpcServices(MasterRpcServices masterRpcServices) {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    this.masterRpcServices = masterRpcServices;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>  }<a name="line.85"></a>
-<span class="sourceLineNo">086</span><a name="line.86"></a>
-<span class="sourceLineNo">087</span>  @Override<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  public void planSkipped(RegionInfo hri, PlanType type) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    skippedCount[type.ordinal()]++;<a name="line.89"></a>
-<span class="sourceLineNo">090</span>  }<a name="line.90"></a>
-<span class="sourceLineNo">091</span><a name="line.91"></a>
-<span class="sourceLineNo">092</span>  @Override<a name="line.92"></a>
-<span class="sourceLineNo">093</span>  public long getSkippedCount(NormalizationPlan.PlanType type) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    return skippedCount[type.ordinal()];<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  }<a name="line.95"></a>
-<span class="sourceLineNo">096</span><a name="line.96"></a>
-<span class="sourceLineNo">097</span>  /**<a name="line.97"></a>
-<span class="sourceLineNo">098</span>   * Comparator class that gives higher priority to region Split plan.<a name="line.98"></a>
-<span class="sourceLineNo">099</span>   */<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  static class PlanComparator implements Comparator&lt;NormalizationPlan&gt; {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    @Override<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    public int compare(NormalizationPlan plan1, NormalizationPlan plan2) {<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      boolean plan1IsSplit = plan1 instanceof SplitNormalizationPlan;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      boolean plan2IsSplit = plan2 instanceof SplitNormalizationPlan;<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      if (plan1IsSplit &amp;&amp; plan2IsSplit) {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        return 0;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>      } else if (plan1IsSplit) {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>        return -1;<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      } else if (plan2IsSplit) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>        return 1;<a name="line.110"></a>
-<span class="sourceLineNo">111</span>      } else {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>        return 0;<a name="line.112"></a>
-<span class="sourceLineNo">113</span>      }<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    }<a name="line.114"></a>
-<span class="sourceLineNo">115</span>  }<a name="line.115"></a>
-<span class="sourceLineNo">116</span><a name="line.116"></a>
-<span class="sourceLineNo">117</span>  private Comparator&lt;NormalizationPlan&gt; planComparator = new PlanComparator();<a name="line.117"></a>
+<span class="sourceLineNo">047</span> * Logic in use:<a name="line.47"></a>
+<span class="sourceLineNo">048</span> *<a name="line.48"></a>
+<span class="sourceLineNo">049</span> *  &lt;ol&gt;<a name="line.49"></a>
+<span class="sourceLineNo">050</span> *  &lt;li&gt; Get all regions of a given table<a name="line.50"></a>
+<span class="sourceLineNo">051</span> *  &lt;li&gt; Get avg size S of each region (by total size of store files reported in RegionMetrics)<a name="line.51"></a>
+<span class="sourceLineNo">052</span> *  &lt;li&gt; Seek every single region one by one. If a region R0 is bigger than S * 2, it is<a name="line.52"></a>
+<span class="sourceLineNo">053</span> *  kindly requested to split. Thereon evaluate the next region R1<a name="line.53"></a>
+<span class="sourceLineNo">054</span> *  &lt;li&gt; Otherwise, if R0 + R1 is smaller than S, R0 and R1 are kindly requested to merge.<a name="line.54"></a>
+<span class="sourceLineNo">055</span> *  Thereon evaluate the next region R2<a name="line.55"></a>
+<span class="sourceLineNo">056</span> *  &lt;li&gt; Otherwise, R1 is evaluated<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * &lt;/ol&gt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span> * &lt;p&gt;<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * Region sizes are coarse and approximate on the order of megabytes. Additionally,<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * "empty" regions (less than 1MB, with the previous note) are not merged away. This<a name="line.60"></a>
+<span class="sourceLineNo">061</span> * is by design to prevent normalization from undoing the pre-splitting of a table.<a name="line.61"></a>
+<span class="sourceLineNo">062</span> */<a name="line.62"></a>
+<span class="sourceLineNo">063</span>@InterfaceAudience.Private<a name="line.63"></a>
+<span class="sourceLineNo">064</span>public class SimpleRegionNormalizer implements RegionNormalizer {<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>  private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  private int minRegionCount;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>  private MasterServices masterServices;<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  private MasterRpcServices masterRpcServices;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length];<a name="line.70"></a>
+<span class="sourceLineNo">071</span><a name="line.71"></a>
+<span class="sourceLineNo">072</span>  public SimpleRegionNormalizer() {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    minRegionCount = HBaseConfiguration.create().getInt("hbase.normalizer.min.region.count", 3);<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  }<a name="line.74"></a>
+<span class="sourceLineNo">075</span>  /**<a name="line.75"></a>
+<span class="sourceLineNo">076</span>   * Set the master service.<a name="line.76"></a>
+<span class="sourceLineNo">077</span>   * @param masterServices inject instance of MasterServices<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   */<a name="line.78"></a>
+<span class="sourceLineNo">079</span>  @Override<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  public void setMasterServices(MasterServices masterServices) {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    this.masterServices = masterServices;<a name="line.81"></a>
+<span class="sourceLineNo">082</span>  }<a name="line.82"></a>
+<span class="sourceLineNo">083</span><a name="line.83"></a>
+<span class="sourceLineNo">084</span>  @Override<a name="line.84"></a>
+<span class="sourceLineNo">085</span>  public void setMasterRpcServices(MasterRpcServices masterRpcServices) {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    this.masterRpcServices = masterRpcServices;<a name="line.86"></a>
+<span class="sourceLineNo">087</span>  }<a name="line.87"></a>
+<span class="sourceLineNo">088</span><a name="line.88"></a>
+<span class="sourceLineNo">089</span>  @Override<a name="line.89"></a>
+<span class="sourceLineNo">090</span>  public void planSkipped(RegionInfo hri, PlanType type) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    skippedCount[type.ordinal()]++;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>  }<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>  @Override<a name="line.94"></a>
+<span class="sourceLineNo">095</span>  public long getSkippedCount(NormalizationPlan.PlanType type) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    return skippedCount[type.ordinal()];<a name="line.96"></a>
+<span class="sourceLineNo">097</span>  }<a name="line.97"></a>
+<span class="sourceLineNo">098</span><a name="line.98"></a>
+<span class="sourceLineNo">099</span>  /**<a name="line.99"></a>
+<span class="sourceLineNo">100</span>   * Comparator class that gives higher priority to region Split plan.<a name="line.100"></a>
+<span class="sourceLineNo">101</span>   */<a name="line.101"></a>
+<span class="sourceLineNo">102</span>  static class PlanComparator implements Comparator&lt;NormalizationPlan&gt; {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    @Override<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    public int compare(NormalizationPlan plan1, NormalizationPlan plan2) {<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      boolean plan1IsSplit = plan1 instanceof SplitNormalizationPlan;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      boolean plan2IsSplit = plan2 instanceof SplitNormalizationPlan;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      if (plan1IsSplit &amp;&amp; plan2IsSplit) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        return 0;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      } else if (plan1IsSplit) {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>        return -1;<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      } else if (plan2IsSplit) {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        return 1;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>      } else {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>        return 0;<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      }<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  }<a name="line.117"></a>
 <span class="sourceLineNo">118</span><a name="line.118"></a>
-<span class="sourceLineNo">119</span>  /**<a name="line.119"></a>
-<span class="sourceLineNo">120</span>   * Computes next most "urgent" normalization action on the table.<a name="line.120"></a>
-<span class="sourceLineNo">121</span>   * Action may be either a split, or a merge, or no action.<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   *<a name="line.122"></a>
-<span class="sourceLineNo">123</span>   * @param table table to normalize<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * @return normalization plan to execute<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   */<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  @Override<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  public List&lt;NormalizationPlan&gt; computePlanForTable(TableName table) throws HBaseIOException {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    if (table == null || table.isSystemTable()) {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      LOG.debug("Normalization of system table " + table + " isn't allowed");<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      return null;<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>    List&lt;NormalizationPlan&gt; plans = new ArrayList&lt;&gt;();<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    List&lt;RegionInfo&gt; tableRegions = masterServices.getAssignmentManager().getRegionStates().<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      getRegionsOfTable(table);<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>    //TODO: should we make min number of regions a config param?<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    if (tableRegions == null || tableRegions.size() &lt; minRegionCount) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      int nrRegions = tableRegions == null ? 0 : tableRegions.size();<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number"<a name="line.140"></a>
-<span class="sourceLineNo">141</span>        + " of regions for normalizer to run is " + minRegionCount + ", not running normalizer");<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      return null;<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>    LOG.debug("Computing normalization plan for table: " + table +<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      ", number of regions: " + tableRegions.size());<a name="line.146"></a>
-<span class="sourceLineNo">147</span><a name="line.147"></a>
-<span class="sourceLineNo">148</span>    long totalSizeMb = 0;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    int acutalRegionCnt = 0;<a name="line.149"></a>
-<span class="sourceLineNo">150</span><a name="line.150"></a>
-<span class="sourceLineNo">151</span>    for (int i = 0; i &lt; tableRegions.size(); i++) {<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      RegionInfo hri = tableRegions.get(i);<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      long regionSize = getRegionSize(hri);<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      if (regionSize &gt; 0) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        acutalRegionCnt++;<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        totalSizeMb += regionSize;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>      }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    }<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    double avgRegionSize = acutalRegionCnt == 0 ? 0 : totalSizeMb / (double) acutalRegionCnt;<a name="line.160"></a>
-<span class="sourceLineNo">161</span><a name="line.161"></a>
-<span class="sourceLineNo">162</span>    LOG.debug("Table " + table + ", total aggregated regions size: " + totalSizeMb);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    LOG.debug("Table " + table + ", average region size: " + avgRegionSize);<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>    int candidateIdx = 0;<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    boolean splitEnabled = true, mergeEnabled = true;<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    try {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.168"></a>
-<span class="sourceLineNo">169</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    }<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    try {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.174"></a>
-<span class="sourceLineNo">175</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    }<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    while (candidateIdx &lt; tableRegions.size()) {<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      RegionInfo hri = tableRegions.get(candidateIdx);<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      long regionSize = getRegionSize(hri);<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      // if the region is &gt; 2 times larger than average, we split it, split<a name="line.182"></a>
-<span class="sourceLineNo">183</span>      // is more high priority normalization action than merge.<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      if (regionSize &gt; 2 * avgRegionSize) {<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        if (splitEnabled) {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>          LOG.info("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.186"></a>
-<span class="sourceLineNo">187</span>              + regionSize + ", more than twice avg size, splitting");<a name="line.187"></a>
-<span class="sourceLineNo">188</span>          plans.add(new SplitNormalizationPlan(hri, null));<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      } else {<a name="line.190"></a>
-<span class="sourceLineNo">191</span>        if (candidateIdx == tableRegions.size()-1) {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>          break;<a name="line.192"></a>
-<span class="sourceLineNo">193</span>        }<a name="line.193"></a>
-<span class="sourceLineNo">194</span>        if (mergeEnabled) {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>          RegionInfo hri2 = tableRegions.get(candidateIdx+1);<a name="line.195"></a>
-<span class="sourceLineNo">196</span>          long regionSize2 = getRegionSize(hri2);<a name="line.196"></a>
-<span class="sourceLineNo">197</span>          if (regionSize &gt;= 0 &amp;&amp; regionSize2 &gt;= 0 &amp;&amp; regionSize + regionSize2 &lt; avgRegionSize) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>            LOG.info("Table " + table + ", small region size: " + regionSize<a name="line.198"></a>
-<span class="sourceLineNo">199</span>              + " plus its neighbor size: " + regionSize2<a name="line.199"></a>
-<span class="sourceLineNo">200</span>              + ", less than the avg size " + avgRegionSize + ", merging them");<a name="line.200"></a>
-<span class="sourceLineNo">201</span>            plans.add(new MergeNormalizationPlan(hri, hri2));<a name="line.201"></a>
-<span class="sourceLineNo">202</span>            candidateIdx++;<a name="line.202"></a>
-<span class="sourceLineNo">203</span>          }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>        }<a name="line.204"></a>
-<span class="sourceLineNo">205</span>      }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      candidateIdx++;<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    }<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    if (plans.isEmpty()) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      LOG.debug("No normalization needed, regions look good for table: " + table);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      return null;<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    }<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    Collections.sort(plans, planComparator);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    return plans;<a name="line.213"></a>
-<span class="sourceLineNo">214</span>  }<a name="line.214"></a>
-<span class="sourceLineNo">215</span><a name="line.215"></a>
-<span class="sourceLineNo">216</span>  private long getRegionSize(RegionInfo hri) {<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    ServerName sn = masterServices.getAssignmentManager().getRegionStates().<a name="line.217"></a>
-<span class="sourceLineNo">218</span>      getRegionServerOfRegion(hri);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>    RegionMetrics regionLoad = masterServices.getServerManager().getLoad(sn).<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      getRegionMetrics().get(hri.getRegionName());<a name="line.220"></a>
-<span class="sourceLineNo">221</span>    if (regionLoad == null) {<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      LOG.debug(hri.getRegionNameAsString() + " was not found in RegionsLoad");<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      return -1;<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    }<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    return (long) regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>}<a name="line.227"></a>
+<span class="sourceLineNo">119</span>  private Comparator&lt;NormalizationPlan&gt; planComparator = new PlanComparator();<a name="line.119"></a>
+<span class="sourceLineNo">120</span><a name="line.120"></a>
+<span class="sourceLineNo">121</span>  /**<a name="line.121"></a>
+<span class="sourceLineNo">122</span>   * Computes next most "urgent" normalization action on the table.<a name="line.122"></a>
+<span class="sourceLineNo">123</span>   * Action may be either a split, or a merge, or no action.<a name="line.123"></a>
+<span class="sourceLineNo">124</span>   *<a name="line.124"></a>
+<span class="sourceLineNo">125</span>   * @param table table to normalize<a name="line.125"></a>
+<span class="sourceLineNo">126</span>   * @return normalization plan to execute<a name="line.126"></a>
+<span class="sourceLineNo">127</span>   */<a name="line.127"></a>
+<span class="sourceLineNo">128</span>  @Override<a name="line.128"></a>
+<span class="sourceLineNo">129</span>  public List&lt;NormalizationPlan&gt; computePlanForTable(TableName table) throws HBaseIOException {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    if (table == null || table.isSystemTable()) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      LOG.debug("Normalization of system table " + table + " isn't allowed");<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      return null;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    }<a name="line.133"></a>
+<span class="sourceLineNo">134</span><a name="line.134"></a>
+<span class="sourceLineNo">135</span>    List&lt;NormalizationPlan&gt; plans = new ArrayList&lt;&gt;();<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    List&lt;RegionInfo&gt; tableRegions = masterServices.getAssignmentManager().getRegionStates().<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      getRegionsOfTable(table);<a name="line.137"></a>
+<span class="sourceLineNo">138</span><a name="line.138"></a>
+<span class="sourceLineNo">139</span>    //TODO: should we make min number of regions a config param?<a name="line.139"></a>
+<span class="sourceLineNo">140</span>    if (tableRegions == null || tableRegions.size() &lt; minRegionCount) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      int nrRegions = tableRegions == null ? 0 : tableRegions.size();<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number"<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        + " of regions for normalizer to run is " + minRegionCount + ", not running normalizer");<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      return null;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
+<span class="sourceLineNo">146</span><a name="line.146"></a>
+<span class="sourceLineNo">147</span>    LOG.debug("Computing normalization plan for table: " + table +<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      ", number of regions: " + tableRegions.size());<a name="line.148"></a>
+<span class="sourceLineNo">149</span><a name="line.149"></a>
+<span class="sourceLineNo">150</span>    long totalSizeMb = 0;<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    int acutalRegionCnt = 0;<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    for (int i = 0; i &lt; tableRegions.size(); i++) {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      RegionInfo hri = tableRegions.get(i);<a name="line.154"></a>
+<span class="sourceLineNo">155</span>      long regionSize = getRegionSize(hri);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      if (regionSize &gt; 0) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        acutalRegionCnt++;<a name="line.157"></a>
+<span class="sourceLineNo">158</span>        totalSizeMb += regionSize;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>      }<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    }<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    int targetRegionCount = -1;<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    long targetRegionSize = -1;<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    try {<a name="line.163"></a>
+<span class="sourceLineNo">164</span>      TableDescriptor tableDescriptor = masterServices.getTableDescriptors().get(table);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>      if(tableDescriptor != null) {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>        targetRegionCount =<a name="line.166"></a>
+<span class="sourceLineNo">167</span>            tableDescriptor.getNormalizerTargetRegionCount();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        targetRegionSize =<a name="line.168"></a>
+<span class="sourceLineNo">169</span>            tableDescriptor.getNormalizerTargetRegionSize();<a name="line.169"></a>
+<span class="sourceLineNo">170</span>        LOG.debug("Table {}:  target region count is {}, target region size is {}", table,<a name="line.170"></a>
+<span class="sourceLineNo">171</span>            targetRegionCount, targetRegionSize);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      }<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    } catch (IOException e) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      LOG.warn(<a name="line.174"></a>
+<span class="sourceLineNo">175</span>        "cannot get the target number and target size of table {}, they will be default value -1.",<a name="line.175"></a>
+<span class="sourceLineNo">176</span>        table);<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    }<a name="line.177"></a>
+<span class="sourceLineNo">178</span><a name="line.178"></a>
+<span class="sourceLineNo">179</span>    double avgRegionSize;<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    if (targetRegionSize &gt; 0) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      avgRegionSize = targetRegionSize;<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    } else if (targetRegionCount &gt; 0) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      avgRegionSize = totalSizeMb / (double) targetRegionCount;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    } else {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      avgRegionSize = acutalRegionCnt == 0 ? 0 : totalSizeMb / (double) acutalRegionCnt;<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    }<a name="line.186"></a>
+<span class="sourceLineNo">187</span><a name="line.187"></a>
+<span class="sourceLineNo">188</span>    LOG.debug("Table " + table + ", total aggregated regions size: " + totalSizeMb);<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    LOG.debug("Table " + table + ", average region size: " + avgRegionSize);<a name="line.189"></a>
+<span class="sourceLineNo">190</span><a name="line.190"></a>
+<span class="sourceLineNo">191</span>    int candidateIdx = 0;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    boolean splitEnabled = true, mergeEnabled = true;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    try {<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.194"></a>
+<span class="sourceLineNo">195</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    }<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    try {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.200"></a>
+<span class="sourceLineNo">201</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    while (candidateIdx &lt; tableRegions.size()) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      RegionInfo hri = tableRegions.get(candidateIdx);<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      long regionSize = getRegionSize(hri);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      // if the region is &gt; 2 times larger than average, we split it, split<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      // is more high priority normalization action than merge.<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      if (regionSize &gt; 2 * avgRegionSize) {<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        if (splitEnabled) {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>          LOG.info("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.212"></a>
+<span class="sourceLineNo">213</span>              + regionSize + ", more than twice avg size, splitting");<a name="line.213"></a>
+<span class="sourceLineNo">214</span>          plans.add(new SplitNormalizationPlan(hri, null));<a name="line.214"></a>
+<span class="sourceLineNo">215</span>        }<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      } else {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        if (candidateIdx == tableRegions.size()-1) {<a name="line.217"></a>
+<span class="sourceLineNo">218</span>          break;<a name="line.218"></a>
+<span class="sourceLineNo">219</span>        }<a name="line.219"></a>
+<span class="sourceLineNo">220</span>        if (mergeEnabled) {<a name="line.220"></a>
+<span class="sourceLineNo">221</span>          RegionInfo hri2 = tableRegions.get(candidateIdx+1);<a name="line.221"></a>
+<span class="sourceLineNo">222</span>          long regionSize2 = getRegionSize(hri2);<a name="line.222"></a>
+<span class="sourceLineNo">223</span>          if (regionSize &gt;= 0 &amp;&amp; regionSize2 &gt;= 0 &amp;&amp; regionSize + regionSize2 &lt; avgRegionSize) {<a name="line.223"></a>
+<span class="sourceLineNo">224</span>            LOG.info("Table " + table + ", small region size: " + regionSize<a name="line.224"></a>
+<span class="sourceLineNo">225</span>              + " plus its neighbor size: " + regionSize2<a name="line.225"></a>
+<span class="sourceLineNo">226</span>              + ", less than the avg size " + avgRegionSize + ", merging them");<a name="line.226"></a>
+<span class="sourceLineNo">227</span>            plans.add(new MergeNormalizationPlan(hri, hri2));<a name="line.227"></a>
+<span class="sourceLineNo">228</span>            candidateIdx++;<a name="line.228"></a>
+<span class="sourceLineNo">229</span>          }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>        }<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      }<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      candidateIdx++;<a name="line.232"></a>
+<span class="sourceLineNo">233</span>    }<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    if (plans.isEmpty()) {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>      LOG.debug("No normalization needed, regions look good for table: " + table);<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      return null;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    }<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    Collections.sort(plans, planComparator);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    return plans;<a name="line.239"></a>
+<span class="sourceLineNo">240</span>  }<a name="line.240"></a>
+<span class="sourceLineNo">241</span><a name="line.241"></a>
+<span class="sourceLineNo">242</span>  private long getRegionSize(RegionInfo hri) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    ServerName sn = masterServices.getAssignmentManager().getRegionStates().<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      getRegionServerOfRegion(hri);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    RegionMetrics regionLoad = masterServices.getServerManager().getLoad(sn).<a name="line.245"></a>
+<span class="sourceLineNo">246</span>      getRegionMetrics().get(hri.getRegionName());<a name="line.246"></a>
+<span class="sourceLineNo">247</span>    if (regionLoad == null) {<a name="line.247"></a>
+<span class="sourceLineNo">248</span>      LOG.debug(hri.getRegionNameAsString() + " was not found in RegionsLoad");<a name="line.248"></a>
+<span class="sourceLineNo">249</span>      return -1;<a name="line.249"></a>
+<span class="sourceLineNo">250</span>    }<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    return (long) regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>  }<a name="line.252"></a>
+<span class="sourceLineNo">253</span>}<a name="line.253"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/75e49c45/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html
index 9267f53..c688159 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html
@@ -26,213 +26,239 @@
 <span class="sourceLineNo">018</span> */<a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.master.normalizer;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.ArrayList;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.Collections;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.Comparator;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HBaseIOException;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.RegionMetrics;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.ServerName;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.Size;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.TableName;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.client.MasterSwitchType;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.master.MasterRpcServices;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.master.normalizer.NormalizationPlan.PlanType;<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.slf4j.Logger;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.slf4j.LoggerFactory;<a name="line.38"></a>
-<span class="sourceLineNo">039</span><a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.40"></a>
+<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.ArrayList;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.util.Collections;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.Comparator;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.List;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.HBaseConfiguration;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HBaseIOException;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.RegionMetrics;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.ServerName;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.Size;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.TableName;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.client.MasterSwitchType;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.TableDescriptor;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.master.MasterRpcServices;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.master.MasterServices;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.master.normalizer.NormalizationPlan.PlanType;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.slf4j.Logger;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.slf4j.LoggerFactory;<a name="line.40"></a>
 <span class="sourceLineNo">041</span><a name="line.41"></a>
-<span class="sourceLineNo">042</span>/**<a name="line.42"></a>
-<span class="sourceLineNo">043</span> * Simple implementation of region normalizer.<a name="line.43"></a>
-<span class="sourceLineNo">044</span> *<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * Logic in use:<a name="line.45"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>/**<a name="line.44"></a>
+<span class="sourceLineNo">045</span> * Simple implementation of region normalizer.<a name="line.45"></a>
 <span class="sourceLineNo">046</span> *<a name="line.46"></a>
-<span class="sourceLineNo">047</span> *  &lt;ol&gt;<a name="line.47"></a>
-<span class="sourceLineNo">048</span> *  &lt;li&gt; Get all regions of a given table<a name="line.48"></a>
-<span class="sourceLineNo">049</span> *  &lt;li&gt; Get avg size S of each region (by total size of store files reported in RegionMetrics)<a name="line.49"></a>
-<span class="sourceLineNo">050</span> *  &lt;li&gt; Seek every single region one by one. If a region R0 is bigger than S * 2, it is<a name="line.50"></a>
-<span class="sourceLineNo">051</span> *  kindly requested to split. Thereon evaluate the next region R1<a name="line.51"></a>
-<span class="sourceLineNo">052</span> *  &lt;li&gt; Otherwise, if R0 + R1 is smaller than S, R0 and R1 are kindly requested to merge.<a name="line.52"></a>
-<span class="sourceLineNo">053</span> *  Thereon evaluate the next region R2<a name="line.53"></a>
-<span class="sourceLineNo">054</span> *  &lt;li&gt; Otherwise, R1 is evaluated<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * &lt;/ol&gt;<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * &lt;p&gt;<a name="line.56"></a>
-<span class="sourceLineNo">057</span> * Region sizes are coarse and approximate on the order of megabytes. Additionally,<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * "empty" regions (less than 1MB, with the previous note) are not merged away. This<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * is by design to prevent normalization from undoing the pre-splitting of a table.<a name="line.59"></a>
-<span class="sourceLineNo">060</span> */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>@InterfaceAudience.Private<a name="line.61"></a>
-<span class="sourceLineNo">062</span>public class SimpleRegionNormalizer implements RegionNormalizer {<a name="line.62"></a>
-<span class="sourceLineNo">063</span><a name="line.63"></a>
-<span class="sourceLineNo">064</span>  private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class);<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  private int minRegionCount;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>  private MasterServices masterServices;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>  private MasterRpcServices masterRpcServices;<a name="line.67"></a>
-<span class="sourceLineNo">068</span>  private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length];<a name="line.68"></a>
-<span class="sourceLineNo">069</span><a name="line.69"></a>
-<span class="sourceLineNo">070</span>  public SimpleRegionNormalizer() {<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    minRegionCount = HBaseConfiguration.create().getInt("hbase.normalizer.min.region.count", 3);<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  }<a name="line.72"></a>
-<span class="sourceLineNo">073</span>  /**<a name="line.73"></a>
-<span class="sourceLineNo">074</span>   * Set the master service.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>   * @param masterServices inject instance of MasterServices<a name="line.75"></a>
-<span class="sourceLineNo">076</span>   */<a name="line.76"></a>
-<span class="sourceLineNo">077</span>  @Override<a name="line.77"></a>
-<span class="sourceLineNo">078</span>  public void setMasterServices(MasterServices masterServices) {<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    this.masterServices = masterServices;<a name="line.79"></a>
-<span class="sourceLineNo">080</span>  }<a name="line.80"></a>
-<span class="sourceLineNo">081</span><a name="line.81"></a>
-<span class="sourceLineNo">082</span>  @Override<a name="line.82"></a>
-<span class="sourceLineNo">083</span>  public void setMasterRpcServices(MasterRpcServices masterRpcServices) {<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    this.masterRpcServices = masterRpcServices;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>  }<a name="line.85"></a>
-<span class="sourceLineNo">086</span><a name="line.86"></a>
-<span class="sourceLineNo">087</span>  @Override<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  public void planSkipped(RegionInfo hri, PlanType type) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    skippedCount[type.ordinal()]++;<a name="line.89"></a>
-<span class="sourceLineNo">090</span>  }<a name="line.90"></a>
-<span class="sourceLineNo">091</span><a name="line.91"></a>
-<span class="sourceLineNo">092</span>  @Override<a name="line.92"></a>
-<span class="sourceLineNo">093</span>  public long getSkippedCount(NormalizationPlan.PlanType type) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    return skippedCount[type.ordinal()];<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  }<a name="line.95"></a>
-<span class="sourceLineNo">096</span><a name="line.96"></a>
-<span class="sourceLineNo">097</span>  /**<a name="line.97"></a>
-<span class="sourceLineNo">098</span>   * Comparator class that gives higher priority to region Split plan.<a name="line.98"></a>
-<span class="sourceLineNo">099</span>   */<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  static class PlanComparator implements Comparator&lt;NormalizationPlan&gt; {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    @Override<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    public int compare(NormalizationPlan plan1, NormalizationPlan plan2) {<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      boolean plan1IsSplit = plan1 instanceof SplitNormalizationPlan;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      boolean plan2IsSplit = plan2 instanceof SplitNormalizationPlan;<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      if (plan1IsSplit &amp;&amp; plan2IsSplit) {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        return 0;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>      } else if (plan1IsSplit) {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>        return -1;<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      } else if (plan2IsSplit) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>        return 1;<a name="line.110"></a>
-<span class="sourceLineNo">111</span>      } else {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>        return 0;<a name="line.112"></a>
-<span class="sourceLineNo">113</span>      }<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    }<a name="line.114"></a>
-<span class="sourceLineNo">115</span>  }<a name="line.115"></a>
-<span class="sourceLineNo">116</span><a name="line.116"></a>
-<span class="sourceLineNo">117</span>  private Comparator&lt;NormalizationPlan&gt; planComparator = new PlanComparator();<a name="line.117"></a>
+<span class="sourceLineNo">047</span> * Logic in use:<a name="line.47"></a>
+<span class="sourceLineNo">048</span> *<a name="line.48"></a>
+<span class="sourceLineNo">049</span> *  &lt;ol&gt;<a name="line.49"></a>
+<span class="sourceLineNo">050</span> *  &lt;li&gt; Get all regions of a given table<a name="line.50"></a>
+<span class="sourceLineNo">051</span> *  &lt;li&gt; Get avg size S of each region (by total size of store files reported in RegionMetrics)<a name="line.51"></a>
+<span class="sourceLineNo">052</span> *  &lt;li&gt; Seek every single region one by one. If a region R0 is bigger than S * 2, it is<a name="line.52"></a>
+<span class="sourceLineNo">053</span> *  kindly requested to split. Thereon evaluate the next region R1<a name="line.53"></a>
+<span class="sourceLineNo">054</span> *  &lt;li&gt; Otherwise, if R0 + R1 is smaller than S, R0 and R1 are kindly requested to merge.<a name="line.54"></a>
+<span class="sourceLineNo">055</span> *  Thereon evaluate the next region R2<a name="line.55"></a>
+<span class="sourceLineNo">056</span> *  &lt;li&gt; Otherwise, R1 is evaluated<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * &lt;/ol&gt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span> * &lt;p&gt;<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * Region sizes are coarse and approximate on the order of megabytes. Additionally,<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * "empty" regions (less than 1MB, with the previous note) are not merged away. This<a name="line.60"></a>
+<span class="sourceLineNo">061</span> * is by design to prevent normalization from undoing the pre-splitting of a table.<a name="line.61"></a>
+<span class="sourceLineNo">062</span> */<a name="line.62"></a>
+<span class="sourceLineNo">063</span>@InterfaceAudience.Private<a name="line.63"></a>
+<span class="sourceLineNo">064</span>public class SimpleRegionNormalizer implements RegionNormalizer {<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>  private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  private int minRegionCount;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>  private MasterServices masterServices;<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  private MasterRpcServices masterRpcServices;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length];<a name="line.70"></a>
+<span class="sourceLineNo">071</span><a name="line.71"></a>
+<span class="sourceLineNo">072</span>  public SimpleRegionNormalizer() {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    minRegionCount = HBaseConfiguration.create().getInt("hbase.normalizer.min.region.count", 3);<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  }<a name="line.74"></a>
+<span class="sourceLineNo">075</span>  /**<a name="line.75"></a>
+<span class="sourceLineNo">076</span>   * Set the master service.<a name="line.76"></a>
+<span class="sourceLineNo">077</span>   * @param masterServices inject instance of MasterServices<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   */<a name="line.78"></a>
+<span class="sourceLineNo">079</span>  @Override<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  public void setMasterServices(MasterServices masterServices) {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    this.masterServices = masterServices;<a name="line.81"></a>
+<span class="sourceLineNo">082</span>  }<a name="line.82"></a>
+<span class="sourceLineNo">083</span><a name="line.83"></a>
+<span class="sourceLineNo">084</span>  @Override<a name="line.84"></a>
+<span class="sourceLineNo">085</span>  public void setMasterRpcServices(MasterRpcServices masterRpcServices) {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    this.masterRpcServices = masterRpcServices;<a name="line.86"></a>
+<span class="sourceLineNo">087</span>  }<a name="line.87"></a>
+<span class="sourceLineNo">088</span><a name="line.88"></a>
+<span class="sourceLineNo">089</span>  @Override<a name="line.89"></a>
+<span class="sourceLineNo">090</span>  public void planSkipped(RegionInfo hri, PlanType type) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>    skippedCount[type.ordinal()]++;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>  }<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>  @Override<a name="line.94"></a>
+<span class="sourceLineNo">095</span>  public long getSkippedCount(NormalizationPlan.PlanType type) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    return skippedCount[type.ordinal()];<a name="line.96"></a>
+<span class="sourceLineNo">097</span>  }<a name="line.97"></a>
+<span class="sourceLineNo">098</span><a name="line.98"></a>
+<span class="sourceLineNo">099</span>  /**<a name="line.99"></a>
+<span class="sourceLineNo">100</span>   * Comparator class that gives higher priority to region Split plan.<a name="line.100"></a>
+<span class="sourceLineNo">101</span>   */<a name="line.101"></a>
+<span class="sourceLineNo">102</span>  static class PlanComparator implements Comparator&lt;NormalizationPlan&gt; {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    @Override<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    public int compare(NormalizationPlan plan1, NormalizationPlan plan2) {<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      boolean plan1IsSplit = plan1 instanceof SplitNormalizationPlan;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      boolean plan2IsSplit = plan2 instanceof SplitNormalizationPlan;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      if (plan1IsSplit &amp;&amp; plan2IsSplit) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        return 0;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      } else if (plan1IsSplit) {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>        return -1;<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      } else if (plan2IsSplit) {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        return 1;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>      } else {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>        return 0;<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      }<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  }<a name="line.117"></a>
 <span class="sourceLineNo">118</span><a name="line.118"></a>
-<span class="sourceLineNo">119</span>  /**<a name="line.119"></a>
-<span class="sourceLineNo">120</span>   * Computes next most "urgent" normalization action on the table.<a name="line.120"></a>
-<span class="sourceLineNo">121</span>   * Action may be either a split, or a merge, or no action.<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   *<a name="line.122"></a>
-<span class="sourceLineNo">123</span>   * @param table table to normalize<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * @return normalization plan to execute<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   */<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  @Override<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  public List&lt;NormalizationPlan&gt; computePlanForTable(TableName table) throws HBaseIOException {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    if (table == null || table.isSystemTable()) {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      LOG.debug("Normalization of system table " + table + " isn't allowed");<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      return null;<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>    List&lt;NormalizationPlan&gt; plans = new ArrayList&lt;&gt;();<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    List&lt;RegionInfo&gt; tableRegions = masterServices.getAssignmentManager().getRegionStates().<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      getRegionsOfTable(table);<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>    //TODO: should we make min number of regions a config param?<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    if (tableRegions == null || tableRegions.size() &lt; minRegionCount) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      int nrRegions = tableRegions == null ? 0 : tableRegions.size();<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number"<a name="line.140"></a>
-<span class="sourceLineNo">141</span>        + " of regions for normalizer to run is " + minRegionCount + ", not running normalizer");<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      return null;<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>    LOG.debug("Computing normalization plan for table: " + table +<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      ", number of regions: " + tableRegions.size());<a name="line.146"></a>
-<span class="sourceLineNo">147</span><a name="line.147"></a>
-<span class="sourceLineNo">148</span>    long totalSizeMb = 0;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    int acutalRegionCnt = 0;<a name="line.149"></a>
-<span class="sourceLineNo">150</span><a name="line.150"></a>
-<span class="sourceLineNo">151</span>    for (int i = 0; i &lt; tableRegions.size(); i++) {<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      RegionInfo hri = tableRegions.get(i);<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      long regionSize = getRegionSize(hri);<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      if (regionSize &gt; 0) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        acutalRegionCnt++;<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        totalSizeMb += regionSize;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>      }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    }<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    double avgRegionSize = acutalRegionCnt == 0 ? 0 : totalSizeMb / (double) acutalRegionCnt;<a name="line.160"></a>
-<span class="sourceLineNo">161</span><a name="line.161"></a>
-<span class="sourceLineNo">162</span>    LOG.debug("Table " + table + ", total aggregated regions size: " + totalSizeMb);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    LOG.debug("Table " + table + ", average region size: " + avgRegionSize);<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>    int candidateIdx = 0;<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    boolean splitEnabled = true, mergeEnabled = true;<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    try {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.168"></a>
-<span class="sourceLineNo">169</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    }<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    try {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.174"></a>
-<span class="sourceLineNo">175</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    }<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    while (candidateIdx &lt; tableRegions.size()) {<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      RegionInfo hri = tableRegions.get(candidateIdx);<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      long regionSize = getRegionSize(hri);<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      // if the region is &gt; 2 times larger than average, we split it, split<a name="line.182"></a>
-<span class="sourceLineNo">183</span>      // is more high priority normalization action than merge.<a name="line.183"></a>
-<span class="sourceLineNo">184</span>      if (regionSize &gt; 2 * avgRegionSize) {<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        if (splitEnabled) {<a name="line.185"></a>
-<span class="sourceLineNo">186</span>          LOG.info("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.186"></a>
-<span class="sourceLineNo">187</span>              + regionSize + ", more than twice avg size, splitting");<a name="line.187"></a>
-<span class="sourceLineNo">188</span>          plans.add(new SplitNormalizationPlan(hri, null));<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        }<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      } else {<a name="line.190"></a>
-<span class="sourceLineNo">191</span>        if (candidateIdx == tableRegions.size()-1) {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>          break;<a name="line.192"></a>
-<span class="sourceLineNo">193</span>        }<a name="line.193"></a>
-<span class="sourceLineNo">194</span>        if (mergeEnabled) {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>          RegionInfo hri2 = tableRegions.get(candidateIdx+1);<a name="line.195"></a>
-<span class="sourceLineNo">196</span>          long regionSize2 = getRegionSize(hri2);<a name="line.196"></a>
-<span class="sourceLineNo">197</span>          if (regionSize &gt;= 0 &amp;&amp; regionSize2 &gt;= 0 &amp;&amp; regionSize + regionSize2 &lt; avgRegionSize) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>            LOG.info("Table " + table + ", small region size: " + regionSize<a name="line.198"></a>
-<span class="sourceLineNo">199</span>              + " plus its neighbor size: " + regionSize2<a name="line.199"></a>
-<span class="sourceLineNo">200</span>              + ", less than the avg size " + avgRegionSize + ", merging them");<a name="line.200"></a>
-<span class="sourceLineNo">201</span>            plans.add(new MergeNormalizationPlan(hri, hri2));<a name="line.201"></a>
-<span class="sourceLineNo">202</span>            candidateIdx++;<a name="line.202"></a>
-<span class="sourceLineNo">203</span>          }<a name="line.203"></a>
-<span class="sourceLineNo">204</span>        }<a name="line.204"></a>
-<span class="sourceLineNo">205</span>      }<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      candidateIdx++;<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    }<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    if (plans.isEmpty()) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      LOG.debug("No normalization needed, regions look good for table: " + table);<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      return null;<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    }<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    Collections.sort(plans, planComparator);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    return plans;<a name="line.213"></a>
-<span class="sourceLineNo">214</span>  }<a name="line.214"></a>
-<span class="sourceLineNo">215</span><a name="line.215"></a>
-<span class="sourceLineNo">216</span>  private long getRegionSize(RegionInfo hri) {<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    ServerName sn = masterServices.getAssignmentManager().getRegionStates().<a name="line.217"></a>
-<span class="sourceLineNo">218</span>      getRegionServerOfRegion(hri);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>    RegionMetrics regionLoad = masterServices.getServerManager().getLoad(sn).<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      getRegionMetrics().get(hri.getRegionName());<a name="line.220"></a>
-<span class="sourceLineNo">221</span>    if (regionLoad == null) {<a name="line.221"></a>
-<span class="sourceLineNo">222</span>      LOG.debug(hri.getRegionNameAsString() + " was not found in RegionsLoad");<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      return -1;<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    }<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    return (long) regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE);<a name="line.225"></a>
-<span class="sourceLineNo">226</span>  }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>}<a name="line.227"></a>
+<span class="sourceLineNo">119</span>  private Comparator&lt;NormalizationPlan&gt; planComparator = new PlanComparator();<a name="line.119"></a>
+<span class="sourceLineNo">120</span><a name="line.120"></a>
+<span class="sourceLineNo">121</span>  /**<a name="line.121"></a>
+<span class="sourceLineNo">122</span>   * Computes next most "urgent" normalization action on the table.<a name="line.122"></a>
+<span class="sourceLineNo">123</span>   * Action may be either a split, or a merge, or no action.<a name="line.123"></a>
+<span class="sourceLineNo">124</span>   *<a name="line.124"></a>
+<span class="sourceLineNo">125</span>   * @param table table to normalize<a name="line.125"></a>
+<span class="sourceLineNo">126</span>   * @return normalization plan to execute<a name="line.126"></a>
+<span class="sourceLineNo">127</span>   */<a name="line.127"></a>
+<span class="sourceLineNo">128</span>  @Override<a name="line.128"></a>
+<span class="sourceLineNo">129</span>  public List&lt;NormalizationPlan&gt; computePlanForTable(TableName table) throws HBaseIOException {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    if (table == null || table.isSystemTable()) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      LOG.debug("Normalization of system table " + table + " isn't allowed");<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      return null;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    }<a name="line.133"></a>
+<span class="sourceLineNo">134</span><a name="line.134"></a>
+<span class="sourceLineNo">135</span>    List&lt;NormalizationPlan&gt; plans = new ArrayList&lt;&gt;();<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    List&lt;RegionInfo&gt; tableRegions = masterServices.getAssignmentManager().getRegionStates().<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      getRegionsOfTable(table);<a name="line.137"></a>
+<span class="sourceLineNo">138</span><a name="line.138"></a>
+<span class="sourceLineNo">139</span>    //TODO: should we make min number of regions a config param?<a name="line.139"></a>
+<span class="sourceLineNo">140</span>    if (tableRegions == null || tableRegions.size() &lt; minRegionCount) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      int nrRegions = tableRegions == null ? 0 : tableRegions.size();<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number"<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        + " of regions for normalizer to run is " + minRegionCount + ", not running normalizer");<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      return null;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
+<span class="sourceLineNo">146</span><a name="line.146"></a>
+<span class="sourceLineNo">147</span>    LOG.debug("Computing normalization plan for table: " + table +<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      ", number of regions: " + tableRegions.size());<a name="line.148"></a>
+<span class="sourceLineNo">149</span><a name="line.149"></a>
+<span class="sourceLineNo">150</span>    long totalSizeMb = 0;<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    int acutalRegionCnt = 0;<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    for (int i = 0; i &lt; tableRegions.size(); i++) {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      RegionInfo hri = tableRegions.get(i);<a name="line.154"></a>
+<span class="sourceLineNo">155</span>      long regionSize = getRegionSize(hri);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      if (regionSize &gt; 0) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        acutalRegionCnt++;<a name="line.157"></a>
+<span class="sourceLineNo">158</span>        totalSizeMb += regionSize;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>      }<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    }<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    int targetRegionCount = -1;<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    long targetRegionSize = -1;<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    try {<a name="line.163"></a>
+<span class="sourceLineNo">164</span>      TableDescriptor tableDescriptor = masterServices.getTableDescriptors().get(table);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>      if(tableDescriptor != null) {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>        targetRegionCount =<a name="line.166"></a>
+<span class="sourceLineNo">167</span>            tableDescriptor.getNormalizerTargetRegionCount();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>        targetRegionSize =<a name="line.168"></a>
+<span class="sourceLineNo">169</span>            tableDescriptor.getNormalizerTargetRegionSize();<a name="line.169"></a>
+<span class="sourceLineNo">170</span>        LOG.debug("Table {}:  target region count is {}, target region size is {}", table,<a name="line.170"></a>
+<span class="sourceLineNo">171</span>            targetRegionCount, targetRegionSize);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      }<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    } catch (IOException e) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      LOG.warn(<a name="line.174"></a>
+<span class="sourceLineNo">175</span>        "cannot get the target number and target size of table {}, they will be default value -1.",<a name="line.175"></a>
+<span class="sourceLineNo">176</span>        table);<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    }<a name="line.177"></a>
+<span class="sourceLineNo">178</span><a name="line.178"></a>
+<span class="sourceLineNo">179</span>    double avgRegionSize;<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    if (targetRegionSize &gt; 0) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      avgRegionSize = targetRegionSize;<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    } else if (targetRegionCount &gt; 0) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      avgRegionSize = totalSizeMb / (double) targetRegionCount;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    } else {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      avgRegionSize = acutalRegionCnt == 0 ? 0 : totalSizeMb / (double) acutalRegionCnt;<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    }<a name="line.186"></a>
+<span class="sourceLineNo">187</span><a name="line.187"></a>
+<span class="sourceLineNo">188</span>    LOG.debug("Table " + table + ", total aggregated regions size: " + totalSizeMb);<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    LOG.debug("Table " + table + ", average region size: " + avgRegionSize);<a name="line.189"></a>
+<span class="sourceLineNo">190</span><a name="line.190"></a>
+<span class="sourceLineNo">191</span>    int candidateIdx = 0;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    boolean splitEnabled = true, mergeEnabled = true;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    try {<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.194"></a>
+<span class="sourceLineNo">195</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    }<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    try {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null,<a name="line.200"></a>
+<span class="sourceLineNo">201</span>        RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      LOG.debug("Unable to determine whether split is enabled", e);<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    while (candidateIdx &lt; tableRegions.size()) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      RegionInfo hri = tableRegions.get(candidateIdx);<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      long regionSize = getRegionSize(hri);<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      // if the region is &gt; 2 times larger than average, we split it, split<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      // is more high priority normalization action than merge.<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      if (regionSize &gt; 2 * avgRegionSize) {<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        if (splitEnabled) {<a name="line.211"></a>
+<span class="sourceLineNo">212</span>          LOG.info("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.212"></a>
+<span class="sourceLineNo">213</span>              + regionSize + ", more than twice avg size, splitting");<a name="line.213"></a>
+<span class="sourceLineNo">214</span>          plans.add(new SplitNormalizationPlan(hri, null));<a name="line.214"></a>
+<span class="sourceLineNo">215</span>        }<a name="line.215"></a>
+<span class="sourceLineNo">216</span>      } else {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        if (candidateIdx == tableRegions.size()-1) {<a name="line.217"></a>
+<span class="sourceLineNo">218</span>          break;<a name="line.218"></a>
+<span class="sourceLineNo">219</span>        }<a name="line.219"></a>
+<span class="sourceLineNo">220</span>        if (mergeEnabled) {<a name="line.220"></a>
+<span class="sourceLineNo">221</span>          RegionInfo hri2 = tableRegions.get(candidateIdx+1);<a name="line.221"></a>
+<span class="sourceLineNo">222</span>          long regionSize2 = getRegionSize(hri2);<a name="line.222"></a>
+<span class="sourceLineNo">223</span>          if (regionSize &gt;= 0 &amp;&amp; regionSize2 &gt;= 0 &amp;&amp; regionSize + regionSize2 &lt; avgRegionSize) {<a name="line.223"></a>
+<span class="sourceLineNo">224</span>            LOG.info("Table " + table + ", small region size: " + regionSize<a name="line.224"></a>
+<span class="sourceLineNo">225</span>              + " plus its neighbor size: " + regionSize2<a name="line.225"></a>
+<span class="sourceLineNo">226</span>              + ", less than the avg size " + avgRegionSize + ", merging them");<a name="line.226"></a>
+<span class="sourceLineNo">227</span>            plans.add(new MergeNormalizationPlan(hri, hri2));<a name="line.227"></a>
+<span class="sourceLineNo">228</span>            candidateIdx++;<a name="line.228"></a>
+<span class="sourceLineNo">229</span>          }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>        }<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      }<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      candidateIdx++;<a name="line.232"></a>
+<span class="sourceLineNo">233</span>    }<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    if (plans.isEmpty()) {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>      LOG.debug("No normalization needed, regions look good for table: " + table);<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      return null;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    }<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    Collections.sort(plans, planComparator);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    return plans;<a name="line.239"></a>
+<span class="sourceLineNo">240</span>  }<a name="line.240"></a>
+<span class="sourceLineNo">241</span><a name="line.241"></a>
+<span class="sourceLineNo">242</span>  private long getRegionSize(RegionInfo hri) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>    ServerName sn = masterServices.getAssignmentManager().getRegionStates().<a name="line.243"></a>
+<span class="sourceLineNo">244</span>      getRegionServerOfRegion(hri);<a name="line.244"></a>
+<span class="sourceLineNo">245</span>    RegionMetrics regionLoad = masterServices.getServerManager().getLoad(sn).<a name="line.245"></a>
+<span class="sourceLineNo">246</span>      getRegionMetrics().get(hri.getRegionName());<a name="line.246"></a>
+<span class="sourceLineNo">247</span>    if (regionLoad == null) {<a name="line.247"></a>
+<span class="sourceLineNo">248</span>      LOG.debug(hri.getRegionNameAsString() + " was not found in RegionsLoad");<a name="line.248"></a>
+<span class="sourceLineNo">249</span>      return -1;<a name="line.249"></a>
+<span class="sourceLineNo">250</span>    }<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    return (long) regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>  }<a name="line.252"></a>
+<span class="sourceLineNo">253</span>}<a name="line.253"></a>
 
 
 


Mime
View raw message