http://git-wip-us.apache.org/repos/asf/hbase-site/blob/aa3fb87f/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.AssignmentProcedureEvent.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.AssignmentProcedureEvent.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.AssignmentProcedureEvent.html index 550d833..d664e99 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.AssignmentProcedureEvent.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.AssignmentProcedureEvent.html @@ -154,171 +154,173 @@ <span class="sourceLineNo">146</span> }<a name="line.146"></a> <span class="sourceLineNo">147</span> }<a name="line.147"></a> <span class="sourceLineNo">148</span><a name="line.148"></a> -<span class="sourceLineNo">149</span> public boolean isInState(final State... expected) {<a name="line.149"></a> -<span class="sourceLineNo">150</span> if (expected != null && expected.length > 0) {<a name="line.150"></a> -<span class="sourceLineNo">151</span> boolean expectedState = false;<a name="line.151"></a> -<span class="sourceLineNo">152</span> for (int i = 0; i < expected.length; ++i) {<a name="line.152"></a> -<span class="sourceLineNo">153</span> expectedState |= (getState() == expected[i]);<a name="line.153"></a> -<span class="sourceLineNo">154</span> }<a name="line.154"></a> -<span class="sourceLineNo">155</span> return expectedState;<a name="line.155"></a> -<span class="sourceLineNo">156</span> }<a name="line.156"></a> -<span class="sourceLineNo">157</span> return true;<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 boolean isStuck() {<a name="line.160"></a> -<span class="sourceLineNo">161</span> return isInState(State.FAILED_OPEN) && getProcedure() != null;<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> public boolean isInTransition() {<a name="line.164"></a> -<span class="sourceLineNo">165</span> return getProcedure() != null;<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> public long getLastUpdate() {<a name="line.168"></a> -<span class="sourceLineNo">169</span> TransitRegionStateProcedure proc = this.procedure;<a name="line.169"></a> -<span class="sourceLineNo">170</span> return proc != null ? proc.getLastUpdate() : lastUpdate;<a name="line.170"></a> -<span class="sourceLineNo">171</span> }<a name="line.171"></a> -<span class="sourceLineNo">172</span><a name="line.172"></a> -<span class="sourceLineNo">173</span> public void setLastHost(final ServerName serverName) {<a name="line.173"></a> -<span class="sourceLineNo">174</span> this.lastHost = serverName;<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> public void setOpenSeqNum(final long seqId) {<a name="line.177"></a> -<span class="sourceLineNo">178</span> this.openSeqNum = seqId;<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 ServerName setRegionLocation(final ServerName serverName) {<a name="line.181"></a> -<span class="sourceLineNo">182</span> ServerName lastRegionLocation = this.regionLocation;<a name="line.182"></a> -<span class="sourceLineNo">183</span> if (LOG.isTraceEnabled() && serverName == null) {<a name="line.183"></a> -<span class="sourceLineNo">184</span> LOG.trace("Tracking when we are set to null " + this, new Throwable("TRACE"));<a name="line.184"></a> -<span class="sourceLineNo">185</span> }<a name="line.185"></a> -<span class="sourceLineNo">186</span> this.regionLocation = serverName;<a name="line.186"></a> -<span class="sourceLineNo">187</span> this.lastUpdate = EnvironmentEdgeManager.currentTime();<a name="line.187"></a> -<span class="sourceLineNo">188</span> return lastRegionLocation;<a name="line.188"></a> -<span class="sourceLineNo">189</span> }<a name="line.189"></a> -<span class="sourceLineNo">190</span><a name="line.190"></a> -<span class="sourceLineNo">191</span> public void setProcedure(TransitRegionStateProcedure proc) {<a name="line.191"></a> -<span class="sourceLineNo">192</span> assert this.procedure == null;<a name="line.192"></a> -<span class="sourceLineNo">193</span> this.procedure = proc;<a name="line.193"></a> -<span class="sourceLineNo">194</span> ritMap.put(regionInfo, this);<a name="line.194"></a> -<span class="sourceLineNo">195</span> }<a name="line.195"></a> -<span class="sourceLineNo">196</span><a name="line.196"></a> -<span class="sourceLineNo">197</span> public void unsetProcedure(TransitRegionStateProcedure proc) {<a name="line.197"></a> -<span class="sourceLineNo">198</span> assert this.procedure == proc;<a name="line.198"></a> -<span class="sourceLineNo">199</span> this.procedure = null;<a name="line.199"></a> -<span class="sourceLineNo">200</span> ritMap.remove(regionInfo, this);<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 TransitRegionStateProcedure getProcedure() {<a name="line.203"></a> -<span class="sourceLineNo">204</span> return procedure;<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 ProcedureEvent<?> getProcedureEvent() {<a name="line.207"></a> -<span class="sourceLineNo">208</span> return event;<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 RegionInfo getRegionInfo() {<a name="line.211"></a> -<span class="sourceLineNo">212</span> return regionInfo;<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> public TableName getTable() {<a name="line.215"></a> -<span class="sourceLineNo">216</span> return getRegionInfo().getTable();<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span><a name="line.218"></a> -<span class="sourceLineNo">219</span> public boolean isSystemTable() {<a name="line.219"></a> -<span class="sourceLineNo">220</span> return getTable().isSystemTable();<a name="line.220"></a> -<span class="sourceLineNo">221</span> }<a name="line.221"></a> -<span class="sourceLineNo">222</span><a name="line.222"></a> -<span class="sourceLineNo">223</span> public ServerName getLastHost() {<a name="line.223"></a> -<span class="sourceLineNo">224</span> return lastHost;<a name="line.224"></a> -<span class="sourceLineNo">225</span> }<a name="line.225"></a> -<span class="sourceLineNo">226</span><a name="line.226"></a> -<span class="sourceLineNo">227</span> public ServerName getRegionLocation() {<a name="line.227"></a> -<span class="sourceLineNo">228</span> return regionLocation;<a name="line.228"></a> -<span class="sourceLineNo">229</span> }<a name="line.229"></a> -<span class="sourceLineNo">230</span><a name="line.230"></a> -<span class="sourceLineNo">231</span> public State getState() {<a name="line.231"></a> -<span class="sourceLineNo">232</span> return state;<a name="line.232"></a> -<span class="sourceLineNo">233</span> }<a name="line.233"></a> -<span class="sourceLineNo">234</span><a name="line.234"></a> -<span class="sourceLineNo">235</span> public long getOpenSeqNum() {<a name="line.235"></a> -<span class="sourceLineNo">236</span> return openSeqNum;<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> public int getFormatVersion() {<a name="line.239"></a> -<span class="sourceLineNo">240</span> // we don't have any format for now<a name="line.240"></a> -<span class="sourceLineNo">241</span> // it should probably be in regionInfo.getFormatVersion()<a name="line.241"></a> -<span class="sourceLineNo">242</span> return 0;<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 RegionState toRegionState() {<a name="line.245"></a> -<span class="sourceLineNo">246</span> return new RegionState(getRegionInfo(), getState(), getLastUpdate(), getRegionLocation());<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> @Override<a name="line.249"></a> -<span class="sourceLineNo">250</span> public int compareTo(final RegionStateNode other) {<a name="line.250"></a> -<span class="sourceLineNo">251</span> // NOTE: RegionInfo sort by table first, so we are relying on that.<a name="line.251"></a> -<span class="sourceLineNo">252</span> // we have a TestRegionState#testOrderedByTable() that check for that.<a name="line.252"></a> -<span class="sourceLineNo">253</span> return RegionInfo.COMPARATOR.compare(getRegionInfo(), other.getRegionInfo());<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> @Override<a name="line.256"></a> -<span class="sourceLineNo">257</span> public int hashCode() {<a name="line.257"></a> -<span class="sourceLineNo">258</span> return getRegionInfo().hashCode();<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> @Override<a name="line.261"></a> -<span class="sourceLineNo">262</span> public boolean equals(final Object other) {<a name="line.262"></a> -<span class="sourceLineNo">263</span> if (this == other) {<a name="line.263"></a> -<span class="sourceLineNo">264</span> return true;<a name="line.264"></a> -<span class="sourceLineNo">265</span> }<a name="line.265"></a> -<span class="sourceLineNo">266</span> if (!(other instanceof RegionStateNode)) {<a name="line.266"></a> -<span class="sourceLineNo">267</span> return false;<a name="line.267"></a> -<span class="sourceLineNo">268</span> }<a name="line.268"></a> -<span class="sourceLineNo">269</span> return compareTo((RegionStateNode) other) == 0;<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> @Override<a name="line.272"></a> -<span class="sourceLineNo">273</span> public String toString() {<a name="line.273"></a> -<span class="sourceLineNo">274</span> return toDescriptiveString();<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 String toShortString() {<a name="line.277"></a> -<span class="sourceLineNo">278</span> // rit= is the current Region-In-Transition State -- see State enum.<a name="line.278"></a> -<span class="sourceLineNo">279</span> return String.format("rit=%s, location=%s", getState(), getRegionLocation());<a name="line.279"></a> -<span class="sourceLineNo">280</span> }<a name="line.280"></a> -<span class="sourceLineNo">281</span><a name="line.281"></a> -<span class="sourceLineNo">282</span> public String toDescriptiveString() {<a name="line.282"></a> -<span class="sourceLineNo">283</span> return String.format("%s, table=%s, region=%s", toShortString(), getTable(),<a name="line.283"></a> -<span class="sourceLineNo">284</span> getRegionInfo().getEncodedName());<a name="line.284"></a> -<span class="sourceLineNo">285</span> }<a name="line.285"></a> -<span class="sourceLineNo">286</span><a name="line.286"></a> -<span class="sourceLineNo">287</span> public void checkOnline() throws DoNotRetryRegionException {<a name="line.287"></a> -<span class="sourceLineNo">288</span> RegionInfo ri = getRegionInfo();<a name="line.288"></a> -<span class="sourceLineNo">289</span> State s = state;<a name="line.289"></a> -<span class="sourceLineNo">290</span> if (s != State.OPEN) {<a name="line.290"></a> -<span class="sourceLineNo">291</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " is no OPEN; state=" + s);<a name="line.291"></a> -<span class="sourceLineNo">292</span> }<a name="line.292"></a> -<span class="sourceLineNo">293</span> if (ri.isSplitParent()) {<a name="line.293"></a> -<span class="sourceLineNo">294</span> throw new DoNotRetryRegionException(<a name="line.294"></a> -<span class="sourceLineNo">295</span> ri.getEncodedName() + " is not online (splitParent=true)");<a name="line.295"></a> -<span class="sourceLineNo">296</span> }<a name="line.296"></a> -<span class="sourceLineNo">297</span> if (ri.isSplit()) {<a name="line.297"></a> -<span class="sourceLineNo">298</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " has split=true");<a name="line.298"></a> -<span class="sourceLineNo">299</span> }<a name="line.299"></a> -<span class="sourceLineNo">300</span> if (ri.isOffline()) {<a name="line.300"></a> -<span class="sourceLineNo">301</span> // RegionOfflineException is not instance of DNRIOE so wrap it.<a name="line.301"></a> -<span class="sourceLineNo">302</span> throw new DoNotRetryRegionException(new RegionOfflineException(ri.getEncodedName()));<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><a name="line.305"></a> -<span class="sourceLineNo">306</span> public void lock() {<a name="line.306"></a> -<span class="sourceLineNo">307</span> lock.lock();<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> public void unlock() {<a name="line.310"></a> -<span class="sourceLineNo">311</span> lock.unlock();<a name="line.311"></a> -<span class="sourceLineNo">312</span> }<a name="line.312"></a> -<span class="sourceLineNo">313</span>}<a name="line.313"></a> +<span class="sourceLineNo">149</span> /**<a name="line.149"></a> +<span class="sourceLineNo">150</span> * Notice that, we will return true if {@code expected} is empty.<a name="line.150"></a> +<span class="sourceLineNo">151</span> * <p/><a name="line.151"></a> +<span class="sourceLineNo">152</span> * This is a bit strange but we need this logic, for example, we can change the state to OPENING<a name="line.152"></a> +<span class="sourceLineNo">153</span> * from any state, as in SCP we will not change the state to CLOSED before opening the region.<a name="line.153"></a> +<span class="sourceLineNo">154</span> */<a name="line.154"></a> +<span class="sourceLineNo">155</span> public boolean isInState(State... expected) {<a name="line.155"></a> +<span class="sourceLineNo">156</span> if (expected.length == 0) {<a name="line.156"></a> +<span class="sourceLineNo">157</span> return true;<a name="line.157"></a> +<span class="sourceLineNo">158</span> }<a name="line.158"></a> +<span class="sourceLineNo">159</span> return getState().matches(expected);<a name="line.159"></a> +<span class="sourceLineNo">160</span> }<a name="line.160"></a> +<span class="sourceLineNo">161</span><a name="line.161"></a> +<span class="sourceLineNo">162</span> public boolean isStuck() {<a name="line.162"></a> +<span class="sourceLineNo">163</span> return isInState(State.FAILED_OPEN) && getProcedure() != null;<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> public boolean isInTransition() {<a name="line.166"></a> +<span class="sourceLineNo">167</span> return getProcedure() != null;<a name="line.167"></a> +<span class="sourceLineNo">168</span> }<a name="line.168"></a> +<span class="sourceLineNo">169</span><a name="line.169"></a> +<span class="sourceLineNo">170</span> public long getLastUpdate() {<a name="line.170"></a> +<span class="sourceLineNo">171</span> TransitRegionStateProcedure proc = this.procedure;<a name="line.171"></a> +<span class="sourceLineNo">172</span> return proc != null ? proc.getLastUpdate() : lastUpdate;<a name="line.172"></a> +<span class="sourceLineNo">173</span> }<a name="line.173"></a> +<span class="sourceLineNo">174</span><a name="line.174"></a> +<span class="sourceLineNo">175</span> public void setLastHost(final ServerName serverName) {<a name="line.175"></a> +<span class="sourceLineNo">176</span> this.lastHost = serverName;<a name="line.176"></a> +<span class="sourceLineNo">177</span> }<a name="line.177"></a> +<span class="sourceLineNo">178</span><a name="line.178"></a> +<span class="sourceLineNo">179</span> public void setOpenSeqNum(final long seqId) {<a name="line.179"></a> +<span class="sourceLineNo">180</span> this.openSeqNum = seqId;<a name="line.180"></a> +<span class="sourceLineNo">181</span> }<a name="line.181"></a> +<span class="sourceLineNo">182</span><a name="line.182"></a> +<span class="sourceLineNo">183</span> public ServerName setRegionLocation(final ServerName serverName) {<a name="line.183"></a> +<span class="sourceLineNo">184</span> ServerName lastRegionLocation = this.regionLocation;<a name="line.184"></a> +<span class="sourceLineNo">185</span> if (LOG.isTraceEnabled() && serverName == null) {<a name="line.185"></a> +<span class="sourceLineNo">186</span> LOG.trace("Tracking when we are set to null " + this, new Throwable("TRACE"));<a name="line.186"></a> +<span class="sourceLineNo">187</span> }<a name="line.187"></a> +<span class="sourceLineNo">188</span> this.regionLocation = serverName;<a name="line.188"></a> +<span class="sourceLineNo">189</span> this.lastUpdate = EnvironmentEdgeManager.currentTime();<a name="line.189"></a> +<span class="sourceLineNo">190</span> return lastRegionLocation;<a name="line.190"></a> +<span class="sourceLineNo">191</span> }<a name="line.191"></a> +<span class="sourceLineNo">192</span><a name="line.192"></a> +<span class="sourceLineNo">193</span> public void setProcedure(TransitRegionStateProcedure proc) {<a name="line.193"></a> +<span class="sourceLineNo">194</span> assert this.procedure == null;<a name="line.194"></a> +<span class="sourceLineNo">195</span> this.procedure = proc;<a name="line.195"></a> +<span class="sourceLineNo">196</span> ritMap.put(regionInfo, this);<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 void unsetProcedure(TransitRegionStateProcedure proc) {<a name="line.199"></a> +<span class="sourceLineNo">200</span> assert this.procedure == proc;<a name="line.200"></a> +<span class="sourceLineNo">201</span> this.procedure = null;<a name="line.201"></a> +<span class="sourceLineNo">202</span> ritMap.remove(regionInfo, this);<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span><a name="line.204"></a> +<span class="sourceLineNo">205</span> public TransitRegionStateProcedure getProcedure() {<a name="line.205"></a> +<span class="sourceLineNo">206</span> return procedure;<a name="line.206"></a> +<span class="sourceLineNo">207</span> }<a name="line.207"></a> +<span class="sourceLineNo">208</span><a name="line.208"></a> +<span class="sourceLineNo">209</span> public ProcedureEvent<?> getProcedureEvent() {<a name="line.209"></a> +<span class="sourceLineNo">210</span> return event;<a name="line.210"></a> +<span class="sourceLineNo">211</span> }<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> public RegionInfo getRegionInfo() {<a name="line.213"></a> +<span class="sourceLineNo">214</span> return regionInfo;<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> public TableName getTable() {<a name="line.217"></a> +<span class="sourceLineNo">218</span> return getRegionInfo().getTable();<a name="line.218"></a> +<span class="sourceLineNo">219</span> }<a name="line.219"></a> +<span class="sourceLineNo">220</span><a name="line.220"></a> +<span class="sourceLineNo">221</span> public boolean isSystemTable() {<a name="line.221"></a> +<span class="sourceLineNo">222</span> return getTable().isSystemTable();<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 ServerName getLastHost() {<a name="line.225"></a> +<span class="sourceLineNo">226</span> return lastHost;<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 ServerName getRegionLocation() {<a name="line.229"></a> +<span class="sourceLineNo">230</span> return regionLocation;<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 State getState() {<a name="line.233"></a> +<span class="sourceLineNo">234</span> return state;<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 long getOpenSeqNum() {<a name="line.237"></a> +<span class="sourceLineNo">238</span> return openSeqNum;<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 int getFormatVersion() {<a name="line.241"></a> +<span class="sourceLineNo">242</span> // we don't have any format for now<a name="line.242"></a> +<span class="sourceLineNo">243</span> // it should probably be in regionInfo.getFormatVersion()<a name="line.243"></a> +<span class="sourceLineNo">244</span> return 0;<a name="line.244"></a> +<span class="sourceLineNo">245</span> }<a name="line.245"></a> +<span class="sourceLineNo">246</span><a name="line.246"></a> +<span class="sourceLineNo">247</span> public RegionState toRegionState() {<a name="line.247"></a> +<span class="sourceLineNo">248</span> return new RegionState(getRegionInfo(), getState(), getLastUpdate(), getRegionLocation());<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> @Override<a name="line.251"></a> +<span class="sourceLineNo">252</span> public int compareTo(final RegionStateNode other) {<a name="line.252"></a> +<span class="sourceLineNo">253</span> // NOTE: RegionInfo sort by table first, so we are relying on that.<a name="line.253"></a> +<span class="sourceLineNo">254</span> // we have a TestRegionState#testOrderedByTable() that check for that.<a name="line.254"></a> +<span class="sourceLineNo">255</span> return RegionInfo.COMPARATOR.compare(getRegionInfo(), other.getRegionInfo());<a name="line.255"></a> +<span class="sourceLineNo">256</span> }<a name="line.256"></a> +<span class="sourceLineNo">257</span><a name="line.257"></a> +<span class="sourceLineNo">258</span> @Override<a name="line.258"></a> +<span class="sourceLineNo">259</span> public int hashCode() {<a name="line.259"></a> +<span class="sourceLineNo">260</span> return getRegionInfo().hashCode();<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> @Override<a name="line.263"></a> +<span class="sourceLineNo">264</span> public boolean equals(final Object other) {<a name="line.264"></a> +<span class="sourceLineNo">265</span> if (this == other) {<a name="line.265"></a> +<span class="sourceLineNo">266</span> return true;<a name="line.266"></a> +<span class="sourceLineNo">267</span> }<a name="line.267"></a> +<span class="sourceLineNo">268</span> if (!(other instanceof RegionStateNode)) {<a name="line.268"></a> +<span class="sourceLineNo">269</span> return false;<a name="line.269"></a> +<span class="sourceLineNo">270</span> }<a name="line.270"></a> +<span class="sourceLineNo">271</span> return compareTo((RegionStateNode) other) == 0;<a name="line.271"></a> +<span class="sourceLineNo">272</span> }<a name="line.272"></a> +<span class="sourceLineNo">273</span><a name="line.273"></a> +<span class="sourceLineNo">274</span> @Override<a name="line.274"></a> +<span class="sourceLineNo">275</span> public String toString() {<a name="line.275"></a> +<span class="sourceLineNo">276</span> return toDescriptiveString();<a name="line.276"></a> +<span class="sourceLineNo">277</span> }<a name="line.277"></a> +<span class="sourceLineNo">278</span><a name="line.278"></a> +<span class="sourceLineNo">279</span> public String toShortString() {<a name="line.279"></a> +<span class="sourceLineNo">280</span> // rit= is the current Region-In-Transition State -- see State enum.<a name="line.280"></a> +<span class="sourceLineNo">281</span> return String.format("rit=%s, location=%s", getState(), getRegionLocation());<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 String toDescriptiveString() {<a name="line.284"></a> +<span class="sourceLineNo">285</span> return String.format("%s, table=%s, region=%s", toShortString(), getTable(),<a name="line.285"></a> +<span class="sourceLineNo">286</span> getRegionInfo().getEncodedName());<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 void checkOnline() throws DoNotRetryRegionException {<a name="line.289"></a> +<span class="sourceLineNo">290</span> RegionInfo ri = getRegionInfo();<a name="line.290"></a> +<span class="sourceLineNo">291</span> State s = state;<a name="line.291"></a> +<span class="sourceLineNo">292</span> if (s != State.OPEN) {<a name="line.292"></a> +<span class="sourceLineNo">293</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " is no OPEN; state=" + s);<a name="line.293"></a> +<span class="sourceLineNo">294</span> }<a name="line.294"></a> +<span class="sourceLineNo">295</span> if (ri.isSplitParent()) {<a name="line.295"></a> +<span class="sourceLineNo">296</span> throw new DoNotRetryRegionException(<a name="line.296"></a> +<span class="sourceLineNo">297</span> ri.getEncodedName() + " is not online (splitParent=true)");<a name="line.297"></a> +<span class="sourceLineNo">298</span> }<a name="line.298"></a> +<span class="sourceLineNo">299</span> if (ri.isSplit()) {<a name="line.299"></a> +<span class="sourceLineNo">300</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " has split=true");<a name="line.300"></a> +<span class="sourceLineNo">301</span> }<a name="line.301"></a> +<span class="sourceLineNo">302</span> if (ri.isOffline()) {<a name="line.302"></a> +<span class="sourceLineNo">303</span> // RegionOfflineException is not instance of DNRIOE so wrap it.<a name="line.303"></a> +<span class="sourceLineNo">304</span> throw new DoNotRetryRegionException(new RegionOfflineException(ri.getEncodedName()));<a name="line.304"></a> +<span class="sourceLineNo">305</span> }<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 void lock() {<a name="line.308"></a> +<span class="sourceLineNo">309</span> lock.lock();<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 void unlock() {<a name="line.312"></a> +<span class="sourceLineNo">313</span> lock.unlock();<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>
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/aa3fb87f/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.html index 550d833..d664e99 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/assignment/RegionStateNode.html @@ -154,171 +154,173 @@ <span class="sourceLineNo">146</span> }<a name="line.146"></a> <span class="sourceLineNo">147</span> }<a name="line.147"></a> <span class="sourceLineNo">148</span><a name="line.148"></a> -<span class="sourceLineNo">149</span> public boolean isInState(final State... expected) {<a name="line.149"></a> -<span class="sourceLineNo">150</span> if (expected != null && expected.length > 0) {<a name="line.150"></a> -<span class="sourceLineNo">151</span> boolean expectedState = false;<a name="line.151"></a> -<span class="sourceLineNo">152</span> for (int i = 0; i < expected.length; ++i) {<a name="line.152"></a> -<span class="sourceLineNo">153</span> expectedState |= (getState() == expected[i]);<a name="line.153"></a> -<span class="sourceLineNo">154</span> }<a name="line.154"></a> -<span class="sourceLineNo">155</span> return expectedState;<a name="line.155"></a> -<span class="sourceLineNo">156</span> }<a name="line.156"></a> -<span class="sourceLineNo">157</span> return true;<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 boolean isStuck() {<a name="line.160"></a> -<span class="sourceLineNo">161</span> return isInState(State.FAILED_OPEN) && getProcedure() != null;<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> public boolean isInTransition() {<a name="line.164"></a> -<span class="sourceLineNo">165</span> return getProcedure() != null;<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> public long getLastUpdate() {<a name="line.168"></a> -<span class="sourceLineNo">169</span> TransitRegionStateProcedure proc = this.procedure;<a name="line.169"></a> -<span class="sourceLineNo">170</span> return proc != null ? proc.getLastUpdate() : lastUpdate;<a name="line.170"></a> -<span class="sourceLineNo">171</span> }<a name="line.171"></a> -<span class="sourceLineNo">172</span><a name="line.172"></a> -<span class="sourceLineNo">173</span> public void setLastHost(final ServerName serverName) {<a name="line.173"></a> -<span class="sourceLineNo">174</span> this.lastHost = serverName;<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> public void setOpenSeqNum(final long seqId) {<a name="line.177"></a> -<span class="sourceLineNo">178</span> this.openSeqNum = seqId;<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 ServerName setRegionLocation(final ServerName serverName) {<a name="line.181"></a> -<span class="sourceLineNo">182</span> ServerName lastRegionLocation = this.regionLocation;<a name="line.182"></a> -<span class="sourceLineNo">183</span> if (LOG.isTraceEnabled() && serverName == null) {<a name="line.183"></a> -<span class="sourceLineNo">184</span> LOG.trace("Tracking when we are set to null " + this, new Throwable("TRACE"));<a name="line.184"></a> -<span class="sourceLineNo">185</span> }<a name="line.185"></a> -<span class="sourceLineNo">186</span> this.regionLocation = serverName;<a name="line.186"></a> -<span class="sourceLineNo">187</span> this.lastUpdate = EnvironmentEdgeManager.currentTime();<a name="line.187"></a> -<span class="sourceLineNo">188</span> return lastRegionLocation;<a name="line.188"></a> -<span class="sourceLineNo">189</span> }<a name="line.189"></a> -<span class="sourceLineNo">190</span><a name="line.190"></a> -<span class="sourceLineNo">191</span> public void setProcedure(TransitRegionStateProcedure proc) {<a name="line.191"></a> -<span class="sourceLineNo">192</span> assert this.procedure == null;<a name="line.192"></a> -<span class="sourceLineNo">193</span> this.procedure = proc;<a name="line.193"></a> -<span class="sourceLineNo">194</span> ritMap.put(regionInfo, this);<a name="line.194"></a> -<span class="sourceLineNo">195</span> }<a name="line.195"></a> -<span class="sourceLineNo">196</span><a name="line.196"></a> -<span class="sourceLineNo">197</span> public void unsetProcedure(TransitRegionStateProcedure proc) {<a name="line.197"></a> -<span class="sourceLineNo">198</span> assert this.procedure == proc;<a name="line.198"></a> -<span class="sourceLineNo">199</span> this.procedure = null;<a name="line.199"></a> -<span class="sourceLineNo">200</span> ritMap.remove(regionInfo, this);<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 TransitRegionStateProcedure getProcedure() {<a name="line.203"></a> -<span class="sourceLineNo">204</span> return procedure;<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 ProcedureEvent<?> getProcedureEvent() {<a name="line.207"></a> -<span class="sourceLineNo">208</span> return event;<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 RegionInfo getRegionInfo() {<a name="line.211"></a> -<span class="sourceLineNo">212</span> return regionInfo;<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> public TableName getTable() {<a name="line.215"></a> -<span class="sourceLineNo">216</span> return getRegionInfo().getTable();<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span><a name="line.218"></a> -<span class="sourceLineNo">219</span> public boolean isSystemTable() {<a name="line.219"></a> -<span class="sourceLineNo">220</span> return getTable().isSystemTable();<a name="line.220"></a> -<span class="sourceLineNo">221</span> }<a name="line.221"></a> -<span class="sourceLineNo">222</span><a name="line.222"></a> -<span class="sourceLineNo">223</span> public ServerName getLastHost() {<a name="line.223"></a> -<span class="sourceLineNo">224</span> return lastHost;<a name="line.224"></a> -<span class="sourceLineNo">225</span> }<a name="line.225"></a> -<span class="sourceLineNo">226</span><a name="line.226"></a> -<span class="sourceLineNo">227</span> public ServerName getRegionLocation() {<a name="line.227"></a> -<span class="sourceLineNo">228</span> return regionLocation;<a name="line.228"></a> -<span class="sourceLineNo">229</span> }<a name="line.229"></a> -<span class="sourceLineNo">230</span><a name="line.230"></a> -<span class="sourceLineNo">231</span> public State getState() {<a name="line.231"></a> -<span class="sourceLineNo">232</span> return state;<a name="line.232"></a> -<span class="sourceLineNo">233</span> }<a name="line.233"></a> -<span class="sourceLineNo">234</span><a name="line.234"></a> -<span class="sourceLineNo">235</span> public long getOpenSeqNum() {<a name="line.235"></a> -<span class="sourceLineNo">236</span> return openSeqNum;<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> public int getFormatVersion() {<a name="line.239"></a> -<span class="sourceLineNo">240</span> // we don't have any format for now<a name="line.240"></a> -<span class="sourceLineNo">241</span> // it should probably be in regionInfo.getFormatVersion()<a name="line.241"></a> -<span class="sourceLineNo">242</span> return 0;<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 RegionState toRegionState() {<a name="line.245"></a> -<span class="sourceLineNo">246</span> return new RegionState(getRegionInfo(), getState(), getLastUpdate(), getRegionLocation());<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> @Override<a name="line.249"></a> -<span class="sourceLineNo">250</span> public int compareTo(final RegionStateNode other) {<a name="line.250"></a> -<span class="sourceLineNo">251</span> // NOTE: RegionInfo sort by table first, so we are relying on that.<a name="line.251"></a> -<span class="sourceLineNo">252</span> // we have a TestRegionState#testOrderedByTable() that check for that.<a name="line.252"></a> -<span class="sourceLineNo">253</span> return RegionInfo.COMPARATOR.compare(getRegionInfo(), other.getRegionInfo());<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> @Override<a name="line.256"></a> -<span class="sourceLineNo">257</span> public int hashCode() {<a name="line.257"></a> -<span class="sourceLineNo">258</span> return getRegionInfo().hashCode();<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> @Override<a name="line.261"></a> -<span class="sourceLineNo">262</span> public boolean equals(final Object other) {<a name="line.262"></a> -<span class="sourceLineNo">263</span> if (this == other) {<a name="line.263"></a> -<span class="sourceLineNo">264</span> return true;<a name="line.264"></a> -<span class="sourceLineNo">265</span> }<a name="line.265"></a> -<span class="sourceLineNo">266</span> if (!(other instanceof RegionStateNode)) {<a name="line.266"></a> -<span class="sourceLineNo">267</span> return false;<a name="line.267"></a> -<span class="sourceLineNo">268</span> }<a name="line.268"></a> -<span class="sourceLineNo">269</span> return compareTo((RegionStateNode) other) == 0;<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> @Override<a name="line.272"></a> -<span class="sourceLineNo">273</span> public String toString() {<a name="line.273"></a> -<span class="sourceLineNo">274</span> return toDescriptiveString();<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 String toShortString() {<a name="line.277"></a> -<span class="sourceLineNo">278</span> // rit= is the current Region-In-Transition State -- see State enum.<a name="line.278"></a> -<span class="sourceLineNo">279</span> return String.format("rit=%s, location=%s", getState(), getRegionLocation());<a name="line.279"></a> -<span class="sourceLineNo">280</span> }<a name="line.280"></a> -<span class="sourceLineNo">281</span><a name="line.281"></a> -<span class="sourceLineNo">282</span> public String toDescriptiveString() {<a name="line.282"></a> -<span class="sourceLineNo">283</span> return String.format("%s, table=%s, region=%s", toShortString(), getTable(),<a name="line.283"></a> -<span class="sourceLineNo">284</span> getRegionInfo().getEncodedName());<a name="line.284"></a> -<span class="sourceLineNo">285</span> }<a name="line.285"></a> -<span class="sourceLineNo">286</span><a name="line.286"></a> -<span class="sourceLineNo">287</span> public void checkOnline() throws DoNotRetryRegionException {<a name="line.287"></a> -<span class="sourceLineNo">288</span> RegionInfo ri = getRegionInfo();<a name="line.288"></a> -<span class="sourceLineNo">289</span> State s = state;<a name="line.289"></a> -<span class="sourceLineNo">290</span> if (s != State.OPEN) {<a name="line.290"></a> -<span class="sourceLineNo">291</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " is no OPEN; state=" + s);<a name="line.291"></a> -<span class="sourceLineNo">292</span> }<a name="line.292"></a> -<span class="sourceLineNo">293</span> if (ri.isSplitParent()) {<a name="line.293"></a> -<span class="sourceLineNo">294</span> throw new DoNotRetryRegionException(<a name="line.294"></a> -<span class="sourceLineNo">295</span> ri.getEncodedName() + " is not online (splitParent=true)");<a name="line.295"></a> -<span class="sourceLineNo">296</span> }<a name="line.296"></a> -<span class="sourceLineNo">297</span> if (ri.isSplit()) {<a name="line.297"></a> -<span class="sourceLineNo">298</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " has split=true");<a name="line.298"></a> -<span class="sourceLineNo">299</span> }<a name="line.299"></a> -<span class="sourceLineNo">300</span> if (ri.isOffline()) {<a name="line.300"></a> -<span class="sourceLineNo">301</span> // RegionOfflineException is not instance of DNRIOE so wrap it.<a name="line.301"></a> -<span class="sourceLineNo">302</span> throw new DoNotRetryRegionException(new RegionOfflineException(ri.getEncodedName()));<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><a name="line.305"></a> -<span class="sourceLineNo">306</span> public void lock() {<a name="line.306"></a> -<span class="sourceLineNo">307</span> lock.lock();<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> public void unlock() {<a name="line.310"></a> -<span class="sourceLineNo">311</span> lock.unlock();<a name="line.311"></a> -<span class="sourceLineNo">312</span> }<a name="line.312"></a> -<span class="sourceLineNo">313</span>}<a name="line.313"></a> +<span class="sourceLineNo">149</span> /**<a name="line.149"></a> +<span class="sourceLineNo">150</span> * Notice that, we will return true if {@code expected} is empty.<a name="line.150"></a> +<span class="sourceLineNo">151</span> * <p/><a name="line.151"></a> +<span class="sourceLineNo">152</span> * This is a bit strange but we need this logic, for example, we can change the state to OPENING<a name="line.152"></a> +<span class="sourceLineNo">153</span> * from any state, as in SCP we will not change the state to CLOSED before opening the region.<a name="line.153"></a> +<span class="sourceLineNo">154</span> */<a name="line.154"></a> +<span class="sourceLineNo">155</span> public boolean isInState(State... expected) {<a name="line.155"></a> +<span class="sourceLineNo">156</span> if (expected.length == 0) {<a name="line.156"></a> +<span class="sourceLineNo">157</span> return true;<a name="line.157"></a> +<span class="sourceLineNo">158</span> }<a name="line.158"></a> +<span class="sourceLineNo">159</span> return getState().matches(expected);<a name="line.159"></a> +<span class="sourceLineNo">160</span> }<a name="line.160"></a> +<span class="sourceLineNo">161</span><a name="line.161"></a> +<span class="sourceLineNo">162</span> public boolean isStuck() {<a name="line.162"></a> +<span class="sourceLineNo">163</span> return isInState(State.FAILED_OPEN) && getProcedure() != null;<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> public boolean isInTransition() {<a name="line.166"></a> +<span class="sourceLineNo">167</span> return getProcedure() != null;<a name="line.167"></a> +<span class="sourceLineNo">168</span> }<a name="line.168"></a> +<span class="sourceLineNo">169</span><a name="line.169"></a> +<span class="sourceLineNo">170</span> public long getLastUpdate() {<a name="line.170"></a> +<span class="sourceLineNo">171</span> TransitRegionStateProcedure proc = this.procedure;<a name="line.171"></a> +<span class="sourceLineNo">172</span> return proc != null ? proc.getLastUpdate() : lastUpdate;<a name="line.172"></a> +<span class="sourceLineNo">173</span> }<a name="line.173"></a> +<span class="sourceLineNo">174</span><a name="line.174"></a> +<span class="sourceLineNo">175</span> public void setLastHost(final ServerName serverName) {<a name="line.175"></a> +<span class="sourceLineNo">176</span> this.lastHost = serverName;<a name="line.176"></a> +<span class="sourceLineNo">177</span> }<a name="line.177"></a> +<span class="sourceLineNo">178</span><a name="line.178"></a> +<span class="sourceLineNo">179</span> public void setOpenSeqNum(final long seqId) {<a name="line.179"></a> +<span class="sourceLineNo">180</span> this.openSeqNum = seqId;<a name="line.180"></a> +<span class="sourceLineNo">181</span> }<a name="line.181"></a> +<span class="sourceLineNo">182</span><a name="line.182"></a> +<span class="sourceLineNo">183</span> public ServerName setRegionLocation(final ServerName serverName) {<a name="line.183"></a> +<span class="sourceLineNo">184</span> ServerName lastRegionLocation = this.regionLocation;<a name="line.184"></a> +<span class="sourceLineNo">185</span> if (LOG.isTraceEnabled() && serverName == null) {<a name="line.185"></a> +<span class="sourceLineNo">186</span> LOG.trace("Tracking when we are set to null " + this, new Throwable("TRACE"));<a name="line.186"></a> +<span class="sourceLineNo">187</span> }<a name="line.187"></a> +<span class="sourceLineNo">188</span> this.regionLocation = serverName;<a name="line.188"></a> +<span class="sourceLineNo">189</span> this.lastUpdate = EnvironmentEdgeManager.currentTime();<a name="line.189"></a> +<span class="sourceLineNo">190</span> return lastRegionLocation;<a name="line.190"></a> +<span class="sourceLineNo">191</span> }<a name="line.191"></a> +<span class="sourceLineNo">192</span><a name="line.192"></a> +<span class="sourceLineNo">193</span> public void setProcedure(TransitRegionStateProcedure proc) {<a name="line.193"></a> +<span class="sourceLineNo">194</span> assert this.procedure == null;<a name="line.194"></a> +<span class="sourceLineNo">195</span> this.procedure = proc;<a name="line.195"></a> +<span class="sourceLineNo">196</span> ritMap.put(regionInfo, this);<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 void unsetProcedure(TransitRegionStateProcedure proc) {<a name="line.199"></a> +<span class="sourceLineNo">200</span> assert this.procedure == proc;<a name="line.200"></a> +<span class="sourceLineNo">201</span> this.procedure = null;<a name="line.201"></a> +<span class="sourceLineNo">202</span> ritMap.remove(regionInfo, this);<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span><a name="line.204"></a> +<span class="sourceLineNo">205</span> public TransitRegionStateProcedure getProcedure() {<a name="line.205"></a> +<span class="sourceLineNo">206</span> return procedure;<a name="line.206"></a> +<span class="sourceLineNo">207</span> }<a name="line.207"></a> +<span class="sourceLineNo">208</span><a name="line.208"></a> +<span class="sourceLineNo">209</span> public ProcedureEvent<?> getProcedureEvent() {<a name="line.209"></a> +<span class="sourceLineNo">210</span> return event;<a name="line.210"></a> +<span class="sourceLineNo">211</span> }<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> public RegionInfo getRegionInfo() {<a name="line.213"></a> +<span class="sourceLineNo">214</span> return regionInfo;<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> public TableName getTable() {<a name="line.217"></a> +<span class="sourceLineNo">218</span> return getRegionInfo().getTable();<a name="line.218"></a> +<span class="sourceLineNo">219</span> }<a name="line.219"></a> +<span class="sourceLineNo">220</span><a name="line.220"></a> +<span class="sourceLineNo">221</span> public boolean isSystemTable() {<a name="line.221"></a> +<span class="sourceLineNo">222</span> return getTable().isSystemTable();<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 ServerName getLastHost() {<a name="line.225"></a> +<span class="sourceLineNo">226</span> return lastHost;<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 ServerName getRegionLocation() {<a name="line.229"></a> +<span class="sourceLineNo">230</span> return regionLocation;<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 State getState() {<a name="line.233"></a> +<span class="sourceLineNo">234</span> return state;<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 long getOpenSeqNum() {<a name="line.237"></a> +<span class="sourceLineNo">238</span> return openSeqNum;<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 int getFormatVersion() {<a name="line.241"></a> +<span class="sourceLineNo">242</span> // we don't have any format for now<a name="line.242"></a> +<span class="sourceLineNo">243</span> // it should probably be in regionInfo.getFormatVersion()<a name="line.243"></a> +<span class="sourceLineNo">244</span> return 0;<a name="line.244"></a> +<span class="sourceLineNo">245</span> }<a name="line.245"></a> +<span class="sourceLineNo">246</span><a name="line.246"></a> +<span class="sourceLineNo">247</span> public RegionState toRegionState() {<a name="line.247"></a> +<span class="sourceLineNo">248</span> return new RegionState(getRegionInfo(), getState(), getLastUpdate(), getRegionLocation());<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> @Override<a name="line.251"></a> +<span class="sourceLineNo">252</span> public int compareTo(final RegionStateNode other) {<a name="line.252"></a> +<span class="sourceLineNo">253</span> // NOTE: RegionInfo sort by table first, so we are relying on that.<a name="line.253"></a> +<span class="sourceLineNo">254</span> // we have a TestRegionState#testOrderedByTable() that check for that.<a name="line.254"></a> +<span class="sourceLineNo">255</span> return RegionInfo.COMPARATOR.compare(getRegionInfo(), other.getRegionInfo());<a name="line.255"></a> +<span class="sourceLineNo">256</span> }<a name="line.256"></a> +<span class="sourceLineNo">257</span><a name="line.257"></a> +<span class="sourceLineNo">258</span> @Override<a name="line.258"></a> +<span class="sourceLineNo">259</span> public int hashCode() {<a name="line.259"></a> +<span class="sourceLineNo">260</span> return getRegionInfo().hashCode();<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> @Override<a name="line.263"></a> +<span class="sourceLineNo">264</span> public boolean equals(final Object other) {<a name="line.264"></a> +<span class="sourceLineNo">265</span> if (this == other) {<a name="line.265"></a> +<span class="sourceLineNo">266</span> return true;<a name="line.266"></a> +<span class="sourceLineNo">267</span> }<a name="line.267"></a> +<span class="sourceLineNo">268</span> if (!(other instanceof RegionStateNode)) {<a name="line.268"></a> +<span class="sourceLineNo">269</span> return false;<a name="line.269"></a> +<span class="sourceLineNo">270</span> }<a name="line.270"></a> +<span class="sourceLineNo">271</span> return compareTo((RegionStateNode) other) == 0;<a name="line.271"></a> +<span class="sourceLineNo">272</span> }<a name="line.272"></a> +<span class="sourceLineNo">273</span><a name="line.273"></a> +<span class="sourceLineNo">274</span> @Override<a name="line.274"></a> +<span class="sourceLineNo">275</span> public String toString() {<a name="line.275"></a> +<span class="sourceLineNo">276</span> return toDescriptiveString();<a name="line.276"></a> +<span class="sourceLineNo">277</span> }<a name="line.277"></a> +<span class="sourceLineNo">278</span><a name="line.278"></a> +<span class="sourceLineNo">279</span> public String toShortString() {<a name="line.279"></a> +<span class="sourceLineNo">280</span> // rit= is the current Region-In-Transition State -- see State enum.<a name="line.280"></a> +<span class="sourceLineNo">281</span> return String.format("rit=%s, location=%s", getState(), getRegionLocation());<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 String toDescriptiveString() {<a name="line.284"></a> +<span class="sourceLineNo">285</span> return String.format("%s, table=%s, region=%s", toShortString(), getTable(),<a name="line.285"></a> +<span class="sourceLineNo">286</span> getRegionInfo().getEncodedName());<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 void checkOnline() throws DoNotRetryRegionException {<a name="line.289"></a> +<span class="sourceLineNo">290</span> RegionInfo ri = getRegionInfo();<a name="line.290"></a> +<span class="sourceLineNo">291</span> State s = state;<a name="line.291"></a> +<span class="sourceLineNo">292</span> if (s != State.OPEN) {<a name="line.292"></a> +<span class="sourceLineNo">293</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " is no OPEN; state=" + s);<a name="line.293"></a> +<span class="sourceLineNo">294</span> }<a name="line.294"></a> +<span class="sourceLineNo">295</span> if (ri.isSplitParent()) {<a name="line.295"></a> +<span class="sourceLineNo">296</span> throw new DoNotRetryRegionException(<a name="line.296"></a> +<span class="sourceLineNo">297</span> ri.getEncodedName() + " is not online (splitParent=true)");<a name="line.297"></a> +<span class="sourceLineNo">298</span> }<a name="line.298"></a> +<span class="sourceLineNo">299</span> if (ri.isSplit()) {<a name="line.299"></a> +<span class="sourceLineNo">300</span> throw new DoNotRetryRegionException(ri.getEncodedName() + " has split=true");<a name="line.300"></a> +<span class="sourceLineNo">301</span> }<a name="line.301"></a> +<span class="sourceLineNo">302</span> if (ri.isOffline()) {<a name="line.302"></a> +<span class="sourceLineNo">303</span> // RegionOfflineException is not instance of DNRIOE so wrap it.<a name="line.303"></a> +<span class="sourceLineNo">304</span> throw new DoNotRetryRegionException(new RegionOfflineException(ri.getEncodedName()));<a name="line.304"></a> +<span class="sourceLineNo">305</span> }<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 void lock() {<a name="line.308"></a> +<span class="sourceLineNo">309</span> lock.lock();<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 void unlock() {<a name="line.312"></a> +<span class="sourceLineNo">313</span> lock.unlock();<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>