http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c91fafb4/devapidocs/src-html/org/apache/hadoop/hbase/RegionLocations.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/RegionLocations.html 
b/devapidocs/src-html/org/apache/hadoop/hbase/RegionLocations.html
index a68b27b..32c122b 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/RegionLocations.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/RegionLocations.html
@@ -64,309 +64,310 @@
 <span class="sourceLineNo">056</span>    int index = 0;<a name="line.56"></a>
 <span class="sourceLineNo">057</span>    for (HRegionLocation loc : locations) 
{<a name="line.57"></a>
 <span class="sourceLineNo">058</span>      if (loc != null) {<a 
name="line.58"></a>
-<span class="sourceLineNo">059</span>        if (loc.getServerName() != null) 
{<a name="line.59"></a>
-<span class="sourceLineNo">060</span>          numNonNullElements++;<a 
name="line.60"></a>
-<span class="sourceLineNo">061</span>        }<a name="line.61"></a>
-<span class="sourceLineNo">062</span>        if 
(loc.getRegionInfo().getReplicaId() &gt;= maxReplicaId) {<a name="line.62"></a>
-<span class="sourceLineNo">063</span>          maxReplicaId = 
loc.getRegionInfo().getReplicaId();<a name="line.63"></a>
-<span class="sourceLineNo">064</span>          maxReplicaIdIndex = index;<a 
name="line.64"></a>
-<span class="sourceLineNo">065</span>        }<a name="line.65"></a>
-<span class="sourceLineNo">066</span>      }<a name="line.66"></a>
-<span class="sourceLineNo">067</span>      index++;<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    }<a name="line.68"></a>
-<span class="sourceLineNo">069</span>    this.numNonNullElements = 
numNonNullElements;<a name="line.69"></a>
-<span class="sourceLineNo">070</span><a name="line.70"></a>
-<span class="sourceLineNo">071</span>    // account for the null elements in 
the array after maxReplicaIdIndex<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    maxReplicaId = maxReplicaId + 
(locations.length - (maxReplicaIdIndex + 1) );<a name="line.72"></a>
-<span class="sourceLineNo">073</span><a name="line.73"></a>
-<span class="sourceLineNo">074</span>    if (maxReplicaId + 1 == 
locations.length) {<a name="line.74"></a>
-<span class="sourceLineNo">075</span>      this.locations = locations;<a 
name="line.75"></a>
-<span class="sourceLineNo">076</span>    } else {<a name="line.76"></a>
-<span class="sourceLineNo">077</span>      this.locations = new 
HRegionLocation[maxReplicaId + 1];<a name="line.77"></a>
-<span class="sourceLineNo">078</span>      for (HRegionLocation loc : 
locations) {<a name="line.78"></a>
-<span class="sourceLineNo">079</span>        if (loc != null) {<a 
name="line.79"></a>
-<span class="sourceLineNo">080</span>          
this.locations[loc.getRegionInfo().getReplicaId()] = loc;<a name="line.80"></a>
-<span class="sourceLineNo">081</span>        }<a name="line.81"></a>
+<span class="sourceLineNo">059</span>        if 
(loc.getRegionInfo().getReplicaId() &gt;= maxReplicaId) {<a name="line.59"></a>
+<span class="sourceLineNo">060</span>          maxReplicaId = 
loc.getRegionInfo().getReplicaId();<a name="line.60"></a>
+<span class="sourceLineNo">061</span>          maxReplicaIdIndex = index;<a 
name="line.61"></a>
+<span class="sourceLineNo">062</span>        }<a name="line.62"></a>
+<span class="sourceLineNo">063</span>      }<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      index++;<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    }<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    // account for the null elements in 
the array after maxReplicaIdIndex<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    maxReplicaId = maxReplicaId + 
(locations.length - (maxReplicaIdIndex + 1) );<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>    if (maxReplicaId + 1 == 
locations.length) {<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      this.locations = locations;<a 
name="line.70"></a>
+<span class="sourceLineNo">071</span>    } else {<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      this.locations = new 
HRegionLocation[maxReplicaId + 1];<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      for (HRegionLocation loc : 
locations) {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>        if (loc != null) {<a 
name="line.74"></a>
+<span class="sourceLineNo">075</span>          
this.locations[loc.getRegionInfo().getReplicaId()] = loc;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>        }<a name="line.76"></a>
+<span class="sourceLineNo">077</span>      }<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    }<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    for (HRegionLocation loc : 
this.locations) {<a name="line.79"></a>
+<span class="sourceLineNo">080</span>      if (loc != null &amp;&amp; 
loc.getServerName() != null){<a name="line.80"></a>
+<span class="sourceLineNo">081</span>        numNonNullElements++;<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><a name="line.85"></a>
-<span class="sourceLineNo">086</span>  public 
RegionLocations(Collection&lt;HRegionLocation&gt; locations) {<a 
name="line.86"></a>
-<span class="sourceLineNo">087</span>    this(locations.toArray(new 
HRegionLocation[locations.size()]));<a name="line.87"></a>
-<span class="sourceLineNo">088</span>  }<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>   * Returns the size of the list even if 
some of the elements<a name="line.91"></a>
-<span class="sourceLineNo">092</span>   * might be null.<a name="line.92"></a>
-<span class="sourceLineNo">093</span>   * @return the size of the list 
(corresponding to the max replicaId)<a name="line.93"></a>
-<span class="sourceLineNo">094</span>   */<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  public int size() {<a 
name="line.95"></a>
-<span class="sourceLineNo">096</span>    return locations.length;<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>   * Returns the size of not-null 
locations<a name="line.100"></a>
-<span class="sourceLineNo">101</span>   * @return the size of not-null 
locations<a name="line.101"></a>
-<span class="sourceLineNo">102</span>   */<a name="line.102"></a>
-<span class="sourceLineNo">103</span>  public int numNonNullElements() {<a 
name="line.103"></a>
-<span class="sourceLineNo">104</span>    return numNonNullElements;<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>   * Returns whether there are non-null 
elements in the list<a name="line.108"></a>
-<span class="sourceLineNo">109</span>   * @return whether there are non-null 
elements in the list<a name="line.109"></a>
-<span class="sourceLineNo">110</span>   */<a name="line.110"></a>
-<span class="sourceLineNo">111</span>  public boolean isEmpty() {<a 
name="line.111"></a>
-<span class="sourceLineNo">112</span>    return numNonNullElements == 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>   * Returns a new RegionLocations with 
the locations removed (set to null)<a name="line.116"></a>
-<span class="sourceLineNo">117</span>   * which have the destination server as 
given.<a name="line.117"></a>
-<span class="sourceLineNo">118</span>   * @param serverName the serverName to 
remove locations of<a name="line.118"></a>
-<span class="sourceLineNo">119</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.119"></a>
-<span class="sourceLineNo">120</span>   * if nothing is removed<a 
name="line.120"></a>
-<span class="sourceLineNo">121</span>   */<a name="line.121"></a>
-<span class="sourceLineNo">122</span>  public RegionLocations 
removeByServer(ServerName serverName) {<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    HRegionLocation[] newLocations = 
null;<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    for (int i = 0; i &lt; 
locations.length; i++) {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      // check whether something to 
remove<a name="line.125"></a>
-<span class="sourceLineNo">126</span>      if (locations[i] != null &amp;&amp; 
serverName.equals(locations[i].getServerName())) {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>        if (newLocations == null) { 
//first time<a name="line.127"></a>
-<span class="sourceLineNo">128</span>          newLocations = new 
HRegionLocation[locations.length];<a name="line.128"></a>
-<span class="sourceLineNo">129</span>          System.arraycopy(locations, 0, 
newLocations, 0, i);<a name="line.129"></a>
-<span class="sourceLineNo">130</span>        }<a name="line.130"></a>
-<span class="sourceLineNo">131</span>        newLocations[i] = null;<a 
name="line.131"></a>
-<span class="sourceLineNo">132</span>      } else if (newLocations != null) 
{<a name="line.132"></a>
-<span class="sourceLineNo">133</span>        newLocations[i] = locations[i];<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>    return newLocations == null ? this : 
new RegionLocations(newLocations);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>  }<a name="line.137"></a>
-<span class="sourceLineNo">138</span><a name="line.138"></a>
-<span class="sourceLineNo">139</span>  /**<a name="line.139"></a>
-<span class="sourceLineNo">140</span>   * Removes the given location from the 
list<a name="line.140"></a>
-<span class="sourceLineNo">141</span>   * @param location the location to 
remove<a name="line.141"></a>
-<span class="sourceLineNo">142</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.142"></a>
-<span class="sourceLineNo">143</span>   * if nothing is removed<a 
name="line.143"></a>
-<span class="sourceLineNo">144</span>   */<a name="line.144"></a>
-<span class="sourceLineNo">145</span>  public RegionLocations 
remove(HRegionLocation location) {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    if (location == null) return this;<a 
name="line.146"></a>
-<span class="sourceLineNo">147</span>    if (location.getRegion() == null) 
return this;<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    int replicaId = 
location.getRegionInfo().getReplicaId();<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    if (replicaId &gt;= locations.length) 
return this;<a name="line.149"></a>
-<span class="sourceLineNo">150</span><a name="line.150"></a>
-<span class="sourceLineNo">151</span>    // check whether something to remove. 
HRL.compareTo() compares ONLY the<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    // serverName. We want to compare the 
HRI's as well.<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    if (locations[replicaId] == null<a 
name="line.153"></a>
-<span class="sourceLineNo">154</span>        || 
RegionInfo.COMPARATOR.compare(location.getRegion(), 
locations[replicaId].getRegion()) != 0<a name="line.154"></a>
-<span class="sourceLineNo">155</span>        || 
!location.equals(locations[replicaId])) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      return this;<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>    HRegionLocation[] newLocations = new 
HRegionLocation[locations.length];<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    newLocations[replicaId] = null;<a 
name="line.161"></a>
-<span class="sourceLineNo">162</span><a name="line.162"></a>
-<span class="sourceLineNo">163</span>    return new 
RegionLocations(newLocations);<a name="line.163"></a>
-<span class="sourceLineNo">164</span>  }<a name="line.164"></a>
-<span class="sourceLineNo">165</span><a name="line.165"></a>
-<span class="sourceLineNo">166</span>  /**<a name="line.166"></a>
-<span class="sourceLineNo">167</span>   * Removes location of the given 
replicaId from the list<a name="line.167"></a>
-<span class="sourceLineNo">168</span>   * @param replicaId the replicaId of 
the location to remove<a name="line.168"></a>
-<span class="sourceLineNo">169</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.169"></a>
-<span class="sourceLineNo">170</span>   * if nothing is removed<a 
name="line.170"></a>
-<span class="sourceLineNo">171</span>   */<a name="line.171"></a>
-<span class="sourceLineNo">172</span>  public RegionLocations remove(int 
replicaId) {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    if (getRegionLocation(replicaId) == 
null) {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>      return this;<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    }<a name="line.175"></a>
-<span class="sourceLineNo">176</span><a name="line.176"></a>
-<span class="sourceLineNo">177</span>    HRegionLocation[] newLocations = new 
HRegionLocation[locations.length];<a name="line.177"></a>
-<span class="sourceLineNo">178</span><a name="line.178"></a>
-<span class="sourceLineNo">179</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.179"></a>
-<span class="sourceLineNo">180</span>    if (replicaId &lt; 
newLocations.length) {<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      newLocations[replicaId] = null;<a 
name="line.181"></a>
-<span class="sourceLineNo">182</span>    }<a name="line.182"></a>
-<span class="sourceLineNo">183</span><a name="line.183"></a>
-<span class="sourceLineNo">184</span>    return new 
RegionLocations(newLocations);<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>  /**<a name="line.187"></a>
-<span class="sourceLineNo">188</span>   * Merges this RegionLocations list 
with the given list assuming<a name="line.188"></a>
-<span class="sourceLineNo">189</span>   * same range, and keeping the most up 
to date version of the<a name="line.189"></a>
-<span class="sourceLineNo">190</span>   * HRegionLocation entries from either 
list according to seqNum. If seqNums<a name="line.190"></a>
-<span class="sourceLineNo">191</span>   * are equal, the location from the 
argument (other) is taken.<a name="line.191"></a>
-<span class="sourceLineNo">192</span>   * @param other the locations to merge 
with<a name="line.192"></a>
-<span class="sourceLineNo">193</span>   * @return an RegionLocations object 
with merged locations or the same object<a name="line.193"></a>
-<span class="sourceLineNo">194</span>   * if nothing is merged<a 
name="line.194"></a>
-<span class="sourceLineNo">195</span>   */<a name="line.195"></a>
-<span class="sourceLineNo">196</span>  public RegionLocations 
mergeLocations(RegionLocations other) {<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    assert other != null;<a 
name="line.197"></a>
-<span class="sourceLineNo">198</span><a name="line.198"></a>
-<span class="sourceLineNo">199</span>    HRegionLocation[] newLocations = 
null;<a name="line.199"></a>
-<span class="sourceLineNo">200</span><a name="line.200"></a>
-<span class="sourceLineNo">201</span>    // Use the length from other, since 
it is coming from meta. Otherwise,<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    // in case of region replication 
going down, we might have a leak here.<a name="line.202"></a>
-<span class="sourceLineNo">203</span>    int max = other.locations.length;<a 
name="line.203"></a>
-<span class="sourceLineNo">204</span><a name="line.204"></a>
-<span class="sourceLineNo">205</span>    HRegionInfo regionInfo = null;<a 
name="line.205"></a>
-<span class="sourceLineNo">206</span>    for (int i = 0; i &lt; max; i++) {<a 
name="line.206"></a>
-<span class="sourceLineNo">207</span>      HRegionLocation thisLoc = 
this.getRegionLocation(i);<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      HRegionLocation otherLoc = 
other.getRegionLocation(i);<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      if (regionInfo == null &amp;&amp; 
otherLoc != null &amp;&amp; otherLoc.getRegionInfo() != null) {<a 
name="line.209"></a>
-<span class="sourceLineNo">210</span>        // regionInfo is the first 
non-null HRI from other RegionLocations. We use it to ensure that<a 
name="line.210"></a>
-<span class="sourceLineNo">211</span>        // all replica region infos 
belong to the same region with same region id.<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        regionInfo = 
otherLoc.getRegionInfo();<a name="line.212"></a>
-<span class="sourceLineNo">213</span>      }<a name="line.213"></a>
-<span class="sourceLineNo">214</span><a name="line.214"></a>
-<span class="sourceLineNo">215</span>      HRegionLocation selectedLoc = 
selectRegionLocation(thisLoc,<a name="line.215"></a>
-<span class="sourceLineNo">216</span>        otherLoc, true, false);<a 
name="line.216"></a>
-<span class="sourceLineNo">217</span><a name="line.217"></a>
-<span class="sourceLineNo">218</span>      if (selectedLoc != thisLoc) {<a 
name="line.218"></a>
-<span class="sourceLineNo">219</span>        if (newLocations == null) {<a 
name="line.219"></a>
-<span class="sourceLineNo">220</span>          newLocations = new 
HRegionLocation[max];<a name="line.220"></a>
-<span class="sourceLineNo">221</span>          System.arraycopy(locations, 0, 
newLocations, 0, i);<a name="line.221"></a>
-<span class="sourceLineNo">222</span>        }<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      }<a name="line.223"></a>
-<span class="sourceLineNo">224</span>      if (newLocations != null) {<a 
name="line.224"></a>
-<span class="sourceLineNo">225</span>        newLocations[i] = selectedLoc;<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">228</span><a name="line.228"></a>
-<span class="sourceLineNo">229</span>    // ensure that all replicas share the 
same start code. Otherwise delete them<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    if (newLocations != null &amp;&amp; 
regionInfo != null) {<a name="line.230"></a>
-<span class="sourceLineNo">231</span>      for (int i=0; i &lt; 
newLocations.length; i++) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>        if (newLocations[i] != null) {<a 
name="line.232"></a>
-<span class="sourceLineNo">233</span>          if 
(!RegionReplicaUtil.isReplicasForSameRegion(regionInfo,<a name="line.233"></a>
-<span class="sourceLineNo">234</span>            
newLocations[i].getRegionInfo())) {<a name="line.234"></a>
-<span class="sourceLineNo">235</span>            newLocations[i] = null;<a 
name="line.235"></a>
-<span class="sourceLineNo">236</span>          }<a name="line.236"></a>
-<span class="sourceLineNo">237</span>        }<a name="line.237"></a>
-<span class="sourceLineNo">238</span>      }<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
-<span class="sourceLineNo">240</span><a name="line.240"></a>
-<span class="sourceLineNo">241</span>    return newLocations == null ? this : 
new RegionLocations(newLocations);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>  }<a name="line.242"></a>
-<span class="sourceLineNo">243</span><a name="line.243"></a>
-<span class="sourceLineNo">244</span>  private HRegionLocation 
selectRegionLocation(HRegionLocation oldLocation,<a name="line.244"></a>
-<span class="sourceLineNo">245</span>      HRegionLocation location, boolean 
checkForEquals, boolean force) {<a name="line.245"></a>
-<span class="sourceLineNo">246</span>    if (location == null) {<a 
name="line.246"></a>
-<span class="sourceLineNo">247</span>      return oldLocation == null ? null : 
oldLocation;<a name="line.247"></a>
-<span class="sourceLineNo">248</span>    }<a name="line.248"></a>
-<span class="sourceLineNo">249</span><a name="line.249"></a>
-<span class="sourceLineNo">250</span>    if (oldLocation == null) {<a 
name="line.250"></a>
-<span class="sourceLineNo">251</span>      return location;<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>
-<span class="sourceLineNo">254</span>    if (force<a name="line.254"></a>
-<span class="sourceLineNo">255</span>        || 
isGreaterThan(location.getSeqNum(), oldLocation.getSeqNum(), checkForEquals)) 
{<a name="line.255"></a>
-<span class="sourceLineNo">256</span>      return location;<a 
name="line.256"></a>
-<span class="sourceLineNo">257</span>    }<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    return oldLocation;<a 
name="line.258"></a>
-<span class="sourceLineNo">259</span>  }<a name="line.259"></a>
-<span class="sourceLineNo">260</span><a name="line.260"></a>
-<span class="sourceLineNo">261</span>  /**<a name="line.261"></a>
-<span class="sourceLineNo">262</span>   * Updates the location with new only 
if the new location has a higher<a name="line.262"></a>
-<span class="sourceLineNo">263</span>   * seqNum than the old one or force is 
true.<a name="line.263"></a>
-<span class="sourceLineNo">264</span>   * @param location the location to add 
or update<a name="line.264"></a>
-<span class="sourceLineNo">265</span>   * @param checkForEquals whether to 
update the location if seqNums for the<a name="line.265"></a>
-<span class="sourceLineNo">266</span>   * HRegionLocations for the old and new 
location are the same<a name="line.266"></a>
-<span class="sourceLineNo">267</span>   * @param force whether to force 
update<a name="line.267"></a>
-<span class="sourceLineNo">268</span>   * @return an RegionLocations object 
with updated locations or the same object<a name="line.268"></a>
-<span class="sourceLineNo">269</span>   * if nothing is updated<a 
name="line.269"></a>
-<span class="sourceLineNo">270</span>   */<a name="line.270"></a>
-<span class="sourceLineNo">271</span>  public RegionLocations 
updateLocation(HRegionLocation location,<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      boolean checkForEquals, boolean 
force) {<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    assert location != null;<a 
name="line.273"></a>
-<span class="sourceLineNo">274</span><a name="line.274"></a>
-<span class="sourceLineNo">275</span>    int replicaId = 
location.getRegionInfo().getReplicaId();<a name="line.275"></a>
-<span class="sourceLineNo">276</span><a name="line.276"></a>
-<span class="sourceLineNo">277</span>    HRegionLocation oldLoc = 
getRegionLocation(location.getRegionInfo().getReplicaId());<a 
name="line.277"></a>
-<span class="sourceLineNo">278</span>    HRegionLocation selectedLoc = 
selectRegionLocation(oldLoc, location,<a name="line.278"></a>
-<span class="sourceLineNo">279</span>      checkForEquals, force);<a 
name="line.279"></a>
-<span class="sourceLineNo">280</span><a name="line.280"></a>
-<span class="sourceLineNo">281</span>    if (selectedLoc == oldLoc) {<a 
name="line.281"></a>
-<span class="sourceLineNo">282</span>      return this;<a name="line.282"></a>
-<span class="sourceLineNo">283</span>    }<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    HRegionLocation[] newLocations = new 
HRegionLocation[Math.max(locations.length, replicaId +1)];<a 
name="line.284"></a>
-<span class="sourceLineNo">285</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    newLocations[replicaId] = location;<a 
name="line.286"></a>
-<span class="sourceLineNo">287</span>    // ensure that all replicas share the 
same start code. Otherwise delete them<a name="line.287"></a>
-<span class="sourceLineNo">288</span>    for (int i=0; i &lt; 
newLocations.length; i++) {<a name="line.288"></a>
-<span class="sourceLineNo">289</span>      if (newLocations[i] != null) {<a 
name="line.289"></a>
-<span class="sourceLineNo">290</span>        if 
(!RegionReplicaUtil.isReplicasForSameRegion(location.getRegionInfo(),<a 
name="line.290"></a>
-<span class="sourceLineNo">291</span>          
newLocations[i].getRegionInfo())) {<a name="line.291"></a>
-<span class="sourceLineNo">292</span>          newLocations[i] = null;<a 
name="line.292"></a>
-<span class="sourceLineNo">293</span>        }<a name="line.293"></a>
-<span class="sourceLineNo">294</span>      }<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    }<a name="line.295"></a>
-<span class="sourceLineNo">296</span>    return new 
RegionLocations(newLocations);<a name="line.296"></a>
-<span class="sourceLineNo">297</span>  }<a name="line.297"></a>
-<span class="sourceLineNo">298</span><a name="line.298"></a>
-<span class="sourceLineNo">299</span>  private boolean isGreaterThan(long a, 
long b, boolean checkForEquals) {<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    return a &gt; b || (checkForEquals 
&amp;&amp; (a == b));<a name="line.300"></a>
-<span class="sourceLineNo">301</span>  }<a name="line.301"></a>
-<span class="sourceLineNo">302</span><a name="line.302"></a>
-<span class="sourceLineNo">303</span>  public HRegionLocation 
getRegionLocation(int replicaId) {<a name="line.303"></a>
-<span class="sourceLineNo">304</span>    if (replicaId &gt;= locations.length) 
{<a name="line.304"></a>
-<span class="sourceLineNo">305</span>      return null;<a name="line.305"></a>
-<span class="sourceLineNo">306</span>    }<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    return locations[replicaId];<a 
name="line.307"></a>
-<span class="sourceLineNo">308</span>  }<a name="line.308"></a>
-<span class="sourceLineNo">309</span><a name="line.309"></a>
-<span class="sourceLineNo">310</span>  /**<a name="line.310"></a>
-<span class="sourceLineNo">311</span>   * Returns the region location from the 
list for matching regionName, which can<a name="line.311"></a>
-<span class="sourceLineNo">312</span>   * be regionName or encodedRegionName<a 
name="line.312"></a>
-<span class="sourceLineNo">313</span>   * @param regionName regionName or 
encodedRegionName<a name="line.313"></a>
-<span class="sourceLineNo">314</span>   * @return HRegionLocation found or 
null<a name="line.314"></a>
-<span class="sourceLineNo">315</span>   */<a name="line.315"></a>
-<span class="sourceLineNo">316</span>  public HRegionLocation 
getRegionLocationByRegionName(byte[] regionName) {<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    for (HRegionLocation loc : locations) 
{<a name="line.317"></a>
-<span class="sourceLineNo">318</span>      if (loc != null) {<a 
name="line.318"></a>
-<span class="sourceLineNo">319</span>        if 
(Bytes.equals(loc.getRegionInfo().getRegionName(), regionName)<a 
name="line.319"></a>
-<span class="sourceLineNo">320</span>            || 
Bytes.equals(loc.getRegionInfo().getEncodedNameAsBytes(), regionName)) {<a 
name="line.320"></a>
-<span class="sourceLineNo">321</span>          return loc;<a 
name="line.321"></a>
-<span class="sourceLineNo">322</span>        }<a name="line.322"></a>
-<span class="sourceLineNo">323</span>      }<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    }<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    return null;<a name="line.325"></a>
-<span class="sourceLineNo">326</span>  }<a name="line.326"></a>
-<span class="sourceLineNo">327</span><a name="line.327"></a>
-<span class="sourceLineNo">328</span>  public HRegionLocation[] 
getRegionLocations() {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>    return locations;<a 
name="line.329"></a>
-<span class="sourceLineNo">330</span>  }<a name="line.330"></a>
-<span class="sourceLineNo">331</span><a name="line.331"></a>
-<span class="sourceLineNo">332</span>  public HRegionLocation 
getDefaultRegionLocation() {<a name="line.332"></a>
-<span class="sourceLineNo">333</span>    return 
locations[HRegionInfo.DEFAULT_REPLICA_ID];<a name="line.333"></a>
-<span class="sourceLineNo">334</span>  }<a name="line.334"></a>
-<span class="sourceLineNo">335</span><a name="line.335"></a>
-<span class="sourceLineNo">336</span>  /**<a name="line.336"></a>
-<span class="sourceLineNo">337</span>   * Returns the first not-null region 
location in the list<a name="line.337"></a>
-<span class="sourceLineNo">338</span>   */<a name="line.338"></a>
-<span class="sourceLineNo">339</span>  public HRegionLocation 
getRegionLocation() {<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    for (HRegionLocation loc : locations) 
{<a name="line.340"></a>
-<span class="sourceLineNo">341</span>      if (loc != null) {<a 
name="line.341"></a>
-<span class="sourceLineNo">342</span>        return loc;<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      }<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    }<a name="line.344"></a>
-<span class="sourceLineNo">345</span>    return null;<a name="line.345"></a>
-<span class="sourceLineNo">346</span>  }<a name="line.346"></a>
-<span class="sourceLineNo">347</span><a name="line.347"></a>
-<span class="sourceLineNo">348</span>  @Override<a name="line.348"></a>
-<span class="sourceLineNo">349</span>  public String toString() {<a 
name="line.349"></a>
-<span class="sourceLineNo">350</span>    StringBuilder builder = new 
StringBuilder("[");<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    for (HRegionLocation loc : locations) 
{<a name="line.351"></a>
-<span class="sourceLineNo">352</span>      if (builder.length() &gt; 1) {<a 
name="line.352"></a>
-<span class="sourceLineNo">353</span>        builder.append(", ");<a 
name="line.353"></a>
-<span class="sourceLineNo">354</span>      }<a name="line.354"></a>
-<span class="sourceLineNo">355</span>      builder.append(loc == null ? "null" 
: loc);<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    }<a name="line.356"></a>
-<span class="sourceLineNo">357</span>    builder.append("]");<a 
name="line.357"></a>
-<span class="sourceLineNo">358</span>    return builder.toString();<a 
name="line.358"></a>
-<span class="sourceLineNo">359</span>  }<a name="line.359"></a>
-<span class="sourceLineNo">360</span><a name="line.360"></a>
-<span class="sourceLineNo">361</span>}<a name="line.361"></a>
+<span class="sourceLineNo">084</span>    this.numNonNullElements = 
numNonNullElements;<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>  public 
RegionLocations(Collection&lt;HRegionLocation&gt; locations) {<a 
name="line.87"></a>
+<span class="sourceLineNo">088</span>    this(locations.toArray(new 
HRegionLocation[locations.size()]));<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>  /**<a name="line.91"></a>
+<span class="sourceLineNo">092</span>   * Returns the size of the list even if 
some of the elements<a name="line.92"></a>
+<span class="sourceLineNo">093</span>   * might be null.<a name="line.93"></a>
+<span class="sourceLineNo">094</span>   * @return the size of the list 
(corresponding to the max replicaId)<a name="line.94"></a>
+<span class="sourceLineNo">095</span>   */<a name="line.95"></a>
+<span class="sourceLineNo">096</span>  public int size() {<a 
name="line.96"></a>
+<span class="sourceLineNo">097</span>    return locations.length;<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>  /**<a name="line.100"></a>
+<span class="sourceLineNo">101</span>   * Returns the size of not-null 
locations<a name="line.101"></a>
+<span class="sourceLineNo">102</span>   * @return the size of not-null 
locations<a name="line.102"></a>
+<span class="sourceLineNo">103</span>   */<a name="line.103"></a>
+<span class="sourceLineNo">104</span>  public int numNonNullElements() {<a 
name="line.104"></a>
+<span class="sourceLineNo">105</span>    return numNonNullElements;<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>  /**<a name="line.108"></a>
+<span class="sourceLineNo">109</span>   * Returns whether there are non-null 
elements in the list<a name="line.109"></a>
+<span class="sourceLineNo">110</span>   * @return whether there are non-null 
elements in the list<a name="line.110"></a>
+<span class="sourceLineNo">111</span>   */<a name="line.111"></a>
+<span class="sourceLineNo">112</span>  public boolean isEmpty() {<a 
name="line.112"></a>
+<span class="sourceLineNo">113</span>    return numNonNullElements == 0;<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>   * Returns a new RegionLocations with 
the locations removed (set to null)<a name="line.117"></a>
+<span class="sourceLineNo">118</span>   * which have the destination server as 
given.<a name="line.118"></a>
+<span class="sourceLineNo">119</span>   * @param serverName the serverName to 
remove locations of<a name="line.119"></a>
+<span class="sourceLineNo">120</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.120"></a>
+<span class="sourceLineNo">121</span>   * if nothing is removed<a 
name="line.121"></a>
+<span class="sourceLineNo">122</span>   */<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  public RegionLocations 
removeByServer(ServerName serverName) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    HRegionLocation[] newLocations = 
null;<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    for (int i = 0; i &lt; 
locations.length; i++) {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      // check whether something to 
remove<a name="line.126"></a>
+<span class="sourceLineNo">127</span>      if (locations[i] != null &amp;&amp; 
serverName.equals(locations[i].getServerName())) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        if (newLocations == null) { 
//first time<a name="line.128"></a>
+<span class="sourceLineNo">129</span>          newLocations = new 
HRegionLocation[locations.length];<a name="line.129"></a>
+<span class="sourceLineNo">130</span>          System.arraycopy(locations, 0, 
newLocations, 0, i);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>        }<a name="line.131"></a>
+<span class="sourceLineNo">132</span>        newLocations[i] = null;<a 
name="line.132"></a>
+<span class="sourceLineNo">133</span>      } else if (newLocations != null) 
{<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        newLocations[i] = locations[i];<a 
name="line.134"></a>
+<span class="sourceLineNo">135</span>      }<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    return newLocations == null ? this : 
new RegionLocations(newLocations);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  /**<a name="line.140"></a>
+<span class="sourceLineNo">141</span>   * Removes the given location from the 
list<a name="line.141"></a>
+<span class="sourceLineNo">142</span>   * @param location the location to 
remove<a name="line.142"></a>
+<span class="sourceLineNo">143</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.143"></a>
+<span class="sourceLineNo">144</span>   * if nothing is removed<a 
name="line.144"></a>
+<span class="sourceLineNo">145</span>   */<a name="line.145"></a>
+<span class="sourceLineNo">146</span>  public RegionLocations 
remove(HRegionLocation location) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    if (location == null) return this;<a 
name="line.147"></a>
+<span class="sourceLineNo">148</span>    if (location.getRegion() == null) 
return this;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    int replicaId = 
location.getRegionInfo().getReplicaId();<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    if (replicaId &gt;= locations.length) 
return this;<a name="line.150"></a>
+<span class="sourceLineNo">151</span><a name="line.151"></a>
+<span class="sourceLineNo">152</span>    // check whether something to remove. 
HRL.compareTo() compares ONLY the<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    // serverName. We want to compare the 
HRI's as well.<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    if (locations[replicaId] == null<a 
name="line.154"></a>
+<span class="sourceLineNo">155</span>        || 
RegionInfo.COMPARATOR.compare(location.getRegion(), 
locations[replicaId].getRegion()) != 0<a name="line.155"></a>
+<span class="sourceLineNo">156</span>        || 
!location.equals(locations[replicaId])) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      return this;<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>    HRegionLocation[] newLocations = new 
HRegionLocation[locations.length];<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    newLocations[replicaId] = null;<a 
name="line.162"></a>
+<span class="sourceLineNo">163</span><a name="line.163"></a>
+<span class="sourceLineNo">164</span>    return new 
RegionLocations(newLocations);<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>  /**<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   * Removes location of the given 
replicaId from the list<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * @param replicaId the replicaId of 
the location to remove<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   * @return an RegionLocations object 
with removed locations or the same object<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * if nothing is removed<a 
name="line.171"></a>
+<span class="sourceLineNo">172</span>   */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public RegionLocations remove(int 
replicaId) {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    if (getRegionLocation(replicaId) == 
null) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      return this;<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    }<a name="line.176"></a>
+<span class="sourceLineNo">177</span><a name="line.177"></a>
+<span class="sourceLineNo">178</span>    HRegionLocation[] newLocations = new 
HRegionLocation[locations.length];<a name="line.178"></a>
+<span class="sourceLineNo">179</span><a name="line.179"></a>
+<span class="sourceLineNo">180</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    if (replicaId &lt; 
newLocations.length) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      newLocations[replicaId] = null;<a 
name="line.182"></a>
+<span class="sourceLineNo">183</span>    }<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>    return new 
RegionLocations(newLocations);<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>  /**<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * Merges this RegionLocations list 
with the given list assuming<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * same range, and keeping the most up 
to date version of the<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * HRegionLocation entries from either 
list according to seqNum. If seqNums<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * are equal, the location from the 
argument (other) is taken.<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   * @param other the locations to merge 
with<a name="line.193"></a>
+<span class="sourceLineNo">194</span>   * @return an RegionLocations object 
with merged locations or the same object<a name="line.194"></a>
+<span class="sourceLineNo">195</span>   * if nothing is merged<a 
name="line.195"></a>
+<span class="sourceLineNo">196</span>   */<a name="line.196"></a>
+<span class="sourceLineNo">197</span>  public RegionLocations 
mergeLocations(RegionLocations other) {<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    assert other != null;<a 
name="line.198"></a>
+<span class="sourceLineNo">199</span><a name="line.199"></a>
+<span class="sourceLineNo">200</span>    HRegionLocation[] newLocations = 
null;<a name="line.200"></a>
+<span class="sourceLineNo">201</span><a name="line.201"></a>
+<span class="sourceLineNo">202</span>    // Use the length from other, since 
it is coming from meta. Otherwise,<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    // in case of region replication 
going down, we might have a leak here.<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    int max = other.locations.length;<a 
name="line.204"></a>
+<span class="sourceLineNo">205</span><a name="line.205"></a>
+<span class="sourceLineNo">206</span>    HRegionInfo regionInfo = null;<a 
name="line.206"></a>
+<span class="sourceLineNo">207</span>    for (int i = 0; i &lt; max; i++) {<a 
name="line.207"></a>
+<span class="sourceLineNo">208</span>      HRegionLocation thisLoc = 
this.getRegionLocation(i);<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      HRegionLocation otherLoc = 
other.getRegionLocation(i);<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      if (regionInfo == null &amp;&amp; 
otherLoc != null &amp;&amp; otherLoc.getRegionInfo() != null) {<a 
name="line.210"></a>
+<span class="sourceLineNo">211</span>        // regionInfo is the first 
non-null HRI from other RegionLocations. We use it to ensure that<a 
name="line.211"></a>
+<span class="sourceLineNo">212</span>        // all replica region infos 
belong to the same region with same region id.<a name="line.212"></a>
+<span class="sourceLineNo">213</span>        regionInfo = 
otherLoc.getRegionInfo();<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>      HRegionLocation selectedLoc = 
selectRegionLocation(thisLoc,<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        otherLoc, true, false);<a 
name="line.217"></a>
+<span class="sourceLineNo">218</span><a name="line.218"></a>
+<span class="sourceLineNo">219</span>      if (selectedLoc != thisLoc) {<a 
name="line.219"></a>
+<span class="sourceLineNo">220</span>        if (newLocations == null) {<a 
name="line.220"></a>
+<span class="sourceLineNo">221</span>          newLocations = new 
HRegionLocation[max];<a name="line.221"></a>
+<span class="sourceLineNo">222</span>          System.arraycopy(locations, 0, 
newLocations, 0, i);<a name="line.222"></a>
+<span class="sourceLineNo">223</span>        }<a name="line.223"></a>
+<span class="sourceLineNo">224</span>      }<a name="line.224"></a>
+<span class="sourceLineNo">225</span>      if (newLocations != null) {<a 
name="line.225"></a>
+<span class="sourceLineNo">226</span>        newLocations[i] = selectedLoc;<a 
name="line.226"></a>
+<span class="sourceLineNo">227</span>      }<a name="line.227"></a>
+<span class="sourceLineNo">228</span>    }<a name="line.228"></a>
+<span class="sourceLineNo">229</span><a name="line.229"></a>
+<span class="sourceLineNo">230</span>    // ensure that all replicas share the 
same start code. Otherwise delete them<a name="line.230"></a>
+<span class="sourceLineNo">231</span>    if (newLocations != null &amp;&amp; 
regionInfo != null) {<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      for (int i=0; i &lt; 
newLocations.length; i++) {<a name="line.232"></a>
+<span class="sourceLineNo">233</span>        if (newLocations[i] != null) {<a 
name="line.233"></a>
+<span class="sourceLineNo">234</span>          if 
(!RegionReplicaUtil.isReplicasForSameRegion(regionInfo,<a name="line.234"></a>
+<span class="sourceLineNo">235</span>            
newLocations[i].getRegionInfo())) {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>            newLocations[i] = null;<a 
name="line.236"></a>
+<span class="sourceLineNo">237</span>          }<a name="line.237"></a>
+<span class="sourceLineNo">238</span>        }<a name="line.238"></a>
+<span class="sourceLineNo">239</span>      }<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>    return newLocations == null ? this : 
new RegionLocations(newLocations);<a name="line.242"></a>
+<span class="sourceLineNo">243</span>  }<a name="line.243"></a>
+<span class="sourceLineNo">244</span><a name="line.244"></a>
+<span class="sourceLineNo">245</span>  private HRegionLocation 
selectRegionLocation(HRegionLocation oldLocation,<a name="line.245"></a>
+<span class="sourceLineNo">246</span>      HRegionLocation location, boolean 
checkForEquals, boolean force) {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>    if (location == null) {<a 
name="line.247"></a>
+<span class="sourceLineNo">248</span>      return oldLocation == null ? null : 
oldLocation;<a name="line.248"></a>
+<span class="sourceLineNo">249</span>    }<a name="line.249"></a>
+<span class="sourceLineNo">250</span><a name="line.250"></a>
+<span class="sourceLineNo">251</span>    if (oldLocation == null) {<a 
name="line.251"></a>
+<span class="sourceLineNo">252</span>      return location;<a 
name="line.252"></a>
+<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
+<span class="sourceLineNo">254</span><a name="line.254"></a>
+<span class="sourceLineNo">255</span>    if (force<a name="line.255"></a>
+<span class="sourceLineNo">256</span>        || 
isGreaterThan(location.getSeqNum(), oldLocation.getSeqNum(), checkForEquals)) 
{<a name="line.256"></a>
+<span class="sourceLineNo">257</span>      return location;<a 
name="line.257"></a>
+<span class="sourceLineNo">258</span>    }<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    return oldLocation;<a 
name="line.259"></a>
+<span class="sourceLineNo">260</span>  }<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>  /**<a name="line.262"></a>
+<span class="sourceLineNo">263</span>   * Updates the location with new only 
if the new location has a higher<a name="line.263"></a>
+<span class="sourceLineNo">264</span>   * seqNum than the old one or force is 
true.<a name="line.264"></a>
+<span class="sourceLineNo">265</span>   * @param location the location to add 
or update<a name="line.265"></a>
+<span class="sourceLineNo">266</span>   * @param checkForEquals whether to 
update the location if seqNums for the<a name="line.266"></a>
+<span class="sourceLineNo">267</span>   * HRegionLocations for the old and new 
location are the same<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   * @param force whether to force 
update<a name="line.268"></a>
+<span class="sourceLineNo">269</span>   * @return an RegionLocations object 
with updated locations or the same object<a name="line.269"></a>
+<span class="sourceLineNo">270</span>   * if nothing is updated<a 
name="line.270"></a>
+<span class="sourceLineNo">271</span>   */<a name="line.271"></a>
+<span class="sourceLineNo">272</span>  public RegionLocations 
updateLocation(HRegionLocation location,<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      boolean checkForEquals, boolean 
force) {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    assert location != null;<a 
name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>    int replicaId = 
location.getRegionInfo().getReplicaId();<a name="line.276"></a>
+<span class="sourceLineNo">277</span><a name="line.277"></a>
+<span class="sourceLineNo">278</span>    HRegionLocation oldLoc = 
getRegionLocation(location.getRegionInfo().getReplicaId());<a 
name="line.278"></a>
+<span class="sourceLineNo">279</span>    HRegionLocation selectedLoc = 
selectRegionLocation(oldLoc, location,<a name="line.279"></a>
+<span class="sourceLineNo">280</span>      checkForEquals, force);<a 
name="line.280"></a>
+<span class="sourceLineNo">281</span><a name="line.281"></a>
+<span class="sourceLineNo">282</span>    if (selectedLoc == oldLoc) {<a 
name="line.282"></a>
+<span class="sourceLineNo">283</span>      return this;<a name="line.283"></a>
+<span class="sourceLineNo">284</span>    }<a name="line.284"></a>
+<span class="sourceLineNo">285</span>    HRegionLocation[] newLocations = new 
HRegionLocation[Math.max(locations.length, replicaId +1)];<a 
name="line.285"></a>
+<span class="sourceLineNo">286</span>    System.arraycopy(locations, 0, 
newLocations, 0, locations.length);<a name="line.286"></a>
+<span class="sourceLineNo">287</span>    newLocations[replicaId] = location;<a 
name="line.287"></a>
+<span class="sourceLineNo">288</span>    // ensure that all replicas share the 
same start code. Otherwise delete them<a name="line.288"></a>
+<span class="sourceLineNo">289</span>    for (int i=0; i &lt; 
newLocations.length; i++) {<a name="line.289"></a>
+<span class="sourceLineNo">290</span>      if (newLocations[i] != null) {<a 
name="line.290"></a>
+<span class="sourceLineNo">291</span>        if 
(!RegionReplicaUtil.isReplicasForSameRegion(location.getRegionInfo(),<a 
name="line.291"></a>
+<span class="sourceLineNo">292</span>          
newLocations[i].getRegionInfo())) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>          newLocations[i] = null;<a 
name="line.293"></a>
+<span class="sourceLineNo">294</span>        }<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      }<a name="line.295"></a>
+<span class="sourceLineNo">296</span>    }<a name="line.296"></a>
+<span class="sourceLineNo">297</span>    return new 
RegionLocations(newLocations);<a name="line.297"></a>
+<span class="sourceLineNo">298</span>  }<a name="line.298"></a>
+<span class="sourceLineNo">299</span><a name="line.299"></a>
+<span class="sourceLineNo">300</span>  private boolean isGreaterThan(long a, 
long b, boolean checkForEquals) {<a name="line.300"></a>
+<span class="sourceLineNo">301</span>    return a &gt; b || (checkForEquals 
&amp;&amp; (a == b));<a name="line.301"></a>
+<span class="sourceLineNo">302</span>  }<a name="line.302"></a>
+<span class="sourceLineNo">303</span><a name="line.303"></a>
+<span class="sourceLineNo">304</span>  public HRegionLocation 
getRegionLocation(int replicaId) {<a name="line.304"></a>
+<span class="sourceLineNo">305</span>    if (replicaId &gt;= locations.length) 
{<a name="line.305"></a>
+<span class="sourceLineNo">306</span>      return null;<a name="line.306"></a>
+<span class="sourceLineNo">307</span>    }<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    return locations[replicaId];<a 
name="line.308"></a>
+<span class="sourceLineNo">309</span>  }<a name="line.309"></a>
+<span class="sourceLineNo">310</span><a name="line.310"></a>
+<span class="sourceLineNo">311</span>  /**<a name="line.311"></a>
+<span class="sourceLineNo">312</span>   * Returns the region location from the 
list for matching regionName, which can<a name="line.312"></a>
+<span class="sourceLineNo">313</span>   * be regionName or encodedRegionName<a 
name="line.313"></a>
+<span class="sourceLineNo">314</span>   * @param regionName regionName or 
encodedRegionName<a name="line.314"></a>
+<span class="sourceLineNo">315</span>   * @return HRegionLocation found or 
null<a name="line.315"></a>
+<span class="sourceLineNo">316</span>   */<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  public HRegionLocation 
getRegionLocationByRegionName(byte[] regionName) {<a name="line.317"></a>
+<span class="sourceLineNo">318</span>    for (HRegionLocation loc : locations) 
{<a name="line.318"></a>
+<span class="sourceLineNo">319</span>      if (loc != null) {<a 
name="line.319"></a>
+<span class="sourceLineNo">320</span>        if 
(Bytes.equals(loc.getRegionInfo().getRegionName(), regionName)<a 
name="line.320"></a>
+<span class="sourceLineNo">321</span>            || 
Bytes.equals(loc.getRegionInfo().getEncodedNameAsBytes(), regionName)) {<a 
name="line.321"></a>
+<span class="sourceLineNo">322</span>          return loc;<a 
name="line.322"></a>
+<span class="sourceLineNo">323</span>        }<a name="line.323"></a>
+<span class="sourceLineNo">324</span>      }<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    }<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    return null;<a name="line.326"></a>
+<span class="sourceLineNo">327</span>  }<a name="line.327"></a>
+<span class="sourceLineNo">328</span><a name="line.328"></a>
+<span class="sourceLineNo">329</span>  public HRegionLocation[] 
getRegionLocations() {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    return locations;<a 
name="line.330"></a>
+<span class="sourceLineNo">331</span>  }<a name="line.331"></a>
+<span class="sourceLineNo">332</span><a name="line.332"></a>
+<span class="sourceLineNo">333</span>  public HRegionLocation 
getDefaultRegionLocation() {<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    return 
locations[HRegionInfo.DEFAULT_REPLICA_ID];<a name="line.334"></a>
+<span class="sourceLineNo">335</span>  }<a name="line.335"></a>
+<span class="sourceLineNo">336</span><a name="line.336"></a>
+<span class="sourceLineNo">337</span>  /**<a name="line.337"></a>
+<span class="sourceLineNo">338</span>   * Returns the first not-null region 
location in the list<a name="line.338"></a>
+<span class="sourceLineNo">339</span>   */<a name="line.339"></a>
+<span class="sourceLineNo">340</span>  public HRegionLocation 
getRegionLocation() {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>    for (HRegionLocation loc : locations) 
{<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      if (loc != null) {<a 
name="line.342"></a>
+<span class="sourceLineNo">343</span>        return loc;<a name="line.343"></a>
+<span class="sourceLineNo">344</span>      }<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    }<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    return null;<a name="line.346"></a>
+<span class="sourceLineNo">347</span>  }<a name="line.347"></a>
+<span class="sourceLineNo">348</span><a name="line.348"></a>
+<span class="sourceLineNo">349</span>  @Override<a name="line.349"></a>
+<span class="sourceLineNo">350</span>  public String toString() {<a 
name="line.350"></a>
+<span class="sourceLineNo">351</span>    StringBuilder builder = new 
StringBuilder("[");<a name="line.351"></a>
+<span class="sourceLineNo">352</span>    for (HRegionLocation loc : locations) 
{<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      if (builder.length() &gt; 1) {<a 
name="line.353"></a>
+<span class="sourceLineNo">354</span>        builder.append(", ");<a 
name="line.354"></a>
+<span class="sourceLineNo">355</span>      }<a name="line.355"></a>
+<span class="sourceLineNo">356</span>      builder.append(loc == null ? "null" 
: loc);<a name="line.356"></a>
+<span class="sourceLineNo">357</span>    }<a name="line.357"></a>
+<span class="sourceLineNo">358</span>    builder.append("]");<a 
name="line.358"></a>
+<span class="sourceLineNo">359</span>    return builder.toString();<a 
name="line.359"></a>
+<span class="sourceLineNo">360</span>  }<a name="line.360"></a>
+<span class="sourceLineNo">361</span><a name="line.361"></a>
+<span class="sourceLineNo">362</span>}<a name="line.362"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c91fafb4/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html 
b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
index 6a23f31..3b27fcb 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
@@ -16,11 +16,11 @@
 <span class="sourceLineNo">008</span>@InterfaceAudience.Private<a 
name="line.8"></a>
 <span class="sourceLineNo">009</span>public class Version {<a 
name="line.9"></a>
 <span class="sourceLineNo">010</span>  public static final String version = 
"3.0.0-SNAPSHOT";<a name="line.10"></a>
-<span class="sourceLineNo">011</span>  public static final String revision = 
"d7561cee50acf2e3a52b8a38c71259d60b653ed3";<a name="line.11"></a>
+<span class="sourceLineNo">011</span>  public static final String revision = 
"a838f7631f60d5c12736e8dae2856e1cc5a3bd99";<a name="line.11"></a>
 <span class="sourceLineNo">012</span>  public static final String user = 
"jenkins";<a name="line.12"></a>
-<span class="sourceLineNo">013</span>  public static final String date = "Tue 
Jul 10 17:15:36 UTC 2018";<a name="line.13"></a>
+<span class="sourceLineNo">013</span>  public static final String date = "Wed 
Jul 11 16:12:22 UTC 2018";<a name="line.13"></a>
 <span class="sourceLineNo">014</span>  public static final String url = 
"git://jenkins-websites1.apache.org/home/jenkins/jenkins-slave/workspace/hbase_generate_website/hbase";<a
 name="line.14"></a>
-<span class="sourceLineNo">015</span>  public static final String srcChecksum 
= "e26484db2adaa453ac5ea2d97df0d969";<a name="line.15"></a>
+<span class="sourceLineNo">015</span>  public static final String srcChecksum 
= "c41451c8da902fa182f14f3bd9a512f5";<a name="line.15"></a>
 <span class="sourceLineNo">016</span>}<a name="line.16"></a>
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c91fafb4/devapidocs/src-html/org/apache/hadoop/hbase/client/HRegionLocator.html
----------------------------------------------------------------------
diff --git 
a/devapidocs/src-html/org/apache/hadoop/hbase/client/HRegionLocator.html 
b/devapidocs/src-html/org/apache/hadoop/hbase/client/HRegionLocator.html
index 61b73ad..440106e 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/HRegionLocator.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/HRegionLocator.html
@@ -35,140 +35,136 @@
 <span class="sourceLineNo">027</span>import 
org.apache.hadoop.hbase.HRegionLocation;<a name="line.27"></a>
 <span class="sourceLineNo">028</span>import 
org.apache.hadoop.hbase.MetaTableAccessor;<a name="line.28"></a>
 <span class="sourceLineNo">029</span>import 
org.apache.hadoop.hbase.RegionLocations;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import 
org.apache.hadoop.hbase.ServerName;<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.util.Pair;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import 
org.apache.yetus.audience.InterfaceAudience;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import 
org.apache.yetus.audience.InterfaceStability;<a name="line.34"></a>
-<span class="sourceLineNo">035</span><a name="line.35"></a>
-<span class="sourceLineNo">036</span>import 
org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a 
name="line.36"></a>
-<span class="sourceLineNo">037</span><a name="line.37"></a>
-<span class="sourceLineNo">038</span>/**<a name="line.38"></a>
-<span class="sourceLineNo">039</span> * An implementation of {@link 
RegionLocator}. Used to view region location information for a single<a 
name="line.39"></a>
-<span class="sourceLineNo">040</span> * HBase table. Lightweight. Get as 
needed and just close when done. Instances of this class SHOULD<a 
name="line.40"></a>
-<span class="sourceLineNo">041</span> * NOT be constructed directly. Obtain an 
instance via {@link Connection}. See<a name="line.41"></a>
-<span class="sourceLineNo">042</span> * {@link ConnectionFactory} class 
comment for an example of how.<a name="line.42"></a>
-<span class="sourceLineNo">043</span> *<a name="line.43"></a>
-<span class="sourceLineNo">044</span> * &lt;p&gt; This class is thread safe<a 
name="line.44"></a>
-<span class="sourceLineNo">045</span> */<a name="line.45"></a>
-<span class="sourceLineNo">046</span>@InterfaceAudience.Private<a 
name="line.46"></a>
-<span class="sourceLineNo">047</span>@InterfaceStability.Stable<a 
name="line.47"></a>
-<span class="sourceLineNo">048</span>public class HRegionLocator implements 
RegionLocator {<a name="line.48"></a>
-<span class="sourceLineNo">049</span><a name="line.49"></a>
-<span class="sourceLineNo">050</span>  private final TableName tableName;<a 
name="line.50"></a>
-<span class="sourceLineNo">051</span>  private final ClusterConnection 
connection;<a name="line.51"></a>
-<span class="sourceLineNo">052</span><a name="line.52"></a>
-<span class="sourceLineNo">053</span>  public HRegionLocator(TableName 
tableName, ClusterConnection connection) {<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    this.connection = connection;<a 
name="line.54"></a>
-<span class="sourceLineNo">055</span>    this.tableName = tableName;<a 
name="line.55"></a>
-<span class="sourceLineNo">056</span>  }<a name="line.56"></a>
-<span class="sourceLineNo">057</span><a name="line.57"></a>
-<span class="sourceLineNo">058</span>  /**<a name="line.58"></a>
-<span class="sourceLineNo">059</span>   * {@inheritDoc}<a name="line.59"></a>
-<span class="sourceLineNo">060</span>   */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  @Override<a name="line.61"></a>
-<span class="sourceLineNo">062</span>  public void close() throws IOException 
{<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    // This method is required by the 
RegionLocator interface. This implementation does not have any<a 
name="line.63"></a>
-<span class="sourceLineNo">064</span>    // persistent state, so there is no 
need to do anything here.<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  }<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>   * {@inheritDoc}<a name="line.68"></a>
-<span class="sourceLineNo">069</span>   */<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  @Override<a name="line.70"></a>
-<span class="sourceLineNo">071</span>  public HRegionLocation 
getRegionLocation(final byte [] row)<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  throws IOException {<a 
name="line.72"></a>
-<span class="sourceLineNo">073</span>    return 
connection.getRegionLocation(tableName, row, false);<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>  /**<a name="line.76"></a>
-<span class="sourceLineNo">077</span>   * {@inheritDoc}<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 HRegionLocation 
getRegionLocation(final byte [] row, boolean reload)<a name="line.80"></a>
-<span class="sourceLineNo">081</span>  throws IOException {<a 
name="line.81"></a>
-<span class="sourceLineNo">082</span>    return 
connection.getRegionLocation(tableName, row, reload);<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>  @Override<a name="line.85"></a>
-<span class="sourceLineNo">086</span>  public List&lt;HRegionLocation&gt; 
getAllRegionLocations() throws IOException {<a name="line.86"></a>
-<span class="sourceLineNo">087</span>    TableName tableName = getName();<a 
name="line.87"></a>
-<span class="sourceLineNo">088</span>    List&lt;Pair&lt;RegionInfo, 
ServerName&gt;&gt; locations =<a name="line.88"></a>
-<span class="sourceLineNo">089</span>        
MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName);<a 
name="line.89"></a>
-<span class="sourceLineNo">090</span>    ArrayList&lt;HRegionLocation&gt; 
regions = new ArrayList&lt;&gt;(locations.size());<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    for (Pair&lt;RegionInfo, 
ServerName&gt; entry : locations) {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      regions.add(new 
HRegionLocation(entry.getFirst(), entry.getSecond()));<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>    if (regions.size() &gt; 0) {<a 
name="line.95"></a>
-<span class="sourceLineNo">096</span>      connection.cacheLocation(tableName, 
new RegionLocations(regions));<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    }<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    return regions;<a name="line.98"></a>
-<span class="sourceLineNo">099</span>  }<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>   * {@inheritDoc}<a name="line.102"></a>
-<span class="sourceLineNo">103</span>   */<a name="line.103"></a>
-<span class="sourceLineNo">104</span>  @Override<a name="line.104"></a>
-<span class="sourceLineNo">105</span>  public byte[][] getStartKeys() throws 
IOException {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    return 
getStartEndKeys().getFirst();<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  }<a name="line.107"></a>
-<span class="sourceLineNo">108</span><a name="line.108"></a>
-<span class="sourceLineNo">109</span>  /**<a name="line.109"></a>
-<span class="sourceLineNo">110</span>   * {@inheritDoc}<a name="line.110"></a>
-<span class="sourceLineNo">111</span>   */<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  @Override<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  public byte[][] getEndKeys() throws 
IOException {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    return 
getStartEndKeys().getSecond();<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>   * {@inheritDoc}<a name="line.118"></a>
-<span class="sourceLineNo">119</span>   */<a name="line.119"></a>
-<span class="sourceLineNo">120</span>  @Override<a name="line.120"></a>
-<span class="sourceLineNo">121</span>  public Pair&lt;byte[][], byte[][]&gt; 
getStartEndKeys() throws IOException {<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    return 
getStartEndKeys(listRegionLocations());<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>  @VisibleForTesting<a 
name="line.125"></a>
-<span class="sourceLineNo">126</span>  Pair&lt;byte[][], byte[][]&gt; 
getStartEndKeys(List&lt;RegionLocations&gt; regions) {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    final byte[][] startKeyList = new 
byte[regions.size()][];<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    final byte[][] endKeyList = new 
byte[regions.size()][];<a name="line.128"></a>
-<span class="sourceLineNo">129</span><a name="line.129"></a>
-<span class="sourceLineNo">130</span>    for (int i = 0; i &lt; 
regions.size(); i++) {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      HRegionInfo region = 
regions.get(i).getRegionLocation().getRegionInfo();<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      startKeyList[i] = 
region.getStartKey();<a name="line.132"></a>
-<span class="sourceLineNo">133</span>      endKeyList[i] = 
region.getEndKey();<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>    return new Pair&lt;&gt;(startKeyList, 
endKeyList);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>  }<a name="line.137"></a>
-<span class="sourceLineNo">138</span><a name="line.138"></a>
-<span class="sourceLineNo">139</span>  @Override<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  public TableName getName() {<a 
name="line.140"></a>
-<span class="sourceLineNo">141</span>    return this.tableName;<a 
name="line.141"></a>
-<span class="sourceLineNo">142</span>  }<a name="line.142"></a>
-<span class="sourceLineNo">143</span><a name="line.143"></a>
-<span class="sourceLineNo">144</span>  @VisibleForTesting<a 
name="line.144"></a>
-<span class="sourceLineNo">145</span>  List&lt;RegionLocations&gt; 
listRegionLocations() throws IOException {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    final List&lt;RegionLocations&gt; 
regions = new ArrayList&lt;&gt;();<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    MetaTableAccessor.Visitor visitor = 
new MetaTableAccessor.TableVisitorBase(tableName) {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      @Override<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      public boolean visitInternal(Result 
result) throws IOException {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>        RegionLocations locations = 
MetaTableAccessor.getRegionLocations(result);<a name="line.150"></a>
-<span class="sourceLineNo">151</span>        if (locations == null) return 
true;<a name="line.151"></a>
-<span class="sourceLineNo">152</span>        regions.add(locations);<a 
name="line.152"></a>
-<span class="sourceLineNo">153</span>        return true;<a 
name="line.153"></a>
-<span class="sourceLineNo">154</span>      }<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    };<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    
MetaTableAccessor.scanMetaForTableRegions(connection, visitor, tableName);<a 
name="line.156"></a>
-<span class="sourceLineNo">157</span>    return regions;<a name="line.157"></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.util.Pair;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import 
org.apache.yetus.audience.InterfaceAudience;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import 
org.apache.yetus.audience.InterfaceStability;<a name="line.33"></a>
+<span class="sourceLineNo">034</span><a name="line.34"></a>
+<span class="sourceLineNo">035</span>import 
org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a 
name="line.35"></a>
+<span class="sourceLineNo">036</span><a name="line.36"></a>
+<span class="sourceLineNo">037</span>/**<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * An implementation of {@link 
RegionLocator}. Used to view region location information for a single<a 
name="line.38"></a>
+<span class="sourceLineNo">039</span> * HBase table. Lightweight. Get as 
needed and just close when done. Instances of this class SHOULD<a 
name="line.39"></a>
+<span class="sourceLineNo">040</span> * NOT be constructed directly. Obtain an 
instance via {@link Connection}. See<a name="line.40"></a>
+<span class="sourceLineNo">041</span> * {@link ConnectionFactory} class 
comment for an example of how.<a name="line.41"></a>
+<span class="sourceLineNo">042</span> *<a name="line.42"></a>
+<span class="sourceLineNo">043</span> * &lt;p&gt; This class is thread safe<a 
name="line.43"></a>
+<span class="sourceLineNo">044</span> */<a name="line.44"></a>
+<span class="sourceLineNo">045</span>@InterfaceAudience.Private<a 
name="line.45"></a>
+<span class="sourceLineNo">046</span>@InterfaceStability.Stable<a 
name="line.46"></a>
+<span class="sourceLineNo">047</span>public class HRegionLocator implements 
RegionLocator {<a name="line.47"></a>
+<span class="sourceLineNo">048</span><a name="line.48"></a>
+<span class="sourceLineNo">049</span>  private final TableName tableName;<a 
name="line.49"></a>
+<span class="sourceLineNo">050</span>  private final ClusterConnection 
connection;<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>  public HRegionLocator(TableName 
tableName, ClusterConnection connection) {<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    this.connection = connection;<a 
name="line.53"></a>
+<span class="sourceLineNo">054</span>    this.tableName = tableName;<a 
name="line.54"></a>
+<span class="sourceLineNo">055</span>  }<a name="line.55"></a>
+<span class="sourceLineNo">056</span><a name="line.56"></a>
+<span class="sourceLineNo">057</span>  /**<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   * {@inheritDoc}<a name="line.58"></a>
+<span class="sourceLineNo">059</span>   */<a name="line.59"></a>
+<span class="sourceLineNo">060</span>  @Override<a name="line.60"></a>
+<span class="sourceLineNo">061</span>  public void close() throws IOException 
{<a name="line.61"></a>
+<span class="sourceLineNo">062</span>    // This method is required by the 
RegionLocator interface. This implementation does not have any<a 
name="line.62"></a>
+<span class="sourceLineNo">063</span>    // persistent state, so there is no 
need to do anything here.<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>  /**<a name="line.66"></a>
+<span class="sourceLineNo">067</span>   * {@inheritDoc}<a name="line.67"></a>
+<span class="sourceLineNo">068</span>   */<a name="line.68"></a>
+<span class="sourceLineNo">069</span>  @Override<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  public HRegionLocation 
getRegionLocation(final byte [] row)<a name="line.70"></a>
+<span class="sourceLineNo">071</span>  throws IOException {<a 
name="line.71"></a>
+<span class="sourceLineNo">072</span>    return 
connection.getRegionLocation(tableName, row, false);<a name="line.72"></a>
+<span class="sourceLineNo">073</span>  }<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>   * {@inheritDoc}<a name="line.76"></a>
+<span class="sourceLineNo">077</span>   */<a name="line.77"></a>
+<span class="sourceLineNo">078</span>  @Override<a name="line.78"></a>
+<span class="sourceLineNo">079</span>  public HRegionLocation 
getRegionLocation(final byte [] row, boolean reload)<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  throws IOException {<a 
name="line.80"></a>
+<span class="sourceLineNo">081</span>    return 
connection.getRegionLocation(tableName, row, reload);<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 List&lt;HRegionLocation&gt; 
getAllRegionLocations() throws IOException {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    TableName tableName = getName();<a 
name="line.86"></a>
+<span class="sourceLineNo">087</span>    ArrayList&lt;HRegionLocation&gt; 
regions = new ArrayList&lt;&gt;();<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    for (RegionLocations locations : 
listRegionLocations()) {<a name="line.88"></a>
+<span class="sourceLineNo">089</span>      for (HRegionLocation location : 
locations.getRegionLocations()) {<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        regions.add(location);<a 
name="line.90"></a>
+<span class="sourceLineNo">091</span>      }<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      connection.cacheLocation(tableName, 
locations);<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    }<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    return regions;<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>   * {@inheritDoc}<a name="line.98"></a>
+<span class="sourceLineNo">099</span>   */<a name="line.99"></a>
+<span class="sourceLineNo">100</span>  @Override<a name="line.100"></a>
+<span class="sourceLineNo">101</span>  public byte[][] getStartKeys() throws 
IOException {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    return 
getStartEndKeys().getFirst();<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>   * {@inheritDoc}<a name="line.106"></a>
+<span class="sourceLineNo">107</span>   */<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  @Override<a name="line.108"></a>
+<span class="sourceLineNo">109</span>  public byte[][] getEndKeys() throws 
IOException {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    return 
getStartEndKeys().getSecond();<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>   * {@inheritDoc}<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 Pair&lt;byte[][], byte[][]&gt; 
getStartEndKeys() throws IOException {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    return 
getStartEndKeys(listRegionLocations());<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>  @VisibleForTesting<a 
name="line.121"></a>
+<span class="sourceLineNo">122</span>  Pair&lt;byte[][], byte[][]&gt; 
getStartEndKeys(List&lt;RegionLocations&gt; regions) {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    final byte[][] startKeyList = new 
byte[regions.size()][];<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    final byte[][] endKeyList = new 
byte[regions.size()][];<a name="line.124"></a>
+<span class="sourceLineNo">125</span><a name="line.125"></a>
+<span class="sourceLineNo">126</span>    for (int i = 0; i &lt; 
regions.size(); i++) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>      HRegionInfo region = 
regions.get(i).getRegionLocation().getRegionInfo();<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      startKeyList[i] = 
region.getStartKey();<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      endKeyList[i] = 
region.getEndKey();<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>    return new Pair&lt;&gt;(startKeyList, 
endKeyList);<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>  @Override<a name="line.135"></a>
+<span class="sourceLineNo">136</span>  public TableName getName() {<a 
name="line.136"></a>
+<span class="sourceLineNo">137</span>    return this.tableName;<a 
name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  @VisibleForTesting<a 
name="line.140"></a>
+<span class="sourceLineNo">141</span>  List&lt;RegionLocations&gt; 
listRegionLocations() throws IOException {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    final List&lt;RegionLocations&gt; 
regions = new ArrayList&lt;&gt;();<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    MetaTableAccessor.Visitor visitor = 
new MetaTableAccessor.TableVisitorBase(tableName) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      @Override<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      public boolean visitInternal(Result 
result) throws IOException {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>        RegionLocations locations = 
MetaTableAccessor.getRegionLocations(result);<a name="line.146"></a>
+<span class="sourceLineNo">147</span>        if (locations == null) return 
true;<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        regions.add(locations);<a 
name="line.148"></a>
+<span class="sourceLineNo">149</span>        return true;<a 
name="line.149"></a>
+<span class="sourceLineNo">150</span>      }<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    };<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    
MetaTableAccessor.scanMetaForTableRegions(connection, visitor, tableName);<a 
name="line.152"></a>
+<span class="sourceLineNo">153</span>    return regions;<a name="line.153"></a>
+<span class="sourceLineNo">154</span>  }<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>  public Configuration getConfiguration() 
{<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    return 
connection.getConfiguration();<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>  public Configuration getConfiguration() 
{<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    return 
connection.getConfiguration();<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">159</span>}<a name="line.159"></a>
 
 
 

Reply via email to