hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [02/51] [partial] hbase-site git commit: Published site at .
Date Thu, 30 Nov 2017 15:18:41 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/713d773f/devapidocs/src-html/org/apache/hadoop/hbase/master/RegionState.State.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/RegionState.State.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/RegionState.State.html
index 2daacb5..fb5cc60 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/RegionState.State.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/RegionState.State.html
@@ -25,413 +25,414 @@
 <span class="sourceLineNo">017</span> */<a name="line.17"></a>
 <span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.master;<a name="line.18"></a>
 <span class="sourceLineNo">019</span><a name="line.19"></a>
-<span class="sourceLineNo">020</span>import java.util.Date;<a name="line.20"></a>
-<span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.hadoop.hbase.ServerName;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.25"></a>
-<span class="sourceLineNo">026</span><a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;<a name="line.28"></a>
-<span class="sourceLineNo">029</span><a name="line.29"></a>
-<span class="sourceLineNo">030</span>/**<a name="line.30"></a>
-<span class="sourceLineNo">031</span> * State of a Region while undergoing transitions.<a name="line.31"></a>
-<span class="sourceLineNo">032</span> * This class is immutable.<a name="line.32"></a>
-<span class="sourceLineNo">033</span> */<a name="line.33"></a>
-<span class="sourceLineNo">034</span>@InterfaceAudience.Private<a name="line.34"></a>
-<span class="sourceLineNo">035</span>public class RegionState {<a name="line.35"></a>
-<span class="sourceLineNo">036</span><a name="line.36"></a>
-<span class="sourceLineNo">037</span>  @InterfaceAudience.Private<a name="line.37"></a>
-<span class="sourceLineNo">038</span>  @InterfaceStability.Evolving<a name="line.38"></a>
-<span class="sourceLineNo">039</span>  public enum State {<a name="line.39"></a>
-<span class="sourceLineNo">040</span>    OFFLINE,        // region is in an offline state<a name="line.40"></a>
-<span class="sourceLineNo">041</span>    OPENING,        // server has begun to open but not yet done<a name="line.41"></a>
-<span class="sourceLineNo">042</span>    OPEN,           // server opened region and updated meta<a name="line.42"></a>
-<span class="sourceLineNo">043</span>    CLOSING,        // server has begun to close but not yet done<a name="line.43"></a>
-<span class="sourceLineNo">044</span>    CLOSED,         // server closed region and updated meta<a name="line.44"></a>
-<span class="sourceLineNo">045</span>    SPLITTING,      // server started split of a region<a name="line.45"></a>
-<span class="sourceLineNo">046</span>    SPLIT,          // server completed split of a region<a name="line.46"></a>
-<span class="sourceLineNo">047</span>    FAILED_OPEN,    // failed to open, and won't retry any more<a name="line.47"></a>
-<span class="sourceLineNo">048</span>    FAILED_CLOSE,   // failed to close, and won't retry any more<a name="line.48"></a>
-<span class="sourceLineNo">049</span>    MERGING,        // server started merge a region<a name="line.49"></a>
-<span class="sourceLineNo">050</span>    MERGED,         // server completed merge a region<a name="line.50"></a>
-<span class="sourceLineNo">051</span>    SPLITTING_NEW,  // new region to be created when RS splits a parent<a name="line.51"></a>
-<span class="sourceLineNo">052</span>                    // region but hasn't be created yet, or master doesn't<a name="line.52"></a>
-<span class="sourceLineNo">053</span>                    // know it's already created<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    MERGING_NEW;    // new region to be created when RS merges two<a name="line.54"></a>
-<span class="sourceLineNo">055</span>                    // daughter regions but hasn't be created yet, or<a name="line.55"></a>
-<span class="sourceLineNo">056</span>                    // master doesn't know it's already created<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>     * Convert to protobuf ClusterStatusProtos.RegionState.State<a name="line.59"></a>
-<span class="sourceLineNo">060</span>     */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>    public ClusterStatusProtos.RegionState.State convert() {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>      ClusterStatusProtos.RegionState.State rs;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      switch (this) {<a name="line.63"></a>
-<span class="sourceLineNo">064</span>      case OFFLINE:<a name="line.64"></a>
-<span class="sourceLineNo">065</span>        rs = ClusterStatusProtos.RegionState.State.OFFLINE;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>        break;<a name="line.66"></a>
-<span class="sourceLineNo">067</span>      case OPENING:<a name="line.67"></a>
-<span class="sourceLineNo">068</span>        rs = ClusterStatusProtos.RegionState.State.OPENING;<a name="line.68"></a>
-<span class="sourceLineNo">069</span>        break;<a name="line.69"></a>
-<span class="sourceLineNo">070</span>      case OPEN:<a name="line.70"></a>
-<span class="sourceLineNo">071</span>        rs = ClusterStatusProtos.RegionState.State.OPEN;<a name="line.71"></a>
-<span class="sourceLineNo">072</span>        break;<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      case CLOSING:<a name="line.73"></a>
-<span class="sourceLineNo">074</span>        rs = ClusterStatusProtos.RegionState.State.CLOSING;<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        break;<a name="line.75"></a>
-<span class="sourceLineNo">076</span>      case CLOSED:<a name="line.76"></a>
-<span class="sourceLineNo">077</span>        rs = ClusterStatusProtos.RegionState.State.CLOSED;<a name="line.77"></a>
-<span class="sourceLineNo">078</span>        break;<a name="line.78"></a>
-<span class="sourceLineNo">079</span>      case SPLITTING:<a name="line.79"></a>
-<span class="sourceLineNo">080</span>        rs = ClusterStatusProtos.RegionState.State.SPLITTING;<a name="line.80"></a>
-<span class="sourceLineNo">081</span>        break;<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      case SPLIT:<a name="line.82"></a>
-<span class="sourceLineNo">083</span>        rs = ClusterStatusProtos.RegionState.State.SPLIT;<a name="line.83"></a>
-<span class="sourceLineNo">084</span>        break;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      case FAILED_OPEN:<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        rs = ClusterStatusProtos.RegionState.State.FAILED_OPEN;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>        break;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>      case FAILED_CLOSE:<a name="line.88"></a>
-<span class="sourceLineNo">089</span>        rs = ClusterStatusProtos.RegionState.State.FAILED_CLOSE;<a name="line.89"></a>
-<span class="sourceLineNo">090</span>        break;<a name="line.90"></a>
-<span class="sourceLineNo">091</span>      case MERGING:<a name="line.91"></a>
-<span class="sourceLineNo">092</span>        rs = ClusterStatusProtos.RegionState.State.MERGING;<a name="line.92"></a>
-<span class="sourceLineNo">093</span>        break;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>      case MERGED:<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        rs = ClusterStatusProtos.RegionState.State.MERGED;<a name="line.95"></a>
-<span class="sourceLineNo">096</span>        break;<a name="line.96"></a>
-<span class="sourceLineNo">097</span>      case SPLITTING_NEW:<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        rs = ClusterStatusProtos.RegionState.State.SPLITTING_NEW;<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        break;<a name="line.99"></a>
-<span class="sourceLineNo">100</span>      case MERGING_NEW:<a name="line.100"></a>
-<span class="sourceLineNo">101</span>        rs = ClusterStatusProtos.RegionState.State.MERGING_NEW;<a name="line.101"></a>
-<span class="sourceLineNo">102</span>        break;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      default:<a name="line.103"></a>
-<span class="sourceLineNo">104</span>        throw new IllegalStateException("");<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      }<a name="line.105"></a>
-<span class="sourceLineNo">106</span>      return rs;<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>     * Convert a protobuf HBaseProtos.RegionState.State to a RegionState.State<a name="line.110"></a>
-<span class="sourceLineNo">111</span>     *<a name="line.111"></a>
-<span class="sourceLineNo">112</span>     * @return the RegionState.State<a name="line.112"></a>
-<span class="sourceLineNo">113</span>     */<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    public static State convert(ClusterStatusProtos.RegionState.State protoState) {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>      State state;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>      switch (protoState) {<a name="line.116"></a>
-<span class="sourceLineNo">117</span>      case OFFLINE:<a name="line.117"></a>
-<span class="sourceLineNo">118</span>        state = OFFLINE;<a name="line.118"></a>
-<span class="sourceLineNo">119</span>        break;<a name="line.119"></a>
-<span class="sourceLineNo">120</span>      case PENDING_OPEN:<a name="line.120"></a>
-<span class="sourceLineNo">121</span>      case OPENING:<a name="line.121"></a>
-<span class="sourceLineNo">122</span>        state = OPENING;<a name="line.122"></a>
-<span class="sourceLineNo">123</span>        break;<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      case OPEN:<a name="line.124"></a>
-<span class="sourceLineNo">125</span>        state = OPEN;<a name="line.125"></a>
-<span class="sourceLineNo">126</span>        break;<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      case PENDING_CLOSE:<a name="line.127"></a>
-<span class="sourceLineNo">128</span>      case CLOSING:<a name="line.128"></a>
-<span class="sourceLineNo">129</span>        state = CLOSING;<a name="line.129"></a>
-<span class="sourceLineNo">130</span>        break;<a name="line.130"></a>
-<span class="sourceLineNo">131</span>      case CLOSED:<a name="line.131"></a>
-<span class="sourceLineNo">132</span>        state = CLOSED;<a name="line.132"></a>
-<span class="sourceLineNo">133</span>        break;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      case SPLITTING:<a name="line.134"></a>
-<span class="sourceLineNo">135</span>        state = SPLITTING;<a name="line.135"></a>
-<span class="sourceLineNo">136</span>        break;<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      case SPLIT:<a name="line.137"></a>
-<span class="sourceLineNo">138</span>        state = SPLIT;<a name="line.138"></a>
-<span class="sourceLineNo">139</span>        break;<a name="line.139"></a>
-<span class="sourceLineNo">140</span>      case FAILED_OPEN:<a name="line.140"></a>
-<span class="sourceLineNo">141</span>        state = FAILED_OPEN;<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        break;<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      case FAILED_CLOSE:<a name="line.143"></a>
-<span class="sourceLineNo">144</span>        state = FAILED_CLOSE;<a name="line.144"></a>
-<span class="sourceLineNo">145</span>        break;<a name="line.145"></a>
-<span class="sourceLineNo">146</span>      case MERGING:<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        state = MERGING;<a name="line.147"></a>
-<span class="sourceLineNo">148</span>        break;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      case MERGED:<a name="line.149"></a>
-<span class="sourceLineNo">150</span>        state = MERGED;<a name="line.150"></a>
-<span class="sourceLineNo">151</span>        break;<a name="line.151"></a>
-<span class="sourceLineNo">152</span>      case SPLITTING_NEW:<a name="line.152"></a>
-<span class="sourceLineNo">153</span>        state = SPLITTING_NEW;<a name="line.153"></a>
-<span class="sourceLineNo">154</span>        break;<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      case MERGING_NEW:<a name="line.155"></a>
-<span class="sourceLineNo">156</span>        state = MERGING_NEW;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>        break;<a name="line.157"></a>
-<span class="sourceLineNo">158</span>      default:<a name="line.158"></a>
-<span class="sourceLineNo">159</span>        throw new IllegalStateException("Unhandled state " + protoState);<a name="line.159"></a>
-<span class="sourceLineNo">160</span>      }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      return state;<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><a name="line.164"></a>
-<span class="sourceLineNo">165</span>  private final long stamp;<a name="line.165"></a>
-<span class="sourceLineNo">166</span>  private final RegionInfo hri;<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  private final ServerName serverName;<a name="line.167"></a>
-<span class="sourceLineNo">168</span>  private final State state;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>  // The duration of region in transition<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  private long ritDuration;<a name="line.170"></a>
-<span class="sourceLineNo">171</span><a name="line.171"></a>
-<span class="sourceLineNo">172</span>  public RegionState(RegionInfo region, State state) {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>    this(region, state, System.currentTimeMillis(), null);<a name="line.173"></a>
-<span class="sourceLineNo">174</span>  }<a name="line.174"></a>
-<span class="sourceLineNo">175</span><a name="line.175"></a>
-<span class="sourceLineNo">176</span>  public RegionState(RegionInfo region,<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      State state, ServerName serverName) {<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    this(region, state, System.currentTimeMillis(), serverName);<a name="line.178"></a>
-<span class="sourceLineNo">179</span>  }<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>  public RegionState(RegionInfo region,<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      State state, long stamp, ServerName serverName) {<a name="line.182"></a>
-<span class="sourceLineNo">183</span>    this(region, state, stamp, serverName, 0);<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>  public RegionState(RegionInfo region, State state, long stamp, ServerName serverName,<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      long ritDuration) {<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    this.hri = region;<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    this.state = state;<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    this.stamp = stamp;<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    this.serverName = serverName;<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    this.ritDuration = ritDuration;<a name="line.192"></a>
-<span class="sourceLineNo">193</span>  }<a name="line.193"></a>
-<span class="sourceLineNo">194</span><a name="line.194"></a>
-<span class="sourceLineNo">195</span>  public State getState() {<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    return state;<a name="line.196"></a>
-<span class="sourceLineNo">197</span>  }<a name="line.197"></a>
-<span class="sourceLineNo">198</span><a name="line.198"></a>
-<span class="sourceLineNo">199</span>  public long getStamp() {<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    return stamp;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>  }<a name="line.201"></a>
-<span class="sourceLineNo">202</span><a name="line.202"></a>
-<span class="sourceLineNo">203</span>  public RegionInfo getRegion() {<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    return hri;<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  }<a name="line.205"></a>
-<span class="sourceLineNo">206</span><a name="line.206"></a>
-<span class="sourceLineNo">207</span>  public ServerName getServerName() {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    return serverName;<a name="line.208"></a>
-<span class="sourceLineNo">209</span>  }<a name="line.209"></a>
-<span class="sourceLineNo">210</span><a name="line.210"></a>
-<span class="sourceLineNo">211</span>  public long getRitDuration() {<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    return ritDuration;<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>  /**<a name="line.215"></a>
-<span class="sourceLineNo">216</span>   * Update the duration of region in transition<a name="line.216"></a>
-<span class="sourceLineNo">217</span>   * @param previousStamp previous RegionState's timestamp<a name="line.217"></a>
-<span class="sourceLineNo">218</span>   */<a name="line.218"></a>
-<span class="sourceLineNo">219</span>  @InterfaceAudience.Private<a name="line.219"></a>
-<span class="sourceLineNo">220</span>  void updateRitDuration(long previousStamp) {<a name="line.220"></a>
-<span class="sourceLineNo">221</span>    this.ritDuration += (this.stamp - previousStamp);<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>  public boolean isClosing() {<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    return state == State.CLOSING;<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>  public boolean isClosed() {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>    return state == State.CLOSED;<a name="line.229"></a>
-<span class="sourceLineNo">230</span>  }<a name="line.230"></a>
-<span class="sourceLineNo">231</span><a name="line.231"></a>
-<span class="sourceLineNo">232</span>  public boolean isOpening() {<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    return state == State.OPENING;<a name="line.233"></a>
-<span class="sourceLineNo">234</span>  }<a name="line.234"></a>
-<span class="sourceLineNo">235</span><a name="line.235"></a>
-<span class="sourceLineNo">236</span>  public boolean isOpened() {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>    return state == State.OPEN;<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>  public boolean isOffline() {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    return state == State.OFFLINE;<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>  public boolean isSplitting() {<a name="line.244"></a>
-<span class="sourceLineNo">245</span>    return state == State.SPLITTING;<a name="line.245"></a>
-<span class="sourceLineNo">246</span>  }<a name="line.246"></a>
-<span class="sourceLineNo">247</span><a name="line.247"></a>
-<span class="sourceLineNo">248</span>  public boolean isSplit() {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    return state == State.SPLIT;<a name="line.249"></a>
-<span class="sourceLineNo">250</span>  }<a name="line.250"></a>
-<span class="sourceLineNo">251</span><a name="line.251"></a>
-<span class="sourceLineNo">252</span>  public boolean isSplittingNew() {<a name="line.252"></a>
-<span class="sourceLineNo">253</span>    return state == State.SPLITTING_NEW;<a name="line.253"></a>
-<span class="sourceLineNo">254</span>  }<a name="line.254"></a>
-<span class="sourceLineNo">255</span><a name="line.255"></a>
-<span class="sourceLineNo">256</span>  public boolean isFailedOpen() {<a name="line.256"></a>
-<span class="sourceLineNo">257</span>    return state == State.FAILED_OPEN;<a name="line.257"></a>
-<span class="sourceLineNo">258</span>  }<a name="line.258"></a>
-<span class="sourceLineNo">259</span><a name="line.259"></a>
-<span class="sourceLineNo">260</span>  public boolean isFailedClose() {<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    return state == State.FAILED_CLOSE;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  }<a name="line.262"></a>
-<span class="sourceLineNo">263</span><a name="line.263"></a>
-<span class="sourceLineNo">264</span>  public boolean isMerging() {<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    return state == State.MERGING;<a name="line.265"></a>
-<span class="sourceLineNo">266</span>  }<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>  public boolean isMerged() {<a name="line.268"></a>
-<span class="sourceLineNo">269</span>    return state == State.MERGED;<a name="line.269"></a>
-<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
-<span class="sourceLineNo">271</span><a name="line.271"></a>
-<span class="sourceLineNo">272</span>  public boolean isMergingNew() {<a name="line.272"></a>
-<span class="sourceLineNo">273</span>    return state == State.MERGING_NEW;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>  }<a name="line.274"></a>
-<span class="sourceLineNo">275</span><a name="line.275"></a>
-<span class="sourceLineNo">276</span>  public boolean isOnServer(final ServerName sn) {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>    return serverName != null &amp;&amp; serverName.equals(sn);<a name="line.277"></a>
-<span class="sourceLineNo">278</span>  }<a name="line.278"></a>
-<span class="sourceLineNo">279</span><a name="line.279"></a>
-<span class="sourceLineNo">280</span>  public boolean isMergingOnServer(final ServerName sn) {<a name="line.280"></a>
-<span class="sourceLineNo">281</span>    return isOnServer(sn) &amp;&amp; isMerging();<a name="line.281"></a>
-<span class="sourceLineNo">282</span>  }<a name="line.282"></a>
-<span class="sourceLineNo">283</span><a name="line.283"></a>
-<span class="sourceLineNo">284</span>  public boolean isMergingNewOnServer(final ServerName sn) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    return isOnServer(sn) &amp;&amp; isMergingNew();<a name="line.285"></a>
-<span class="sourceLineNo">286</span>  }<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>  public boolean isMergingNewOrOpenedOnServer(final ServerName sn) {<a name="line.288"></a>
-<span class="sourceLineNo">289</span>    return isOnServer(sn) &amp;&amp; (isMergingNew() || isOpened());<a name="line.289"></a>
-<span class="sourceLineNo">290</span>  }<a name="line.290"></a>
-<span class="sourceLineNo">291</span><a name="line.291"></a>
-<span class="sourceLineNo">292</span>  public boolean isMergingNewOrOfflineOnServer(final ServerName sn) {<a name="line.292"></a>
-<span class="sourceLineNo">293</span>    return isOnServer(sn) &amp;&amp; (isMergingNew() || isOffline());<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>  public boolean isSplittingOnServer(final ServerName sn) {<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    return isOnServer(sn) &amp;&amp; isSplitting();<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>  public boolean isSplittingNewOnServer(final ServerName sn) {<a name="line.300"></a>
-<span class="sourceLineNo">301</span>    return isOnServer(sn) &amp;&amp; isSplittingNew();<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 boolean isSplittingOrOpenedOnServer(final ServerName sn) {<a name="line.304"></a>
-<span class="sourceLineNo">305</span>    return isOnServer(sn) &amp;&amp; (isSplitting() || isOpened());<a name="line.305"></a>
-<span class="sourceLineNo">306</span>  }<a name="line.306"></a>
-<span class="sourceLineNo">307</span><a name="line.307"></a>
-<span class="sourceLineNo">308</span>  public boolean isSplittingOrSplitOnServer(final ServerName sn) {<a name="line.308"></a>
-<span class="sourceLineNo">309</span>    return isOnServer(sn) &amp;&amp; (isSplitting() || isSplit());<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>  public boolean isClosingOrClosedOnServer(final ServerName sn) {<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    return isOnServer(sn) &amp;&amp; (isClosing() || isClosed());<a name="line.313"></a>
-<span class="sourceLineNo">314</span>  }<a name="line.314"></a>
-<span class="sourceLineNo">315</span><a name="line.315"></a>
-<span class="sourceLineNo">316</span>  public boolean isOpeningOrFailedOpenOnServer(final ServerName sn) {<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    return isOnServer(sn) &amp;&amp; (isOpening() || isFailedOpen());<a name="line.317"></a>
-<span class="sourceLineNo">318</span>  }<a name="line.318"></a>
-<span class="sourceLineNo">319</span><a name="line.319"></a>
-<span class="sourceLineNo">320</span>  public boolean isOpeningOrOpenedOnServer(final ServerName sn) {<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    return isOnServer(sn) &amp;&amp; (isOpening() || isOpened());<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>  public boolean isOpenedOnServer(final ServerName sn) {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    return isOnServer(sn) &amp;&amp; isOpened();<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>  /**<a name="line.328"></a>
-<span class="sourceLineNo">329</span>   * Check if a region state can transition to offline<a name="line.329"></a>
-<span class="sourceLineNo">330</span>   */<a name="line.330"></a>
-<span class="sourceLineNo">331</span>  public boolean isReadyToOffline() {<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    return isMerged() || isSplit() || isOffline()<a name="line.332"></a>
-<span class="sourceLineNo">333</span>      || isSplittingNew() || isMergingNew();<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>   * Check if a region state can transition to online<a name="line.337"></a>
-<span class="sourceLineNo">338</span>   */<a name="line.338"></a>
-<span class="sourceLineNo">339</span>  public boolean isReadyToOnline() {<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    return isOpened() || isSplittingNew() || isMergingNew();<a name="line.340"></a>
-<span class="sourceLineNo">341</span>  }<a name="line.341"></a>
-<span class="sourceLineNo">342</span><a name="line.342"></a>
-<span class="sourceLineNo">343</span>  /**<a name="line.343"></a>
-<span class="sourceLineNo">344</span>   * Check if a region state is one of offline states that<a name="line.344"></a>
-<span class="sourceLineNo">345</span>   * can't transition to pending_close/closing (unassign/offline)<a name="line.345"></a>
-<span class="sourceLineNo">346</span>   */<a name="line.346"></a>
-<span class="sourceLineNo">347</span>  public boolean isUnassignable() {<a name="line.347"></a>
-<span class="sourceLineNo">348</span>    return isUnassignable(state);<a name="line.348"></a>
-<span class="sourceLineNo">349</span>  }<a name="line.349"></a>
-<span class="sourceLineNo">350</span><a name="line.350"></a>
-<span class="sourceLineNo">351</span>  /**<a name="line.351"></a>
-<span class="sourceLineNo">352</span>   * Check if a region state is one of offline states that<a name="line.352"></a>
-<span class="sourceLineNo">353</span>   * can't transition to pending_close/closing (unassign/offline)<a name="line.353"></a>
-<span class="sourceLineNo">354</span>   */<a name="line.354"></a>
-<span class="sourceLineNo">355</span>  public static boolean isUnassignable(State state) {<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    return state == State.MERGED || state == State.SPLIT || state == State.OFFLINE<a name="line.356"></a>
-<span class="sourceLineNo">357</span>      || state == State.SPLITTING_NEW || state == State.MERGING_NEW;<a name="line.357"></a>
-<span class="sourceLineNo">358</span>  }<a name="line.358"></a>
-<span class="sourceLineNo">359</span><a name="line.359"></a>
-<span class="sourceLineNo">360</span>  @Override<a name="line.360"></a>
-<span class="sourceLineNo">361</span>  public String toString() {<a name="line.361"></a>
-<span class="sourceLineNo">362</span>    return "{" + hri.getShortNameToLog()<a name="line.362"></a>
-<span class="sourceLineNo">363</span>      + " state=" + state<a name="line.363"></a>
-<span class="sourceLineNo">364</span>      + ", ts=" + stamp<a name="line.364"></a>
-<span class="sourceLineNo">365</span>      + ", server=" + serverName + "}";<a name="line.365"></a>
-<span class="sourceLineNo">366</span>  }<a name="line.366"></a>
-<span class="sourceLineNo">367</span><a name="line.367"></a>
-<span class="sourceLineNo">368</span>  /**<a name="line.368"></a>
-<span class="sourceLineNo">369</span>   * A slower (but more easy-to-read) stringification<a name="line.369"></a>
-<span class="sourceLineNo">370</span>   */<a name="line.370"></a>
-<span class="sourceLineNo">371</span>  public String toDescriptiveString() {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>    long relTime = System.currentTimeMillis() - stamp;<a name="line.372"></a>
-<span class="sourceLineNo">373</span>    return hri.getRegionNameAsString()<a name="line.373"></a>
-<span class="sourceLineNo">374</span>      + " state=" + state<a name="line.374"></a>
-<span class="sourceLineNo">375</span>      + ", ts=" + new Date(stamp) + " (" + (relTime/1000) + "s ago)"<a name="line.375"></a>
-<span class="sourceLineNo">376</span>      + ", server=" + serverName;<a name="line.376"></a>
-<span class="sourceLineNo">377</span>  }<a name="line.377"></a>
-<span class="sourceLineNo">378</span><a name="line.378"></a>
-<span class="sourceLineNo">379</span>  /**<a name="line.379"></a>
-<span class="sourceLineNo">380</span>   * Convert a RegionState to an HBaseProtos.RegionState<a name="line.380"></a>
-<span class="sourceLineNo">381</span>   *<a name="line.381"></a>
-<span class="sourceLineNo">382</span>   * @return the converted HBaseProtos.RegionState<a name="line.382"></a>
-<span class="sourceLineNo">383</span>   */<a name="line.383"></a>
-<span class="sourceLineNo">384</span>  public ClusterStatusProtos.RegionState convert() {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>    ClusterStatusProtos.RegionState.Builder regionState = ClusterStatusProtos.RegionState.newBuilder();<a name="line.385"></a>
-<span class="sourceLineNo">386</span>    regionState.setRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.386"></a>
-<span class="sourceLineNo">387</span>    regionState.setState(state.convert());<a name="line.387"></a>
-<span class="sourceLineNo">388</span>    regionState.setStamp(getStamp());<a name="line.388"></a>
-<span class="sourceLineNo">389</span>    return regionState.build();<a name="line.389"></a>
-<span class="sourceLineNo">390</span>  }<a name="line.390"></a>
-<span class="sourceLineNo">391</span><a name="line.391"></a>
-<span class="sourceLineNo">392</span>  /**<a name="line.392"></a>
-<span class="sourceLineNo">393</span>   * Convert a protobuf HBaseProtos.RegionState to a RegionState<a name="line.393"></a>
-<span class="sourceLineNo">394</span>   *<a name="line.394"></a>
-<span class="sourceLineNo">395</span>   * @return the RegionState<a name="line.395"></a>
-<span class="sourceLineNo">396</span>   */<a name="line.396"></a>
-<span class="sourceLineNo">397</span>  public static RegionState convert(ClusterStatusProtos.RegionState proto) {<a name="line.397"></a>
-<span class="sourceLineNo">398</span>    return new RegionState(ProtobufUtil.toRegionInfo(proto.getRegionInfo()),<a name="line.398"></a>
-<span class="sourceLineNo">399</span>      State.convert(proto.getState()), proto.getStamp(), null);<a name="line.399"></a>
-<span class="sourceLineNo">400</span>  }<a name="line.400"></a>
-<span class="sourceLineNo">401</span><a name="line.401"></a>
-<span class="sourceLineNo">402</span>  /**<a name="line.402"></a>
-<span class="sourceLineNo">403</span>   * Check if two states are the same, except timestamp<a name="line.403"></a>
-<span class="sourceLineNo">404</span>   */<a name="line.404"></a>
-<span class="sourceLineNo">405</span>  @Override<a name="line.405"></a>
-<span class="sourceLineNo">406</span>  public boolean equals(Object obj) {<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    if (this == obj) return true;<a name="line.407"></a>
-<span class="sourceLineNo">408</span>    if (obj == null || getClass() != obj.getClass()) {<a name="line.408"></a>
-<span class="sourceLineNo">409</span>      return false;<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    }<a name="line.410"></a>
-<span class="sourceLineNo">411</span>    RegionState tmp = (RegionState)obj;<a name="line.411"></a>
-<span class="sourceLineNo">412</span><a name="line.412"></a>
-<span class="sourceLineNo">413</span>    return RegionInfo.COMPARATOR.compare(tmp.hri, hri) == 0 &amp;&amp; tmp.state == state<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      &amp;&amp; ((serverName != null &amp;&amp; serverName.equals(tmp.serverName))<a name="line.414"></a>
-<span class="sourceLineNo">415</span>        || (tmp.serverName == null &amp;&amp; serverName == null));<a name="line.415"></a>
-<span class="sourceLineNo">416</span>  }<a name="line.416"></a>
-<span class="sourceLineNo">417</span><a name="line.417"></a>
-<span class="sourceLineNo">418</span>  /**<a name="line.418"></a>
-<span class="sourceLineNo">419</span>   * Don't count timestamp in hash code calculation<a name="line.419"></a>
-<span class="sourceLineNo">420</span>   */<a name="line.420"></a>
-<span class="sourceLineNo">421</span>  @Override<a name="line.421"></a>
-<span class="sourceLineNo">422</span>  public int hashCode() {<a name="line.422"></a>
-<span class="sourceLineNo">423</span>    return (serverName != null ? serverName.hashCode() * 11 : 0)<a name="line.423"></a>
-<span class="sourceLineNo">424</span>      + hri.hashCode() + 5 * state.ordinal();<a name="line.424"></a>
-<span class="sourceLineNo">425</span>  }<a name="line.425"></a>
-<span class="sourceLineNo">426</span>}<a name="line.426"></a>
+<span class="sourceLineNo">020</span>import com.google.common.annotations.VisibleForTesting;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.Date;<a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.ServerName;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.client.RegionInfo;<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>import org.apache.yetus.audience.InterfaceStability;<a name="line.26"></a>
+<span class="sourceLineNo">027</span><a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;<a name="line.29"></a>
+<span class="sourceLineNo">030</span><a name="line.30"></a>
+<span class="sourceLineNo">031</span>/**<a name="line.31"></a>
+<span class="sourceLineNo">032</span> * State of a Region while undergoing transitions.<a name="line.32"></a>
+<span class="sourceLineNo">033</span> * This class is immutable.<a name="line.33"></a>
+<span class="sourceLineNo">034</span> */<a name="line.34"></a>
+<span class="sourceLineNo">035</span>@InterfaceAudience.Private<a name="line.35"></a>
+<span class="sourceLineNo">036</span>public class RegionState {<a name="line.36"></a>
+<span class="sourceLineNo">037</span><a name="line.37"></a>
+<span class="sourceLineNo">038</span>  @InterfaceAudience.Private<a name="line.38"></a>
+<span class="sourceLineNo">039</span>  @InterfaceStability.Evolving<a name="line.39"></a>
+<span class="sourceLineNo">040</span>  public enum State {<a name="line.40"></a>
+<span class="sourceLineNo">041</span>    OFFLINE,        // region is in an offline state<a name="line.41"></a>
+<span class="sourceLineNo">042</span>    OPENING,        // server has begun to open but not yet done<a name="line.42"></a>
+<span class="sourceLineNo">043</span>    OPEN,           // server opened region and updated meta<a name="line.43"></a>
+<span class="sourceLineNo">044</span>    CLOSING,        // server has begun to close but not yet done<a name="line.44"></a>
+<span class="sourceLineNo">045</span>    CLOSED,         // server closed region and updated meta<a name="line.45"></a>
+<span class="sourceLineNo">046</span>    SPLITTING,      // server started split of a region<a name="line.46"></a>
+<span class="sourceLineNo">047</span>    SPLIT,          // server completed split of a region<a name="line.47"></a>
+<span class="sourceLineNo">048</span>    FAILED_OPEN,    // failed to open, and won't retry any more<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    FAILED_CLOSE,   // failed to close, and won't retry any more<a name="line.49"></a>
+<span class="sourceLineNo">050</span>    MERGING,        // server started merge a region<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    MERGED,         // server completed merge a region<a name="line.51"></a>
+<span class="sourceLineNo">052</span>    SPLITTING_NEW,  // new region to be created when RS splits a parent<a name="line.52"></a>
+<span class="sourceLineNo">053</span>                    // region but hasn't be created yet, or master doesn't<a name="line.53"></a>
+<span class="sourceLineNo">054</span>                    // know it's already created<a name="line.54"></a>
+<span class="sourceLineNo">055</span>    MERGING_NEW;    // new region to be created when RS merges two<a name="line.55"></a>
+<span class="sourceLineNo">056</span>                    // daughter regions but hasn't be created yet, or<a name="line.56"></a>
+<span class="sourceLineNo">057</span>                    // master doesn't know it's already created<a name="line.57"></a>
+<span class="sourceLineNo">058</span><a name="line.58"></a>
+<span class="sourceLineNo">059</span>    /**<a name="line.59"></a>
+<span class="sourceLineNo">060</span>     * Convert to protobuf ClusterStatusProtos.RegionState.State<a name="line.60"></a>
+<span class="sourceLineNo">061</span>     */<a name="line.61"></a>
+<span class="sourceLineNo">062</span>    public ClusterStatusProtos.RegionState.State convert() {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>      ClusterStatusProtos.RegionState.State rs;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      switch (this) {<a name="line.64"></a>
+<span class="sourceLineNo">065</span>      case OFFLINE:<a name="line.65"></a>
+<span class="sourceLineNo">066</span>        rs = ClusterStatusProtos.RegionState.State.OFFLINE;<a name="line.66"></a>
+<span class="sourceLineNo">067</span>        break;<a name="line.67"></a>
+<span class="sourceLineNo">068</span>      case OPENING:<a name="line.68"></a>
+<span class="sourceLineNo">069</span>        rs = ClusterStatusProtos.RegionState.State.OPENING;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>        break;<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      case OPEN:<a name="line.71"></a>
+<span class="sourceLineNo">072</span>        rs = ClusterStatusProtos.RegionState.State.OPEN;<a name="line.72"></a>
+<span class="sourceLineNo">073</span>        break;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>      case CLOSING:<a name="line.74"></a>
+<span class="sourceLineNo">075</span>        rs = ClusterStatusProtos.RegionState.State.CLOSING;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>        break;<a name="line.76"></a>
+<span class="sourceLineNo">077</span>      case CLOSED:<a name="line.77"></a>
+<span class="sourceLineNo">078</span>        rs = ClusterStatusProtos.RegionState.State.CLOSED;<a name="line.78"></a>
+<span class="sourceLineNo">079</span>        break;<a name="line.79"></a>
+<span class="sourceLineNo">080</span>      case SPLITTING:<a name="line.80"></a>
+<span class="sourceLineNo">081</span>        rs = ClusterStatusProtos.RegionState.State.SPLITTING;<a name="line.81"></a>
+<span class="sourceLineNo">082</span>        break;<a name="line.82"></a>
+<span class="sourceLineNo">083</span>      case SPLIT:<a name="line.83"></a>
+<span class="sourceLineNo">084</span>        rs = ClusterStatusProtos.RegionState.State.SPLIT;<a name="line.84"></a>
+<span class="sourceLineNo">085</span>        break;<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      case FAILED_OPEN:<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        rs = ClusterStatusProtos.RegionState.State.FAILED_OPEN;<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        break;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>      case FAILED_CLOSE:<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        rs = ClusterStatusProtos.RegionState.State.FAILED_CLOSE;<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        break;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      case MERGING:<a name="line.92"></a>
+<span class="sourceLineNo">093</span>        rs = ClusterStatusProtos.RegionState.State.MERGING;<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        break;<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      case MERGED:<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        rs = ClusterStatusProtos.RegionState.State.MERGED;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        break;<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      case SPLITTING_NEW:<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        rs = ClusterStatusProtos.RegionState.State.SPLITTING_NEW;<a name="line.99"></a>
+<span class="sourceLineNo">100</span>        break;<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      case MERGING_NEW:<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        rs = ClusterStatusProtos.RegionState.State.MERGING_NEW;<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        break;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      default:<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        throw new IllegalStateException("");<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      }<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      return rs;<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>    /**<a name="line.110"></a>
+<span class="sourceLineNo">111</span>     * Convert a protobuf HBaseProtos.RegionState.State to a RegionState.State<a name="line.111"></a>
+<span class="sourceLineNo">112</span>     *<a name="line.112"></a>
+<span class="sourceLineNo">113</span>     * @return the RegionState.State<a name="line.113"></a>
+<span class="sourceLineNo">114</span>     */<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    public static State convert(ClusterStatusProtos.RegionState.State protoState) {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>      State state;<a name="line.116"></a>
+<span class="sourceLineNo">117</span>      switch (protoState) {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>      case OFFLINE:<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        state = OFFLINE;<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        break;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>      case PENDING_OPEN:<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      case OPENING:<a name="line.122"></a>
+<span class="sourceLineNo">123</span>        state = OPENING;<a name="line.123"></a>
+<span class="sourceLineNo">124</span>        break;<a name="line.124"></a>
+<span class="sourceLineNo">125</span>      case OPEN:<a name="line.125"></a>
+<span class="sourceLineNo">126</span>        state = OPEN;<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        break;<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      case PENDING_CLOSE:<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      case CLOSING:<a name="line.129"></a>
+<span class="sourceLineNo">130</span>        state = CLOSING;<a name="line.130"></a>
+<span class="sourceLineNo">131</span>        break;<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      case CLOSED:<a name="line.132"></a>
+<span class="sourceLineNo">133</span>        state = CLOSED;<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        break;<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      case SPLITTING:<a name="line.135"></a>
+<span class="sourceLineNo">136</span>        state = SPLITTING;<a name="line.136"></a>
+<span class="sourceLineNo">137</span>        break;<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      case SPLIT:<a name="line.138"></a>
+<span class="sourceLineNo">139</span>        state = SPLIT;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>        break;<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      case FAILED_OPEN:<a name="line.141"></a>
+<span class="sourceLineNo">142</span>        state = FAILED_OPEN;<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        break;<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      case FAILED_CLOSE:<a name="line.144"></a>
+<span class="sourceLineNo">145</span>        state = FAILED_CLOSE;<a name="line.145"></a>
+<span class="sourceLineNo">146</span>        break;<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      case MERGING:<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        state = MERGING;<a name="line.148"></a>
+<span class="sourceLineNo">149</span>        break;<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      case MERGED:<a name="line.150"></a>
+<span class="sourceLineNo">151</span>        state = MERGED;<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        break;<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      case SPLITTING_NEW:<a name="line.153"></a>
+<span class="sourceLineNo">154</span>        state = SPLITTING_NEW;<a name="line.154"></a>
+<span class="sourceLineNo">155</span>        break;<a name="line.155"></a>
+<span class="sourceLineNo">156</span>      case MERGING_NEW:<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        state = MERGING_NEW;<a name="line.157"></a>
+<span class="sourceLineNo">158</span>        break;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>      default:<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        throw new IllegalStateException("Unhandled state " + protoState);<a name="line.160"></a>
+<span class="sourceLineNo">161</span>      }<a name="line.161"></a>
+<span class="sourceLineNo">162</span>      return state;<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    }<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>  private final long stamp;<a name="line.166"></a>
+<span class="sourceLineNo">167</span>  private final RegionInfo hri;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>  private final ServerName serverName;<a name="line.168"></a>
+<span class="sourceLineNo">169</span>  private final State state;<a name="line.169"></a>
+<span class="sourceLineNo">170</span>  // The duration of region in transition<a name="line.170"></a>
+<span class="sourceLineNo">171</span>  private long ritDuration;<a name="line.171"></a>
+<span class="sourceLineNo">172</span><a name="line.172"></a>
+<span class="sourceLineNo">173</span>  @VisibleForTesting<a name="line.173"></a>
+<span class="sourceLineNo">174</span>  public static RegionState createForTesting(RegionInfo region, State state) {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    return new RegionState(region, state, System.currentTimeMillis(), null);<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>  public RegionState(RegionInfo region, State state, ServerName serverName) {<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    this(region, state, System.currentTimeMillis(), serverName);<a name="line.179"></a>
+<span class="sourceLineNo">180</span>  }<a name="line.180"></a>
+<span class="sourceLineNo">181</span><a name="line.181"></a>
+<span class="sourceLineNo">182</span>  public RegionState(RegionInfo region,<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      State state, long stamp, ServerName serverName) {<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    this(region, state, stamp, serverName, 0);<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>  public RegionState(RegionInfo region, State state, long stamp, ServerName serverName,<a name="line.187"></a>
+<span class="sourceLineNo">188</span>      long ritDuration) {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    this.hri = region;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    this.state = state;<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    this.stamp = stamp;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    this.serverName = serverName;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    this.ritDuration = ritDuration;<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  }<a name="line.194"></a>
+<span class="sourceLineNo">195</span><a name="line.195"></a>
+<span class="sourceLineNo">196</span>  public State getState() {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    return state;<a name="line.197"></a>
+<span class="sourceLineNo">198</span>  }<a name="line.198"></a>
+<span class="sourceLineNo">199</span><a name="line.199"></a>
+<span class="sourceLineNo">200</span>  public long getStamp() {<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    return stamp;<a name="line.201"></a>
+<span class="sourceLineNo">202</span>  }<a name="line.202"></a>
+<span class="sourceLineNo">203</span><a name="line.203"></a>
+<span class="sourceLineNo">204</span>  public RegionInfo getRegion() {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    return hri;<a name="line.205"></a>
+<span class="sourceLineNo">206</span>  }<a name="line.206"></a>
+<span class="sourceLineNo">207</span><a name="line.207"></a>
+<span class="sourceLineNo">208</span>  public ServerName getServerName() {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    return serverName;<a name="line.209"></a>
+<span class="sourceLineNo">210</span>  }<a name="line.210"></a>
+<span class="sourceLineNo">211</span><a name="line.211"></a>
+<span class="sourceLineNo">212</span>  public long getRitDuration() {<a name="line.212"></a>
+<span class="sourceLineNo">213</span>    return ritDuration;<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>  /**<a name="line.216"></a>
+<span class="sourceLineNo">217</span>   * Update the duration of region in transition<a name="line.217"></a>
+<span class="sourceLineNo">218</span>   * @param previousStamp previous RegionState's timestamp<a name="line.218"></a>
+<span class="sourceLineNo">219</span>   */<a name="line.219"></a>
+<span class="sourceLineNo">220</span>  @InterfaceAudience.Private<a name="line.220"></a>
+<span class="sourceLineNo">221</span>  void updateRitDuration(long previousStamp) {<a name="line.221"></a>
+<span class="sourceLineNo">222</span>    this.ritDuration += (this.stamp - previousStamp);<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>  public boolean isClosing() {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    return state == State.CLOSING;<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>  public boolean isClosed() {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    return state == State.CLOSED;<a name="line.230"></a>
+<span class="sourceLineNo">231</span>  }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>  public boolean isOpening() {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>    return state == State.OPENING;<a name="line.234"></a>
+<span class="sourceLineNo">235</span>  }<a name="line.235"></a>
+<span class="sourceLineNo">236</span><a name="line.236"></a>
+<span class="sourceLineNo">237</span>  public boolean isOpened() {<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    return state == State.OPEN;<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>  public boolean isOffline() {<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    return state == State.OFFLINE;<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>  public boolean isSplitting() {<a name="line.245"></a>
+<span class="sourceLineNo">246</span>    return state == State.SPLITTING;<a name="line.246"></a>
+<span class="sourceLineNo">247</span>  }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>  public boolean isSplit() {<a name="line.249"></a>
+<span class="sourceLineNo">250</span>    return state == State.SPLIT;<a name="line.250"></a>
+<span class="sourceLineNo">251</span>  }<a name="line.251"></a>
+<span class="sourceLineNo">252</span><a name="line.252"></a>
+<span class="sourceLineNo">253</span>  public boolean isSplittingNew() {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    return state == State.SPLITTING_NEW;<a name="line.254"></a>
+<span class="sourceLineNo">255</span>  }<a name="line.255"></a>
+<span class="sourceLineNo">256</span><a name="line.256"></a>
+<span class="sourceLineNo">257</span>  public boolean isFailedOpen() {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>    return state == State.FAILED_OPEN;<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>  public boolean isFailedClose() {<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    return state == State.FAILED_CLOSE;<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  }<a name="line.263"></a>
+<span class="sourceLineNo">264</span><a name="line.264"></a>
+<span class="sourceLineNo">265</span>  public boolean isMerging() {<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    return state == State.MERGING;<a name="line.266"></a>
+<span class="sourceLineNo">267</span>  }<a name="line.267"></a>
+<span class="sourceLineNo">268</span><a name="line.268"></a>
+<span class="sourceLineNo">269</span>  public boolean isMerged() {<a name="line.269"></a>
+<span class="sourceLineNo">270</span>    return state == State.MERGED;<a name="line.270"></a>
+<span class="sourceLineNo">271</span>  }<a name="line.271"></a>
+<span class="sourceLineNo">272</span><a name="line.272"></a>
+<span class="sourceLineNo">273</span>  public boolean isMergingNew() {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>    return state == State.MERGING_NEW;<a name="line.274"></a>
+<span class="sourceLineNo">275</span>  }<a name="line.275"></a>
+<span class="sourceLineNo">276</span><a name="line.276"></a>
+<span class="sourceLineNo">277</span>  public boolean isOnServer(final ServerName sn) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>    return serverName != null &amp;&amp; serverName.equals(sn);<a name="line.278"></a>
+<span class="sourceLineNo">279</span>  }<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>  public boolean isMergingOnServer(final ServerName sn) {<a name="line.281"></a>
+<span class="sourceLineNo">282</span>    return isOnServer(sn) &amp;&amp; isMerging();<a name="line.282"></a>
+<span class="sourceLineNo">283</span>  }<a name="line.283"></a>
+<span class="sourceLineNo">284</span><a name="line.284"></a>
+<span class="sourceLineNo">285</span>  public boolean isMergingNewOnServer(final ServerName sn) {<a name="line.285"></a>
+<span class="sourceLineNo">286</span>    return isOnServer(sn) &amp;&amp; isMergingNew();<a name="line.286"></a>
+<span class="sourceLineNo">287</span>  }<a name="line.287"></a>
+<span class="sourceLineNo">288</span><a name="line.288"></a>
+<span class="sourceLineNo">289</span>  public boolean isMergingNewOrOpenedOnServer(final ServerName sn) {<a name="line.289"></a>
+<span class="sourceLineNo">290</span>    return isOnServer(sn) &amp;&amp; (isMergingNew() || isOpened());<a name="line.290"></a>
+<span class="sourceLineNo">291</span>  }<a name="line.291"></a>
+<span class="sourceLineNo">292</span><a name="line.292"></a>
+<span class="sourceLineNo">293</span>  public boolean isMergingNewOrOfflineOnServer(final ServerName sn) {<a name="line.293"></a>
+<span class="sourceLineNo">294</span>    return isOnServer(sn) &amp;&amp; (isMergingNew() || isOffline());<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>  public boolean isSplittingOnServer(final ServerName sn) {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>    return isOnServer(sn) &amp;&amp; isSplitting();<a name="line.298"></a>
+<span class="sourceLineNo">299</span>  }<a name="line.299"></a>
+<span class="sourceLineNo">300</span><a name="line.300"></a>
+<span class="sourceLineNo">301</span>  public boolean isSplittingNewOnServer(final ServerName sn) {<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    return isOnServer(sn) &amp;&amp; isSplittingNew();<a name="line.302"></a>
+<span class="sourceLineNo">303</span>  }<a name="line.303"></a>
+<span class="sourceLineNo">304</span><a name="line.304"></a>
+<span class="sourceLineNo">305</span>  public boolean isSplittingOrOpenedOnServer(final ServerName sn) {<a name="line.305"></a>
+<span class="sourceLineNo">306</span>    return isOnServer(sn) &amp;&amp; (isSplitting() || isOpened());<a name="line.306"></a>
+<span class="sourceLineNo">307</span>  }<a name="line.307"></a>
+<span class="sourceLineNo">308</span><a name="line.308"></a>
+<span class="sourceLineNo">309</span>  public boolean isSplittingOrSplitOnServer(final ServerName sn) {<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    return isOnServer(sn) &amp;&amp; (isSplitting() || isSplit());<a name="line.310"></a>
+<span class="sourceLineNo">311</span>  }<a name="line.311"></a>
+<span class="sourceLineNo">312</span><a name="line.312"></a>
+<span class="sourceLineNo">313</span>  public boolean isClosingOrClosedOnServer(final ServerName sn) {<a name="line.313"></a>
+<span class="sourceLineNo">314</span>    return isOnServer(sn) &amp;&amp; (isClosing() || isClosed());<a name="line.314"></a>
+<span class="sourceLineNo">315</span>  }<a name="line.315"></a>
+<span class="sourceLineNo">316</span><a name="line.316"></a>
+<span class="sourceLineNo">317</span>  public boolean isOpeningOrFailedOpenOnServer(final ServerName sn) {<a name="line.317"></a>
+<span class="sourceLineNo">318</span>    return isOnServer(sn) &amp;&amp; (isOpening() || isFailedOpen());<a name="line.318"></a>
+<span class="sourceLineNo">319</span>  }<a name="line.319"></a>
+<span class="sourceLineNo">320</span><a name="line.320"></a>
+<span class="sourceLineNo">321</span>  public boolean isOpeningOrOpenedOnServer(final ServerName sn) {<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    return isOnServer(sn) &amp;&amp; (isOpening() || isOpened());<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>  public boolean isOpenedOnServer(final ServerName sn) {<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    return isOnServer(sn) &amp;&amp; isOpened();<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>  /**<a name="line.329"></a>
+<span class="sourceLineNo">330</span>   * Check if a region state can transition to offline<a name="line.330"></a>
+<span class="sourceLineNo">331</span>   */<a name="line.331"></a>
+<span class="sourceLineNo">332</span>  public boolean isReadyToOffline() {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>    return isMerged() || isSplit() || isOffline()<a name="line.333"></a>
+<span class="sourceLineNo">334</span>      || isSplittingNew() || isMergingNew();<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>   * Check if a region state can transition to online<a name="line.338"></a>
+<span class="sourceLineNo">339</span>   */<a name="line.339"></a>
+<span class="sourceLineNo">340</span>  public boolean isReadyToOnline() {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>    return isOpened() || isSplittingNew() || isMergingNew();<a name="line.341"></a>
+<span class="sourceLineNo">342</span>  }<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>   * Check if a region state is one of offline states that<a name="line.345"></a>
+<span class="sourceLineNo">346</span>   * can't transition to pending_close/closing (unassign/offline)<a name="line.346"></a>
+<span class="sourceLineNo">347</span>   */<a name="line.347"></a>
+<span class="sourceLineNo">348</span>  public boolean isUnassignable() {<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    return isUnassignable(state);<a name="line.349"></a>
+<span class="sourceLineNo">350</span>  }<a name="line.350"></a>
+<span class="sourceLineNo">351</span><a name="line.351"></a>
+<span class="sourceLineNo">352</span>  /**<a name="line.352"></a>
+<span class="sourceLineNo">353</span>   * Check if a region state is one of offline states that<a name="line.353"></a>
+<span class="sourceLineNo">354</span>   * can't transition to pending_close/closing (unassign/offline)<a name="line.354"></a>
+<span class="sourceLineNo">355</span>   */<a name="line.355"></a>
+<span class="sourceLineNo">356</span>  public static boolean isUnassignable(State state) {<a name="line.356"></a>
+<span class="sourceLineNo">357</span>    return state == State.MERGED || state == State.SPLIT || state == State.OFFLINE<a name="line.357"></a>
+<span class="sourceLineNo">358</span>      || state == State.SPLITTING_NEW || state == State.MERGING_NEW;<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>  @Override<a name="line.361"></a>
+<span class="sourceLineNo">362</span>  public String toString() {<a name="line.362"></a>
+<span class="sourceLineNo">363</span>    return "{" + hri.getShortNameToLog()<a name="line.363"></a>
+<span class="sourceLineNo">364</span>      + " state=" + state<a name="line.364"></a>
+<span class="sourceLineNo">365</span>      + ", ts=" + stamp<a name="line.365"></a>
+<span class="sourceLineNo">366</span>      + ", server=" + serverName + "}";<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  }<a name="line.367"></a>
+<span class="sourceLineNo">368</span><a name="line.368"></a>
+<span class="sourceLineNo">369</span>  /**<a name="line.369"></a>
+<span class="sourceLineNo">370</span>   * A slower (but more easy-to-read) stringification<a name="line.370"></a>
+<span class="sourceLineNo">371</span>   */<a name="line.371"></a>
+<span class="sourceLineNo">372</span>  public String toDescriptiveString() {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>    long relTime = System.currentTimeMillis() - stamp;<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    return hri.getRegionNameAsString()<a name="line.374"></a>
+<span class="sourceLineNo">375</span>      + " state=" + state<a name="line.375"></a>
+<span class="sourceLineNo">376</span>      + ", ts=" + new Date(stamp) + " (" + (relTime/1000) + "s ago)"<a name="line.376"></a>
+<span class="sourceLineNo">377</span>      + ", server=" + serverName;<a name="line.377"></a>
+<span class="sourceLineNo">378</span>  }<a name="line.378"></a>
+<span class="sourceLineNo">379</span><a name="line.379"></a>
+<span class="sourceLineNo">380</span>  /**<a name="line.380"></a>
+<span class="sourceLineNo">381</span>   * Convert a RegionState to an HBaseProtos.RegionState<a name="line.381"></a>
+<span class="sourceLineNo">382</span>   *<a name="line.382"></a>
+<span class="sourceLineNo">383</span>   * @return the converted HBaseProtos.RegionState<a name="line.383"></a>
+<span class="sourceLineNo">384</span>   */<a name="line.384"></a>
+<span class="sourceLineNo">385</span>  public ClusterStatusProtos.RegionState convert() {<a name="line.385"></a>
+<span class="sourceLineNo">386</span>    ClusterStatusProtos.RegionState.Builder regionState = ClusterStatusProtos.RegionState.newBuilder();<a name="line.386"></a>
+<span class="sourceLineNo">387</span>    regionState.setRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    regionState.setState(state.convert());<a name="line.388"></a>
+<span class="sourceLineNo">389</span>    regionState.setStamp(getStamp());<a name="line.389"></a>
+<span class="sourceLineNo">390</span>    return regionState.build();<a name="line.390"></a>
+<span class="sourceLineNo">391</span>  }<a name="line.391"></a>
+<span class="sourceLineNo">392</span><a name="line.392"></a>
+<span class="sourceLineNo">393</span>  /**<a name="line.393"></a>
+<span class="sourceLineNo">394</span>   * Convert a protobuf HBaseProtos.RegionState to a RegionState<a name="line.394"></a>
+<span class="sourceLineNo">395</span>   *<a name="line.395"></a>
+<span class="sourceLineNo">396</span>   * @return the RegionState<a name="line.396"></a>
+<span class="sourceLineNo">397</span>   */<a name="line.397"></a>
+<span class="sourceLineNo">398</span>  public static RegionState convert(ClusterStatusProtos.RegionState proto) {<a name="line.398"></a>
+<span class="sourceLineNo">399</span>    return new RegionState(ProtobufUtil.toRegionInfo(proto.getRegionInfo()),<a name="line.399"></a>
+<span class="sourceLineNo">400</span>      State.convert(proto.getState()), proto.getStamp(), null);<a name="line.400"></a>
+<span class="sourceLineNo">401</span>  }<a name="line.401"></a>
+<span class="sourceLineNo">402</span><a name="line.402"></a>
+<span class="sourceLineNo">403</span>  /**<a name="line.403"></a>
+<span class="sourceLineNo">404</span>   * Check if two states are the same, except timestamp<a name="line.404"></a>
+<span class="sourceLineNo">405</span>   */<a name="line.405"></a>
+<span class="sourceLineNo">406</span>  @Override<a name="line.406"></a>
+<span class="sourceLineNo">407</span>  public boolean equals(Object obj) {<a name="line.407"></a>
+<span class="sourceLineNo">408</span>    if (this == obj) return true;<a name="line.408"></a>
+<span class="sourceLineNo">409</span>    if (obj == null || getClass() != obj.getClass()) {<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      return false;<a name="line.410"></a>
+<span class="sourceLineNo">411</span>    }<a name="line.411"></a>
+<span class="sourceLineNo">412</span>    RegionState tmp = (RegionState)obj;<a name="line.412"></a>
+<span class="sourceLineNo">413</span><a name="line.413"></a>
+<span class="sourceLineNo">414</span>    return RegionInfo.COMPARATOR.compare(tmp.hri, hri) == 0 &amp;&amp; tmp.state == state<a name="line.414"></a>
+<span class="sourceLineNo">415</span>      &amp;&amp; ((serverName != null &amp;&amp; serverName.equals(tmp.serverName))<a name="line.415"></a>
+<span class="sourceLineNo">416</span>        || (tmp.serverName == null &amp;&amp; serverName == null));<a name="line.416"></a>
+<span class="sourceLineNo">417</span>  }<a name="line.417"></a>
+<span class="sourceLineNo">418</span><a name="line.418"></a>
+<span class="sourceLineNo">419</span>  /**<a name="line.419"></a>
+<span class="sourceLineNo">420</span>   * Don't count timestamp in hash code calculation<a name="line.420"></a>
+<span class="sourceLineNo">421</span>   */<a name="line.421"></a>
+<span class="sourceLineNo">422</span>  @Override<a name="line.422"></a>
+<span class="sourceLineNo">423</span>  public int hashCode() {<a name="line.423"></a>
+<span class="sourceLineNo">424</span>    return (serverName != null ? serverName.hashCode() * 11 : 0)<a name="line.424"></a>
+<span class="sourceLineNo">425</span>      + hri.hashCode() + 5 * state.ordinal();<a name="line.425"></a>
+<span class="sourceLineNo">426</span>  }<a name="line.426"></a>
+<span class="sourceLineNo">427</span>}<a name="line.427"></a>
 
 
 


Mime
View raw message