hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [19/34] hbase-site git commit: Published site at .
Date Tue, 03 Oct 2017 15:14:02 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/73598816/devapidocs/src-html/org/apache/hadoop/hbase/client/ClientSideRegionScanner.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/ClientSideRegionScanner.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/ClientSideRegionScanner.html
index 7fae08f..ab87d1f 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/ClientSideRegionScanner.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/ClientSideRegionScanner.html
@@ -94,37 +94,38 @@
 <span class="sourceLineNo">086</span>        resultSize += CellUtil.estimatedSerializedSizeOf(cell);<a name="line.86"></a>
 <span class="sourceLineNo">087</span>      }<a name="line.87"></a>
 <span class="sourceLineNo">088</span>      this.scanMetrics.countOfBytesInResults.addAndGet(resultSize);<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    }<a name="line.89"></a>
-<span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>    return result;<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 void close() {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    if (this.scanner != null) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>      try {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        this.scanner.close();<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        this.scanner = null;<a name="line.99"></a>
-<span class="sourceLineNo">100</span>      } catch (IOException ex) {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>        LOG.warn("Exception while closing scanner", ex);<a name="line.101"></a>
-<span class="sourceLineNo">102</span>      }<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    }<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    if (this.region != null) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      try {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        this.region.closeRegionOperation();<a name="line.106"></a>
-<span class="sourceLineNo">107</span>        this.region.close(true);<a name="line.107"></a>
-<span class="sourceLineNo">108</span>        this.region = null;<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      } catch (IOException ex) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>        LOG.warn("Exception while closing region", ex);<a name="line.110"></a>
-<span class="sourceLineNo">111</span>      }<a name="line.111"></a>
-<span class="sourceLineNo">112</span>    }<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>  @Override<a name="line.115"></a>
-<span class="sourceLineNo">116</span>  public boolean renewLease() {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    throw new UnsupportedOperationException();<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">089</span>      this.scanMetrics.countOfRowsScanned.incrementAndGet();<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>    return result;<a name="line.92"></a>
+<span class="sourceLineNo">093</span>  }<a name="line.93"></a>
+<span class="sourceLineNo">094</span><a name="line.94"></a>
+<span class="sourceLineNo">095</span>  @Override<a name="line.95"></a>
+<span class="sourceLineNo">096</span>  public void close() {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    if (this.scanner != null) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      try {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        this.scanner.close();<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        this.scanner = null;<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      } catch (IOException ex) {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        LOG.warn("Exception while closing scanner", ex);<a name="line.102"></a>
+<span class="sourceLineNo">103</span>      }<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    if (this.region != null) {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      try {<a name="line.106"></a>
+<span class="sourceLineNo">107</span>        this.region.closeRegionOperation();<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        this.region.close(true);<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        this.region = null;<a name="line.109"></a>
+<span class="sourceLineNo">110</span>      } catch (IOException ex) {<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        LOG.warn("Exception while closing region", ex);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>      }<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>  @Override<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  public boolean renewLease() {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    throw new UnsupportedOperationException();<a name="line.118"></a>
+<span class="sourceLineNo">119</span>  }<a name="line.119"></a>
+<span class="sourceLineNo">120</span>}<a name="line.120"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/73598816/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionReplicaUtil.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionReplicaUtil.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionReplicaUtil.html
index aa8960b..9ffd2a7 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionReplicaUtil.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/RegionReplicaUtil.html
@@ -26,146 +26,176 @@
 <span class="sourceLineNo">018</span><a name="line.18"></a>
 <span class="sourceLineNo">019</span>package org.apache.hadoop.hbase.client;<a name="line.19"></a>
 <span class="sourceLineNo">020</span><a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.Collection;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.Iterator;<a name="line.22"></a>
-<span class="sourceLineNo">023</span><a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.25"></a>
-<span class="sourceLineNo">026</span><a name="line.26"></a>
-<span class="sourceLineNo">027</span>/**<a name="line.27"></a>
-<span class="sourceLineNo">028</span> * Utility methods which contain the logic for regions and replicas.<a name="line.28"></a>
-<span class="sourceLineNo">029</span> */<a name="line.29"></a>
-<span class="sourceLineNo">030</span>@InterfaceAudience.Private<a name="line.30"></a>
-<span class="sourceLineNo">031</span>public class RegionReplicaUtil {<a name="line.31"></a>
-<span class="sourceLineNo">032</span><a name="line.32"></a>
-<span class="sourceLineNo">033</span>  /**<a name="line.33"></a>
-<span class="sourceLineNo">034</span>   * Whether or not the secondary region will wait for observing a flush / region open event<a name="line.34"></a>
-<span class="sourceLineNo">035</span>   * from the primary region via async wal replication before enabling read requests. Since replayed<a name="line.35"></a>
-<span class="sourceLineNo">036</span>   * edits from async wal replication from primary is not persisted in WAL, the memstore of the<a name="line.36"></a>
-<span class="sourceLineNo">037</span>   * secondary region might be non-empty at the time of close or crash. For ensuring seqId's not<a name="line.37"></a>
-<span class="sourceLineNo">038</span>   * "going back in time" in the secondary region replica, this should be enabled. However, in some<a name="line.38"></a>
-<span class="sourceLineNo">039</span>   * cases the above semantics might be ok for some application classes.<a name="line.39"></a>
-<span class="sourceLineNo">040</span>   * See HBASE-11580 for more context.<a name="line.40"></a>
-<span class="sourceLineNo">041</span>   */<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  public static final String REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH_CONF_KEY<a name="line.42"></a>
-<span class="sourceLineNo">043</span>    = "hbase.region.replica.wait.for.primary.flush";<a name="line.43"></a>
-<span class="sourceLineNo">044</span>  protected static final boolean DEFAULT_REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH = true;<a name="line.44"></a>
-<span class="sourceLineNo">045</span><a name="line.45"></a>
-<span class="sourceLineNo">046</span>  /**<a name="line.46"></a>
-<span class="sourceLineNo">047</span>   * The default replicaId for the region<a name="line.47"></a>
-<span class="sourceLineNo">048</span>   */<a name="line.48"></a>
-<span class="sourceLineNo">049</span>  static final int DEFAULT_REPLICA_ID = 0;<a name="line.49"></a>
-<span class="sourceLineNo">050</span><a name="line.50"></a>
-<span class="sourceLineNo">051</span>  /**<a name="line.51"></a>
-<span class="sourceLineNo">052</span>   * Returns the RegionInfo for the given replicaId.<a name="line.52"></a>
-<span class="sourceLineNo">053</span>   * RegionInfo's correspond to a range of a table, but more than one<a name="line.53"></a>
-<span class="sourceLineNo">054</span>   * "instance" of the same range can be deployed which are differentiated by<a name="line.54"></a>
-<span class="sourceLineNo">055</span>   * the replicaId.<a name="line.55"></a>
-<span class="sourceLineNo">056</span>   * @param regionInfo<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   * @param replicaId the replicaId to use<a name="line.57"></a>
-<span class="sourceLineNo">058</span>   * @return an RegionInfo object corresponding to the same range (table, start and<a name="line.58"></a>
-<span class="sourceLineNo">059</span>   * end key), but for the given replicaId.<a name="line.59"></a>
-<span class="sourceLineNo">060</span>   */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  public static RegionInfo getRegionInfoForReplica(RegionInfo regionInfo, int replicaId) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>    if (regionInfo.getReplicaId() == replicaId) {<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      return regionInfo;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    }<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>    if (regionInfo.isMetaRegion()) {<a name="line.66"></a>
-<span class="sourceLineNo">067</span>      return RegionInfoBuilder.newBuilder(regionInfo.getTable())<a name="line.67"></a>
-<span class="sourceLineNo">068</span>          .setRegionId(regionInfo.getRegionId())<a name="line.68"></a>
-<span class="sourceLineNo">069</span>          .setReplicaId(replicaId)<a name="line.69"></a>
-<span class="sourceLineNo">070</span>          .setOffline(regionInfo.isOffline())<a name="line.70"></a>
-<span class="sourceLineNo">071</span>          .build();<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    } else {<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      return RegionInfoBuilder.newBuilder(regionInfo.getTable())<a name="line.73"></a>
-<span class="sourceLineNo">074</span>              .setStartKey(regionInfo.getStartKey())<a name="line.74"></a>
-<span class="sourceLineNo">075</span>              .setEndKey(regionInfo.getEndKey())<a name="line.75"></a>
-<span class="sourceLineNo">076</span>              .setSplit(regionInfo.isSplit())<a name="line.76"></a>
-<span class="sourceLineNo">077</span>              .setRegionId(regionInfo.getRegionId())<a name="line.77"></a>
-<span class="sourceLineNo">078</span>              .setReplicaId(replicaId)<a name="line.78"></a>
-<span class="sourceLineNo">079</span>              .setOffline(regionInfo.isOffline())<a name="line.79"></a>
-<span class="sourceLineNo">080</span>              .build();<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    }<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>  /**<a name="line.84"></a>
-<span class="sourceLineNo">085</span>   * Returns the RegionInfo for the default replicaId (0). RegionInfo's correspond to<a name="line.85"></a>
-<span class="sourceLineNo">086</span>   * a range of a table, but more than one "instance" of the same range can be<a name="line.86"></a>
-<span class="sourceLineNo">087</span>   * deployed which are differentiated by the replicaId.<a name="line.87"></a>
-<span class="sourceLineNo">088</span>   * @return an RegionInfo object corresponding to the same range (table, start and<a name="line.88"></a>
-<span class="sourceLineNo">089</span>   * end key), but for the default replicaId.<a name="line.89"></a>
-<span class="sourceLineNo">090</span>   */<a name="line.90"></a>
-<span class="sourceLineNo">091</span>  public static RegionInfo getRegionInfoForDefaultReplica(RegionInfo regionInfo) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    return getRegionInfoForReplica(regionInfo, DEFAULT_REPLICA_ID);<a name="line.92"></a>
-<span class="sourceLineNo">093</span>  }<a name="line.93"></a>
-<span class="sourceLineNo">094</span><a name="line.94"></a>
-<span class="sourceLineNo">095</span>  /** @return true if this replicaId corresponds to default replica for the region */<a name="line.95"></a>
-<span class="sourceLineNo">096</span>  public static boolean isDefaultReplica(int replicaId) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    return DEFAULT_REPLICA_ID == replicaId;<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>  /** @return true if this region is a default replica for the region */<a name="line.100"></a>
-<span class="sourceLineNo">101</span>  public static boolean isDefaultReplica(RegionInfo hri) {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    return  hri.getReplicaId() == DEFAULT_REPLICA_ID;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>  }<a name="line.103"></a>
-<span class="sourceLineNo">104</span><a name="line.104"></a>
-<span class="sourceLineNo">105</span>  /**<a name="line.105"></a>
-<span class="sourceLineNo">106</span>   * Removes the non-default replicas from the passed regions collection<a name="line.106"></a>
-<span class="sourceLineNo">107</span>   * @param regions<a name="line.107"></a>
-<span class="sourceLineNo">108</span>   */<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  public static void removeNonDefaultRegions(Collection&lt;RegionInfo&gt; regions) {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    Iterator&lt;RegionInfo&gt; iterator = regions.iterator();<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    while (iterator.hasNext()) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      RegionInfo hri = iterator.next();<a name="line.112"></a>
-<span class="sourceLineNo">113</span>      if (!RegionReplicaUtil.isDefaultReplica(hri)) {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>        iterator.remove();<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>  public static boolean isReplicasForSameRegion(RegionInfo regionInfoA, RegionInfo regionInfoB) {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    return compareRegionInfosWithoutReplicaId(regionInfoA, regionInfoB) == 0;<a name="line.120"></a>
-<span class="sourceLineNo">121</span>  }<a name="line.121"></a>
-<span class="sourceLineNo">122</span><a name="line.122"></a>
-<span class="sourceLineNo">123</span>  private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      RegionInfo regionInfoB) {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    if (result != 0) {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      return result;<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    }<a name="line.128"></a>
-<span class="sourceLineNo">129</span><a name="line.129"></a>
-<span class="sourceLineNo">130</span>    // Compare start keys.<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    result = Bytes.compareTo(regionInfoA.getStartKey(), regionInfoB.getStartKey());<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    if (result != 0) {<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      return result;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    }<a name="line.134"></a>
-<span class="sourceLineNo">135</span><a name="line.135"></a>
-<span class="sourceLineNo">136</span>    // Compare end keys.<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    result = Bytes.compareTo(regionInfoA.getEndKey(), regionInfoB.getEndKey());<a name="line.137"></a>
-<span class="sourceLineNo">138</span><a name="line.138"></a>
-<span class="sourceLineNo">139</span>    if (result != 0) {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      if (regionInfoA.getStartKey().length != 0<a name="line.140"></a>
-<span class="sourceLineNo">141</span>              &amp;&amp; regionInfoA.getEndKey().length == 0) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>          return 1; // this is last region<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      }<a name="line.143"></a>
-<span class="sourceLineNo">144</span>      if (regionInfoB.getStartKey().length != 0<a name="line.144"></a>
-<span class="sourceLineNo">145</span>              &amp;&amp; regionInfoB.getEndKey().length == 0) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>          return -1; // o is the last region<a name="line.146"></a>
-<span class="sourceLineNo">147</span>      }<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      return result;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    }<a name="line.149"></a>
-<span class="sourceLineNo">150</span><a name="line.150"></a>
-<span class="sourceLineNo">151</span>    // regionId is usually milli timestamp -- this defines older stamps<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    // to be "smaller" than newer stamps in sort order.<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    if (regionInfoA.getRegionId() &gt; regionInfoB.getRegionId()) {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      return 1;<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    } else if (regionInfoA.getRegionId() &lt; regionInfoB.getRegionId()) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      return -1;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    return 0;<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">021</span>import java.util.ArrayList;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.Collection;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.util.Iterator;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.List;<a name="line.24"></a>
+<span class="sourceLineNo">025</span><a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.27"></a>
+<span class="sourceLineNo">028</span><a name="line.28"></a>
+<span class="sourceLineNo">029</span>/**<a name="line.29"></a>
+<span class="sourceLineNo">030</span> * Utility methods which contain the logic for regions and replicas.<a name="line.30"></a>
+<span class="sourceLineNo">031</span> */<a name="line.31"></a>
+<span class="sourceLineNo">032</span>@InterfaceAudience.Private<a name="line.32"></a>
+<span class="sourceLineNo">033</span>public class RegionReplicaUtil {<a name="line.33"></a>
+<span class="sourceLineNo">034</span><a name="line.34"></a>
+<span class="sourceLineNo">035</span>  /**<a name="line.35"></a>
+<span class="sourceLineNo">036</span>   * Whether or not the secondary region will wait for observing a flush / region open event<a name="line.36"></a>
+<span class="sourceLineNo">037</span>   * from the primary region via async wal replication before enabling read requests. Since replayed<a name="line.37"></a>
+<span class="sourceLineNo">038</span>   * edits from async wal replication from primary is not persisted in WAL, the memstore of the<a name="line.38"></a>
+<span class="sourceLineNo">039</span>   * secondary region might be non-empty at the time of close or crash. For ensuring seqId's not<a name="line.39"></a>
+<span class="sourceLineNo">040</span>   * "going back in time" in the secondary region replica, this should be enabled. However, in some<a name="line.40"></a>
+<span class="sourceLineNo">041</span>   * cases the above semantics might be ok for some application classes.<a name="line.41"></a>
+<span class="sourceLineNo">042</span>   * See HBASE-11580 for more context.<a name="line.42"></a>
+<span class="sourceLineNo">043</span>   */<a name="line.43"></a>
+<span class="sourceLineNo">044</span>  public static final String REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH_CONF_KEY<a name="line.44"></a>
+<span class="sourceLineNo">045</span>    = "hbase.region.replica.wait.for.primary.flush";<a name="line.45"></a>
+<span class="sourceLineNo">046</span>  protected static final boolean DEFAULT_REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH = true;<a name="line.46"></a>
+<span class="sourceLineNo">047</span><a name="line.47"></a>
+<span class="sourceLineNo">048</span>  /**<a name="line.48"></a>
+<span class="sourceLineNo">049</span>   * The default replicaId for the region<a name="line.49"></a>
+<span class="sourceLineNo">050</span>   */<a name="line.50"></a>
+<span class="sourceLineNo">051</span>  static final int DEFAULT_REPLICA_ID = 0;<a name="line.51"></a>
+<span class="sourceLineNo">052</span><a name="line.52"></a>
+<span class="sourceLineNo">053</span>  /**<a name="line.53"></a>
+<span class="sourceLineNo">054</span>   * Returns the RegionInfo for the given replicaId.<a name="line.54"></a>
+<span class="sourceLineNo">055</span>   * RegionInfo's correspond to a range of a table, but more than one<a name="line.55"></a>
+<span class="sourceLineNo">056</span>   * "instance" of the same range can be deployed which are differentiated by<a name="line.56"></a>
+<span class="sourceLineNo">057</span>   * the replicaId.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   * @param regionInfo<a name="line.58"></a>
+<span class="sourceLineNo">059</span>   * @param replicaId the replicaId to use<a name="line.59"></a>
+<span class="sourceLineNo">060</span>   * @return an RegionInfo object corresponding to the same range (table, start and<a name="line.60"></a>
+<span class="sourceLineNo">061</span>   * end key), but for the given replicaId.<a name="line.61"></a>
+<span class="sourceLineNo">062</span>   */<a name="line.62"></a>
+<span class="sourceLineNo">063</span>  public static RegionInfo getRegionInfoForReplica(RegionInfo regionInfo, int replicaId) {<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    if (regionInfo.getReplicaId() == replicaId) {<a name="line.64"></a>
+<span class="sourceLineNo">065</span>      return regionInfo;<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    }<a name="line.66"></a>
+<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">068</span>    if (regionInfo.isMetaRegion()) {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      return RegionInfoBuilder.newBuilder(regionInfo.getTable())<a name="line.69"></a>
+<span class="sourceLineNo">070</span>          .setRegionId(regionInfo.getRegionId())<a name="line.70"></a>
+<span class="sourceLineNo">071</span>          .setReplicaId(replicaId)<a name="line.71"></a>
+<span class="sourceLineNo">072</span>          .setOffline(regionInfo.isOffline())<a name="line.72"></a>
+<span class="sourceLineNo">073</span>          .build();<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    } else {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      return RegionInfoBuilder.newBuilder(regionInfo.getTable())<a name="line.75"></a>
+<span class="sourceLineNo">076</span>              .setStartKey(regionInfo.getStartKey())<a name="line.76"></a>
+<span class="sourceLineNo">077</span>              .setEndKey(regionInfo.getEndKey())<a name="line.77"></a>
+<span class="sourceLineNo">078</span>              .setSplit(regionInfo.isSplit())<a name="line.78"></a>
+<span class="sourceLineNo">079</span>              .setRegionId(regionInfo.getRegionId())<a name="line.79"></a>
+<span class="sourceLineNo">080</span>              .setReplicaId(replicaId)<a name="line.80"></a>
+<span class="sourceLineNo">081</span>              .setOffline(regionInfo.isOffline())<a name="line.81"></a>
+<span class="sourceLineNo">082</span>              .build();<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    }<a name="line.83"></a>
+<span class="sourceLineNo">084</span>  }<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>   * Returns the RegionInfo for the default replicaId (0). RegionInfo's correspond to<a name="line.87"></a>
+<span class="sourceLineNo">088</span>   * a range of a table, but more than one "instance" of the same range can be<a name="line.88"></a>
+<span class="sourceLineNo">089</span>   * deployed which are differentiated by the replicaId.<a name="line.89"></a>
+<span class="sourceLineNo">090</span>   * @return an RegionInfo object corresponding to the same range (table, start and<a name="line.90"></a>
+<span class="sourceLineNo">091</span>   * end key), but for the default replicaId.<a name="line.91"></a>
+<span class="sourceLineNo">092</span>   */<a name="line.92"></a>
+<span class="sourceLineNo">093</span>  public static RegionInfo getRegionInfoForDefaultReplica(RegionInfo regionInfo) {<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    return getRegionInfoForReplica(regionInfo, DEFAULT_REPLICA_ID);<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>  /** @return true if this replicaId corresponds to default replica for the region */<a name="line.97"></a>
+<span class="sourceLineNo">098</span>  public static boolean isDefaultReplica(int replicaId) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    return DEFAULT_REPLICA_ID == replicaId;<a name="line.99"></a>
+<span class="sourceLineNo">100</span>  }<a name="line.100"></a>
+<span class="sourceLineNo">101</span><a name="line.101"></a>
+<span class="sourceLineNo">102</span>  /** @return true if this region is a default replica for the region */<a name="line.102"></a>
+<span class="sourceLineNo">103</span>  public static boolean isDefaultReplica(RegionInfo hri) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    return  hri.getReplicaId() == DEFAULT_REPLICA_ID;<a name="line.104"></a>
+<span class="sourceLineNo">105</span>  }<a name="line.105"></a>
+<span class="sourceLineNo">106</span><a name="line.106"></a>
+<span class="sourceLineNo">107</span>  /**<a name="line.107"></a>
+<span class="sourceLineNo">108</span>   * Removes the non-default replicas from the passed regions collection<a name="line.108"></a>
+<span class="sourceLineNo">109</span>   * @param regions<a name="line.109"></a>
+<span class="sourceLineNo">110</span>   */<a name="line.110"></a>
+<span class="sourceLineNo">111</span>  public static void removeNonDefaultRegions(Collection&lt;RegionInfo&gt; regions) {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    Iterator&lt;RegionInfo&gt; iterator = regions.iterator();<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    while (iterator.hasNext()) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>      RegionInfo hri = iterator.next();<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      if (!RegionReplicaUtil.isDefaultReplica(hri)) {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>        iterator.remove();<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><a name="line.120"></a>
+<span class="sourceLineNo">121</span>  public static boolean isReplicasForSameRegion(RegionInfo regionInfoA, RegionInfo regionInfoB) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    return compareRegionInfosWithoutReplicaId(regionInfoA, regionInfoB) == 0;<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  }<a name="line.123"></a>
+<span class="sourceLineNo">124</span><a name="line.124"></a>
+<span class="sourceLineNo">125</span>  private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA,<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      RegionInfo regionInfoB) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    int result = regionInfoA.getTable().compareTo(regionInfoB.getTable());<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    if (result != 0) {<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      return result;<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    }<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>    // Compare start keys.<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    result = Bytes.compareTo(regionInfoA.getStartKey(), regionInfoB.getStartKey());<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    if (result != 0) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      return result;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
+<span class="sourceLineNo">137</span><a name="line.137"></a>
+<span class="sourceLineNo">138</span>    // Compare end keys.<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    result = Bytes.compareTo(regionInfoA.getEndKey(), regionInfoB.getEndKey());<a name="line.139"></a>
+<span class="sourceLineNo">140</span><a name="line.140"></a>
+<span class="sourceLineNo">141</span>    if (result != 0) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      if (regionInfoA.getStartKey().length != 0<a name="line.142"></a>
+<span class="sourceLineNo">143</span>              &amp;&amp; regionInfoA.getEndKey().length == 0) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>          return 1; // this is last region<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>      if (regionInfoB.getStartKey().length != 0<a name="line.146"></a>
+<span class="sourceLineNo">147</span>              &amp;&amp; regionInfoB.getEndKey().length == 0) {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>          return -1; // o is the last region<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      }<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      return result;<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    }<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    // regionId is usually milli timestamp -- this defines older stamps<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    // to be "smaller" than newer stamps in sort order.<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    if (regionInfoA.getRegionId() &gt; regionInfoB.getRegionId()) {<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      return 1;<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    } else if (regionInfoA.getRegionId() &lt; regionInfoB.getRegionId()) {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      return -1;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    }<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    return 0;<a name="line.160"></a>
+<span class="sourceLineNo">161</span>  }<a name="line.161"></a>
+<span class="sourceLineNo">162</span><a name="line.162"></a>
+<span class="sourceLineNo">163</span>  /**<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   * Create any replicas for the regions (the default replicas that was already created is passed to<a name="line.164"></a>
+<span class="sourceLineNo">165</span>   * the method)<a name="line.165"></a>
+<span class="sourceLineNo">166</span>   * @param tableDescriptor descriptor to use<a name="line.166"></a>
+<span class="sourceLineNo">167</span>   * @param regions existing regions<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   * @param oldReplicaCount existing replica count<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * @param newReplicaCount updated replica count due to modify table<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   * @return the combined list of default and non-default replicas<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   */<a name="line.171"></a>
+<span class="sourceLineNo">172</span>  public static List&lt;RegionInfo&gt; addReplicas(final TableDescriptor tableDescriptor,<a name="line.172"></a>
+<span class="sourceLineNo">173</span>      final List&lt;RegionInfo&gt; regions, int oldReplicaCount, int newReplicaCount) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    if ((newReplicaCount - 1) &lt;= 0) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      return regions;<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    }<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    List&lt;RegionInfo&gt; hRegionInfos = new ArrayList&lt;&gt;((newReplicaCount) * regions.size());<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    for (int i = 0; i &lt; regions.size(); i++) {<a name="line.178"></a>
+<span class="sourceLineNo">179</span>      if (RegionReplicaUtil.isDefaultReplica(regions.get(i))) {<a name="line.179"></a>
+<span class="sourceLineNo">180</span>        // region level replica index starts from 0. So if oldReplicaCount was 2 then the max replicaId for<a name="line.180"></a>
+<span class="sourceLineNo">181</span>        // the existing regions would be 1<a name="line.181"></a>
+<span class="sourceLineNo">182</span>        for (int j = oldReplicaCount; j &lt; newReplicaCount; j++) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>          hRegionInfos.add(RegionReplicaUtil.getRegionInfoForReplica(regions.get(i), j));<a name="line.183"></a>
+<span class="sourceLineNo">184</span>        }<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    }<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    hRegionInfos.addAll(regions);<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    return hRegionInfos;<a name="line.188"></a>
+<span class="sourceLineNo">189</span>  }<a name="line.189"></a>
+<span class="sourceLineNo">190</span>}<a name="line.190"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/73598816/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/MasterObserver.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/MasterObserver.html b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/MasterObserver.html
index c19d2e7..0e35e20 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/MasterObserver.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/coprocessor/MasterObserver.html
@@ -704,25 +704,25 @@
 <span class="sourceLineNo">696</span>      final RegionInfo regionInfoB) throws IOException {}<a name="line.696"></a>
 <span class="sourceLineNo">697</span><a name="line.697"></a>
 <span class="sourceLineNo">698</span>  /**<a name="line.698"></a>
-<span class="sourceLineNo">699</span>   * This will be called before PONR step as part of split transaction. Calling<a name="line.699"></a>
+<span class="sourceLineNo">699</span>   * This will be called before update META step as part of split transaction. Calling<a name="line.699"></a>
 <span class="sourceLineNo">700</span>   * {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} rollback the split<a name="line.700"></a>
 <span class="sourceLineNo">701</span>   * @param ctx the environment to interact with the framework and master<a name="line.701"></a>
 <span class="sourceLineNo">702</span>   * @param splitKey<a name="line.702"></a>
 <span class="sourceLineNo">703</span>   * @param metaEntries<a name="line.703"></a>
 <span class="sourceLineNo">704</span>   */<a name="line.704"></a>
-<span class="sourceLineNo">705</span>  default void preSplitRegionBeforePONRAction(<a name="line.705"></a>
+<span class="sourceLineNo">705</span>  default void preSplitRegionBeforeMETAAction(<a name="line.705"></a>
 <span class="sourceLineNo">706</span>      final ObserverContext&lt;MasterCoprocessorEnvironment&gt; ctx,<a name="line.706"></a>
 <span class="sourceLineNo">707</span>      final byte[] splitKey,<a name="line.707"></a>
 <span class="sourceLineNo">708</span>      final List&lt;Mutation&gt; metaEntries) throws IOException {}<a name="line.708"></a>
 <span class="sourceLineNo">709</span><a name="line.709"></a>
 <span class="sourceLineNo">710</span><a name="line.710"></a>
 <span class="sourceLineNo">711</span>  /**<a name="line.711"></a>
-<span class="sourceLineNo">712</span>   * This will be called after PONR step as part of split transaction<a name="line.712"></a>
+<span class="sourceLineNo">712</span>   * This will be called after update META step as part of split transaction<a name="line.712"></a>
 <span class="sourceLineNo">713</span>   * Calling {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no<a name="line.713"></a>
 <span class="sourceLineNo">714</span>   * effect in this hook.<a name="line.714"></a>
 <span class="sourceLineNo">715</span>   * @param ctx the environment to interact with the framework and master<a name="line.715"></a>
 <span class="sourceLineNo">716</span>   */<a name="line.716"></a>
-<span class="sourceLineNo">717</span>  default void preSplitRegionAfterPONRAction(<a name="line.717"></a>
+<span class="sourceLineNo">717</span>  default void preSplitRegionAfterMETAAction(<a name="line.717"></a>
 <span class="sourceLineNo">718</span>      final ObserverContext&lt;MasterCoprocessorEnvironment&gt; ctx)<a name="line.718"></a>
 <span class="sourceLineNo">719</span>      throws IOException {}<a name="line.719"></a>
 <span class="sourceLineNo">720</span><a name="line.720"></a>
@@ -753,7 +753,7 @@
 <span class="sourceLineNo">745</span>      final RegionInfo mergedRegion) throws IOException {}<a name="line.745"></a>
 <span class="sourceLineNo">746</span><a name="line.746"></a>
 <span class="sourceLineNo">747</span>  /**<a name="line.747"></a>
-<span class="sourceLineNo">748</span>   * This will be called before PONR step as part of regions merge transaction. Calling<a name="line.748"></a>
+<span class="sourceLineNo">748</span>   * This will be called before update META step as part of regions merge transaction. Calling<a name="line.748"></a>
 <span class="sourceLineNo">749</span>   * {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} rollback the merge<a name="line.749"></a>
 <span class="sourceLineNo">750</span>   * @param ctx the environment to interact with the framework and master<a name="line.750"></a>
 <span class="sourceLineNo">751</span>   * @param metaEntries mutations to execute on hbase:meta atomically with regions merge updates.<a name="line.751"></a>
@@ -765,7 +765,7 @@
 <span class="sourceLineNo">757</span>      @MetaMutationAnnotation List&lt;Mutation&gt; metaEntries) throws IOException {}<a name="line.757"></a>
 <span class="sourceLineNo">758</span><a name="line.758"></a>
 <span class="sourceLineNo">759</span>  /**<a name="line.759"></a>
-<span class="sourceLineNo">760</span>   * This will be called after PONR step as part of regions merge transaction.<a name="line.760"></a>
+<span class="sourceLineNo">760</span>   * This will be called after META step as part of regions merge transaction.<a name="line.760"></a>
 <span class="sourceLineNo">761</span>   * @param ctx the environment to interact with the framework and master<a name="line.761"></a>
 <span class="sourceLineNo">762</span>   */<a name="line.762"></a>
 <span class="sourceLineNo">763</span>  default void postMergeRegionsCommitAction(<a name="line.763"></a>


Mime
View raw message