hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [19/28] hbase-site git commit: Published site at .
Date Sun, 17 Dec 2017 15:17:58 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/48bd3915/devapidocs/src-html/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.html b/devapidocs/src-html/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.html
index a3bc449..a0dbad7 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.html
@@ -107,535 +107,551 @@
 <span class="sourceLineNo">099</span>  }<a name="line.99"></a>
 <span class="sourceLineNo">100</span><a name="line.100"></a>
 <span class="sourceLineNo">101</span>  /**<a name="line.101"></a>
-<span class="sourceLineNo">102</span>   *<a name="line.102"></a>
-<span class="sourceLineNo">103</span>   * @param zkw<a name="line.103"></a>
-<span class="sourceLineNo">104</span>   * @param replicaId<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   * @return meta table regions and their locations.<a name="line.105"></a>
-<span class="sourceLineNo">106</span>   */<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  public List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; getMetaRegionsAndLocations(ZKWatcher zkw,<a name="line.107"></a>
-<span class="sourceLineNo">108</span>      int replicaId) {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>    ServerName serverName = getMetaRegionLocation(zkw, replicaId);<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; list = new ArrayList&lt;&gt;(1);<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    list.add(new Pair&lt;&gt;(RegionReplicaUtil.getRegionInfoForReplica(<a name="line.111"></a>
-<span class="sourceLineNo">112</span>        RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId), serverName));<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    return list;<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  }<a name="line.114"></a>
-<span class="sourceLineNo">115</span><a name="line.115"></a>
-<span class="sourceLineNo">116</span>  /**<a name="line.116"></a>
-<span class="sourceLineNo">117</span>   * @param zkw ZooKeeper watcher to be used<a name="line.117"></a>
-<span class="sourceLineNo">118</span>   * @return List of meta regions<a name="line.118"></a>
-<span class="sourceLineNo">119</span>   */<a name="line.119"></a>
-<span class="sourceLineNo">120</span>  public List&lt;RegionInfo&gt; getMetaRegions(ZKWatcher zkw) {<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    return getMetaRegions(zkw, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>  }<a name="line.122"></a>
-<span class="sourceLineNo">123</span><a name="line.123"></a>
-<span class="sourceLineNo">124</span>  /**<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   *<a name="line.125"></a>
-<span class="sourceLineNo">126</span>   * @param zkw<a name="line.126"></a>
-<span class="sourceLineNo">127</span>   * @param replicaId<a name="line.127"></a>
-<span class="sourceLineNo">128</span>   * @return List of meta regions<a name="line.128"></a>
-<span class="sourceLineNo">129</span>   */<a name="line.129"></a>
-<span class="sourceLineNo">130</span>  public List&lt;RegionInfo&gt; getMetaRegions(ZKWatcher zkw, int replicaId) {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; result;<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    result = getMetaRegionsAndLocations(zkw, replicaId);<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    return getListOfRegionInfos(result);<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  }<a name="line.134"></a>
-<span class="sourceLineNo">135</span><a name="line.135"></a>
-<span class="sourceLineNo">136</span>  private List&lt;RegionInfo&gt; getListOfRegionInfos(<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      final List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs) {<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    if (pairs == null || pairs.isEmpty()) return Collections.EMPTY_LIST;<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    List&lt;RegionInfo&gt; result = new ArrayList&lt;&gt;(pairs.size());<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    for (Pair&lt;RegionInfo, ServerName&gt; pair: pairs) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      result.add(pair.getFirst());<a name="line.141"></a>
-<span class="sourceLineNo">142</span>    }<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    return result;<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  }<a name="line.144"></a>
-<span class="sourceLineNo">145</span><a name="line.145"></a>
-<span class="sourceLineNo">146</span>  /**<a name="line.146"></a>
-<span class="sourceLineNo">147</span>   * Gets the meta region location, if available.  Does not block.<a name="line.147"></a>
-<span class="sourceLineNo">148</span>   * @param zkw zookeeper connection to use<a name="line.148"></a>
-<span class="sourceLineNo">149</span>   * @return server name or null if we failed to get the data.<a name="line.149"></a>
-<span class="sourceLineNo">150</span>   */<a name="line.150"></a>
-<span class="sourceLineNo">151</span>  public ServerName getMetaRegionLocation(final ZKWatcher zkw) {<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    try {<a name="line.152"></a>
-<span class="sourceLineNo">153</span>      RegionState state = getMetaRegionState(zkw);<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      return state.isOpened() ? state.getServerName() : null;<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    } catch (KeeperException ke) {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>      return null;<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>  }<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>  /**<a name="line.160"></a>
-<span class="sourceLineNo">161</span>   * Gets the meta region location, if available.  Does not block.<a name="line.161"></a>
-<span class="sourceLineNo">162</span>   * @param zkw<a name="line.162"></a>
-<span class="sourceLineNo">163</span>   * @param replicaId<a name="line.163"></a>
-<span class="sourceLineNo">164</span>   * @return server name<a name="line.164"></a>
-<span class="sourceLineNo">165</span>   */<a name="line.165"></a>
-<span class="sourceLineNo">166</span>  public ServerName getMetaRegionLocation(final ZKWatcher zkw, int replicaId) {<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    try {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      RegionState state = getMetaRegionState(zkw, replicaId);<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      return state.isOpened() ? state.getServerName() : null;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    } catch (KeeperException ke) {<a name="line.170"></a>
-<span class="sourceLineNo">171</span>      return null;<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    }<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>  /**<a name="line.175"></a>
-<span class="sourceLineNo">176</span>   * Gets the meta region location, if available, and waits for up to the<a name="line.176"></a>
-<span class="sourceLineNo">177</span>   * specified timeout if not immediately available.<a name="line.177"></a>
-<span class="sourceLineNo">178</span>   * Given the zookeeper notification could be delayed, we will try to<a name="line.178"></a>
-<span class="sourceLineNo">179</span>   * get the latest data.<a name="line.179"></a>
-<span class="sourceLineNo">180</span>   * @param zkw<a name="line.180"></a>
-<span class="sourceLineNo">181</span>   * @param timeout maximum time to wait, in millis<a name="line.181"></a>
-<span class="sourceLineNo">182</span>   * @return server name for server hosting meta region formatted as per<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   * {@link ServerName}, or null if none available<a name="line.183"></a>
-<span class="sourceLineNo">184</span>   * @throws InterruptedException if interrupted while waiting<a name="line.184"></a>
-<span class="sourceLineNo">185</span>   * @throws NotAllMetaRegionsOnlineException<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   */<a name="line.186"></a>
-<span class="sourceLineNo">187</span>  public ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout)<a name="line.187"></a>
-<span class="sourceLineNo">188</span>  throws InterruptedException, NotAllMetaRegionsOnlineException {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    return waitMetaRegionLocation(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout);<a name="line.189"></a>
-<span class="sourceLineNo">190</span>  }<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>   * Gets the meta region location, if available, and waits for up to the<a name="line.193"></a>
-<span class="sourceLineNo">194</span>   * specified timeout if not immediately available.<a name="line.194"></a>
-<span class="sourceLineNo">195</span>   * Given the zookeeper notification could be delayed, we will try to<a name="line.195"></a>
-<span class="sourceLineNo">196</span>   * get the latest data.<a name="line.196"></a>
-<span class="sourceLineNo">197</span>   * @param zkw<a name="line.197"></a>
-<span class="sourceLineNo">198</span>   * @param replicaId<a name="line.198"></a>
-<span class="sourceLineNo">199</span>   * @param timeout maximum time to wait, in millis<a name="line.199"></a>
-<span class="sourceLineNo">200</span>   * @return server name for server hosting meta region formatted as per<a name="line.200"></a>
-<span class="sourceLineNo">201</span>   * {@link ServerName}, or null if none available<a name="line.201"></a>
-<span class="sourceLineNo">202</span>   * @throws InterruptedException<a name="line.202"></a>
-<span class="sourceLineNo">203</span>   * @throws NotAllMetaRegionsOnlineException<a name="line.203"></a>
-<span class="sourceLineNo">204</span>   */<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  throws InterruptedException, NotAllMetaRegionsOnlineException {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    try {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. "<a name="line.209"></a>
-<span class="sourceLineNo">210</span>            + "There could be a mismatch with the one configured in the master.";<a name="line.210"></a>
-<span class="sourceLineNo">211</span>        LOG.error(errorMsg);<a name="line.211"></a>
-<span class="sourceLineNo">212</span>        throw new IllegalArgumentException(errorMsg);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>      }<a name="line.213"></a>
-<span class="sourceLineNo">214</span>    } catch (KeeperException e) {<a name="line.214"></a>
-<span class="sourceLineNo">215</span>      throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);<a name="line.215"></a>
-<span class="sourceLineNo">216</span>    }<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    ServerName sn = blockUntilAvailable(zkw, replicaId, timeout);<a name="line.217"></a>
-<span class="sourceLineNo">218</span><a name="line.218"></a>
-<span class="sourceLineNo">219</span>    if (sn == null) {<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");<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>    return sn;<a name="line.223"></a>
-<span class="sourceLineNo">224</span>  }<a name="line.224"></a>
+<span class="sourceLineNo">102</span>   * Gets the meta regions and their locations for the given path and replica ID.<a name="line.102"></a>
+<span class="sourceLineNo">103</span>   *<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   * @param replicaId the ID of the replica<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   * @return meta table regions and their locations.<a name="line.106"></a>
+<span class="sourceLineNo">107</span>   */<a name="line.107"></a>
+<span class="sourceLineNo">108</span>  public List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; getMetaRegionsAndLocations(ZKWatcher zkw,<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      int replicaId) {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    ServerName serverName = getMetaRegionLocation(zkw, replicaId);<a name="line.110"></a>
+<span class="sourceLineNo">111</span>    List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; list = new ArrayList&lt;&gt;(1);<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    list.add(new Pair&lt;&gt;(RegionReplicaUtil.getRegionInfoForReplica(<a name="line.112"></a>
+<span class="sourceLineNo">113</span>        RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId), serverName));<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    return list;<a name="line.114"></a>
+<span class="sourceLineNo">115</span>  }<a name="line.115"></a>
+<span class="sourceLineNo">116</span><a name="line.116"></a>
+<span class="sourceLineNo">117</span>  /**<a name="line.117"></a>
+<span class="sourceLineNo">118</span>   * Gets the meta regions for the given path with the default replica ID.<a name="line.118"></a>
+<span class="sourceLineNo">119</span>   *<a name="line.119"></a>
+<span class="sourceLineNo">120</span>   * @param zkw ZooKeeper watcher to be used<a name="line.120"></a>
+<span class="sourceLineNo">121</span>   * @return List of meta regions<a name="line.121"></a>
+<span class="sourceLineNo">122</span>   */<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  public List&lt;RegionInfo&gt; getMetaRegions(ZKWatcher zkw) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    return getMetaRegions(zkw, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.124"></a>
+<span class="sourceLineNo">125</span>  }<a name="line.125"></a>
+<span class="sourceLineNo">126</span><a name="line.126"></a>
+<span class="sourceLineNo">127</span>  /**<a name="line.127"></a>
+<span class="sourceLineNo">128</span>   * Gets the meta regions for the given path and replica ID.<a name="line.128"></a>
+<span class="sourceLineNo">129</span>   *<a name="line.129"></a>
+<span class="sourceLineNo">130</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.130"></a>
+<span class="sourceLineNo">131</span>   * @param replicaId the ID of the replica<a name="line.131"></a>
+<span class="sourceLineNo">132</span>   * @return List of meta regions<a name="line.132"></a>
+<span class="sourceLineNo">133</span>   */<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  public List&lt;RegionInfo&gt; getMetaRegions(ZKWatcher zkw, int replicaId) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; result;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    result = getMetaRegionsAndLocations(zkw, replicaId);<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    return getListOfRegionInfos(result);<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  private List&lt;RegionInfo&gt; getListOfRegionInfos(final List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    if (pairs == null || pairs.isEmpty()) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      return Collections.EMPTY_LIST;<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    }<a name="line.143"></a>
+<span class="sourceLineNo">144</span><a name="line.144"></a>
+<span class="sourceLineNo">145</span>    List&lt;RegionInfo&gt; result = new ArrayList&lt;&gt;(pairs.size());<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    for (Pair&lt;RegionInfo, ServerName&gt; pair: pairs) {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      result.add(pair.getFirst());<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    }<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    return result;<a name="line.149"></a>
+<span class="sourceLineNo">150</span>  }<a name="line.150"></a>
+<span class="sourceLineNo">151</span><a name="line.151"></a>
+<span class="sourceLineNo">152</span>  /**<a name="line.152"></a>
+<span class="sourceLineNo">153</span>   * Gets the meta region location, if available.  Does not block.<a name="line.153"></a>
+<span class="sourceLineNo">154</span>   * @param zkw zookeeper connection to use<a name="line.154"></a>
+<span class="sourceLineNo">155</span>   * @return server name or null if we failed to get the data.<a name="line.155"></a>
+<span class="sourceLineNo">156</span>   */<a name="line.156"></a>
+<span class="sourceLineNo">157</span>  public ServerName getMetaRegionLocation(final ZKWatcher zkw) {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    try {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>      RegionState state = getMetaRegionState(zkw);<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      return state.isOpened() ? state.getServerName() : null;<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    } catch (KeeperException ke) {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>      return null;<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>  /**<a name="line.166"></a>
+<span class="sourceLineNo">167</span>   * Gets the meta region location, if available.  Does not block.<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * @param replicaId the ID of the replica<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   * @return server name<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   */<a name="line.171"></a>
+<span class="sourceLineNo">172</span>  public ServerName getMetaRegionLocation(final ZKWatcher zkw, int replicaId) {<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    try {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      RegionState state = getMetaRegionState(zkw, replicaId);<a name="line.174"></a>
+<span class="sourceLineNo">175</span>      return state.isOpened() ? state.getServerName() : null;<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    } catch (KeeperException ke) {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>      return null;<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    }<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>  /**<a name="line.181"></a>
+<span class="sourceLineNo">182</span>   * Gets the meta region location, if available, and waits for up to the<a name="line.182"></a>
+<span class="sourceLineNo">183</span>   * specified timeout if not immediately available.<a name="line.183"></a>
+<span class="sourceLineNo">184</span>   * Given the zookeeper notification could be delayed, we will try to<a name="line.184"></a>
+<span class="sourceLineNo">185</span>   * get the latest data.<a name="line.185"></a>
+<span class="sourceLineNo">186</span>   *<a name="line.186"></a>
+<span class="sourceLineNo">187</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.187"></a>
+<span class="sourceLineNo">188</span>   * @param timeout maximum time to wait, in millis<a name="line.188"></a>
+<span class="sourceLineNo">189</span>   * @return server name for server hosting meta region formatted as per<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * {@link ServerName}, or null if none available<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * @throws InterruptedException if interrupted while waiting<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   * @throws NotAllMetaRegionsOnlineException if a meta or root region is not online<a name="line.192"></a>
+<span class="sourceLineNo">193</span>   */<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public ServerName waitMetaRegionLocation(ZKWatcher zkw, long timeout)<a name="line.194"></a>
+<span class="sourceLineNo">195</span>  throws InterruptedException, NotAllMetaRegionsOnlineException {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    return waitMetaRegionLocation(zkw, RegionInfo.DEFAULT_REPLICA_ID, timeout);<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>  /**<a name="line.199"></a>
+<span class="sourceLineNo">200</span>   * Gets the meta region location, if available, and waits for up to the specified timeout if not<a name="line.200"></a>
+<span class="sourceLineNo">201</span>   * immediately available. Given the zookeeper notification could be delayed, we will try to<a name="line.201"></a>
+<span class="sourceLineNo">202</span>   * get the latest data.<a name="line.202"></a>
+<span class="sourceLineNo">203</span>   *<a name="line.203"></a>
+<span class="sourceLineNo">204</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.204"></a>
+<span class="sourceLineNo">205</span>   * @param replicaId the ID of the replica<a name="line.205"></a>
+<span class="sourceLineNo">206</span>   * @param timeout maximum time to wait, in millis<a name="line.206"></a>
+<span class="sourceLineNo">207</span>   * @return server name for server hosting meta region formatted as per<a name="line.207"></a>
+<span class="sourceLineNo">208</span>   * {@link ServerName}, or null if none available<a name="line.208"></a>
+<span class="sourceLineNo">209</span>   * @throws InterruptedException if waiting for the socket operation fails<a name="line.209"></a>
+<span class="sourceLineNo">210</span>   * @throws NotAllMetaRegionsOnlineException if a meta or root region is not online<a name="line.210"></a>
+<span class="sourceLineNo">211</span>   */<a name="line.211"></a>
+<span class="sourceLineNo">212</span>  public ServerName waitMetaRegionLocation(ZKWatcher zkw, int replicaId, long timeout)<a name="line.212"></a>
+<span class="sourceLineNo">213</span>  throws InterruptedException, NotAllMetaRegionsOnlineException {<a name="line.213"></a>
+<span class="sourceLineNo">214</span>    try {<a name="line.214"></a>
+<span class="sourceLineNo">215</span>      if (ZKUtil.checkExists(zkw, zkw.znodePaths.baseZNode) == -1) {<a name="line.215"></a>
+<span class="sourceLineNo">216</span>        String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. "<a name="line.216"></a>
+<span class="sourceLineNo">217</span>            + "There could be a mismatch with the one configured in the master.";<a name="line.217"></a>
+<span class="sourceLineNo">218</span>        LOG.error(errorMsg);<a name="line.218"></a>
+<span class="sourceLineNo">219</span>        throw new IllegalArgumentException(errorMsg);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      }<a name="line.220"></a>
+<span class="sourceLineNo">221</span>    } catch (KeeperException e) {<a name="line.221"></a>
+<span class="sourceLineNo">222</span>      throw new IllegalStateException("KeeperException while trying to check baseZNode:", e);<a name="line.222"></a>
+<span class="sourceLineNo">223</span>    }<a name="line.223"></a>
+<span class="sourceLineNo">224</span>    ServerName sn = blockUntilAvailable(zkw, replicaId, timeout);<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>   * Waits indefinitely for availability of &lt;code&gt;hbase:meta&lt;/code&gt;.  Used during<a name="line.227"></a>
-<span class="sourceLineNo">228</span>   * cluster startup.  Does not verify meta, just that something has been<a name="line.228"></a>
-<span class="sourceLineNo">229</span>   * set up in zk.<a name="line.229"></a>
-<span class="sourceLineNo">230</span>   * @see #waitMetaRegionLocation(ZKWatcher, long)<a name="line.230"></a>
-<span class="sourceLineNo">231</span>   * @throws InterruptedException if interrupted while waiting<a name="line.231"></a>
-<span class="sourceLineNo">232</span>   */<a name="line.232"></a>
-<span class="sourceLineNo">233</span>  public void waitMetaRegionLocation(ZKWatcher zkw) throws InterruptedException {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>    long startTime = System.currentTimeMillis();<a name="line.234"></a>
-<span class="sourceLineNo">235</span>    while (!stopped) {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>      try {<a name="line.236"></a>
-<span class="sourceLineNo">237</span>        if (waitMetaRegionLocation(zkw, 100) != null) break;<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        long sleepTime = System.currentTimeMillis() - startTime;<a name="line.238"></a>
-<span class="sourceLineNo">239</span>        // +1 in case sleepTime=0<a name="line.239"></a>
-<span class="sourceLineNo">240</span>        if ((sleepTime + 1) % 10000 == 0) {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>          LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");<a name="line.241"></a>
-<span class="sourceLineNo">242</span>        }<a name="line.242"></a>
-<span class="sourceLineNo">243</span>      } catch (NotAllMetaRegionsOnlineException e) {<a name="line.243"></a>
-<span class="sourceLineNo">244</span>        if (LOG.isTraceEnabled()) {<a name="line.244"></a>
-<span class="sourceLineNo">245</span>          LOG.trace("hbase:meta still not available, sleeping and retrying." +<a name="line.245"></a>
-<span class="sourceLineNo">246</span>            " Reason: " + e.getMessage());<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>    }<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>  /**<a name="line.252"></a>
-<span class="sourceLineNo">253</span>   * Verify &lt;code&gt;hbase:meta&lt;/code&gt; is deployed and accessible.<a name="line.253"></a>
-<span class="sourceLineNo">254</span>   * @param hConnection<a name="line.254"></a>
-<span class="sourceLineNo">255</span>   * @param zkw<a name="line.255"></a>
-<span class="sourceLineNo">256</span>   * @param timeout How long to wait on zk for meta address (passed through to<a name="line.256"></a>
-<span class="sourceLineNo">257</span>   * the internal call to {@link #getMetaServerConnection}.<a name="line.257"></a>
-<span class="sourceLineNo">258</span>   * @return True if the &lt;code&gt;hbase:meta&lt;/code&gt; location is healthy.<a name="line.258"></a>
-<span class="sourceLineNo">259</span>   * @throws java.io.IOException<a name="line.259"></a>
-<span class="sourceLineNo">260</span>   * @throws InterruptedException<a name="line.260"></a>
-<span class="sourceLineNo">261</span>   */<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  public boolean verifyMetaRegionLocation(ClusterConnection hConnection,<a name="line.262"></a>
-<span class="sourceLineNo">263</span>                                          ZKWatcher zkw, final long timeout)<a name="line.263"></a>
-<span class="sourceLineNo">264</span>  throws InterruptedException, IOException {<a name="line.264"></a>
-<span class="sourceLineNo">265</span>    return verifyMetaRegionLocation(hConnection, zkw, timeout, RegionInfo.DEFAULT_REPLICA_ID);<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>  /**<a name="line.268"></a>
-<span class="sourceLineNo">269</span>   * Verify &lt;code&gt;hbase:meta&lt;/code&gt; is deployed and accessible.<a name="line.269"></a>
-<span class="sourceLineNo">270</span>   * @param connection<a name="line.270"></a>
-<span class="sourceLineNo">271</span>   * @param zkw<a name="line.271"></a>
-<span class="sourceLineNo">272</span>   * @param timeout How long to wait on zk for meta address (passed through to<a name="line.272"></a>
-<span class="sourceLineNo">273</span>   * @param replicaId<a name="line.273"></a>
-<span class="sourceLineNo">274</span>   * @return True if the &lt;code&gt;hbase:meta&lt;/code&gt; location is healthy.<a name="line.274"></a>
-<span class="sourceLineNo">275</span>   * @throws InterruptedException<a name="line.275"></a>
-<span class="sourceLineNo">276</span>   * @throws IOException<a name="line.276"></a>
-<span class="sourceLineNo">277</span>   */<a name="line.277"></a>
-<span class="sourceLineNo">278</span>  public boolean verifyMetaRegionLocation(ClusterConnection connection,<a name="line.278"></a>
-<span class="sourceLineNo">279</span>                                          ZKWatcher zkw, final long timeout, int replicaId)<a name="line.279"></a>
-<span class="sourceLineNo">280</span>  throws InterruptedException, IOException {<a name="line.280"></a>
-<span class="sourceLineNo">281</span>    AdminProtos.AdminService.BlockingInterface service = null;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>    try {<a name="line.282"></a>
-<span class="sourceLineNo">283</span>      service = getMetaServerConnection(connection, zkw, timeout, replicaId);<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    } catch (NotAllMetaRegionsOnlineException e) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      // Pass<a name="line.285"></a>
-<span class="sourceLineNo">286</span>    } catch (ServerNotRunningYetException e) {<a name="line.286"></a>
-<span class="sourceLineNo">287</span>      // Pass -- remote server is not up so can't be carrying root<a name="line.287"></a>
-<span class="sourceLineNo">288</span>    } catch (UnknownHostException e) {<a name="line.288"></a>
-<span class="sourceLineNo">289</span>      // Pass -- server name doesn't resolve so it can't be assigned anything.<a name="line.289"></a>
-<span class="sourceLineNo">290</span>    } catch (RegionServerStoppedException e) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      // Pass -- server name sends us to a server that is dying or already dead.<a name="line.291"></a>
-<span class="sourceLineNo">292</span>    }<a name="line.292"></a>
-<span class="sourceLineNo">293</span>    return (service != null) &amp;&amp; verifyRegionLocation(connection, service,<a name="line.293"></a>
-<span class="sourceLineNo">294</span>            getMetaRegionLocation(zkw, replicaId), RegionReplicaUtil.getRegionInfoForReplica(<a name="line.294"></a>
-<span class="sourceLineNo">295</span>                RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId).getRegionName());<a name="line.295"></a>
-<span class="sourceLineNo">296</span>  }<a name="line.296"></a>
-<span class="sourceLineNo">297</span><a name="line.297"></a>
-<span class="sourceLineNo">298</span>  /**<a name="line.298"></a>
-<span class="sourceLineNo">299</span>   * Verify we can connect to &lt;code&gt;hostingServer&lt;/code&gt; and that its carrying<a name="line.299"></a>
-<span class="sourceLineNo">300</span>   * &lt;code&gt;regionName&lt;/code&gt;.<a name="line.300"></a>
-<span class="sourceLineNo">301</span>   * @param hostingServer Interface to the server hosting &lt;code&gt;regionName&lt;/code&gt;<a name="line.301"></a>
-<span class="sourceLineNo">302</span>   * @param address The servername that goes with the &lt;code&gt;metaServer&lt;/code&gt;<a name="line.302"></a>
-<span class="sourceLineNo">303</span>   * Interface.  Used logging.<a name="line.303"></a>
-<span class="sourceLineNo">304</span>   * @param regionName The regionname we are interested in.<a name="line.304"></a>
-<span class="sourceLineNo">305</span>   * @return True if we were able to verify the region located at other side of<a name="line.305"></a>
-<span class="sourceLineNo">306</span>   * the Interface.<a name="line.306"></a>
-<span class="sourceLineNo">307</span>   * @throws IOException<a name="line.307"></a>
-<span class="sourceLineNo">308</span>   */<a name="line.308"></a>
-<span class="sourceLineNo">309</span>  // TODO: We should be able to get the ServerName from the AdminProtocol<a name="line.309"></a>
-<span class="sourceLineNo">310</span>  // rather than have to pass it in.  Its made awkward by the fact that the<a name="line.310"></a>
-<span class="sourceLineNo">311</span>  // HRI is likely a proxy against remote server so the getServerName needs<a name="line.311"></a>
-<span class="sourceLineNo">312</span>  // to be fixed to go to a local method or to a cache before we can do this.<a name="line.312"></a>
-<span class="sourceLineNo">313</span>  private boolean verifyRegionLocation(final ClusterConnection connection,<a name="line.313"></a>
-<span class="sourceLineNo">314</span>      AdminService.BlockingInterface hostingServer, final ServerName address,<a name="line.314"></a>
-<span class="sourceLineNo">315</span>      final byte [] regionName)<a name="line.315"></a>
-<span class="sourceLineNo">316</span>  throws IOException {<a name="line.316"></a>
-<span class="sourceLineNo">317</span>    if (hostingServer == null) {<a name="line.317"></a>
-<span class="sourceLineNo">318</span>      LOG.info("Passed hostingServer is null");<a name="line.318"></a>
-<span class="sourceLineNo">319</span>      return false;<a name="line.319"></a>
-<span class="sourceLineNo">320</span>    }<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    Throwable t;<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    HBaseRpcController controller = connection.getRpcControllerFactory().newController();<a name="line.322"></a>
-<span class="sourceLineNo">323</span>    try {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>      // Try and get regioninfo from the hosting server.<a name="line.324"></a>
-<span class="sourceLineNo">325</span>      return ProtobufUtil.getRegionInfo(controller, hostingServer, regionName) != null;<a name="line.325"></a>
-<span class="sourceLineNo">326</span>    } catch (ConnectException e) {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>      t = e;<a name="line.327"></a>
-<span class="sourceLineNo">328</span>    } catch (RetriesExhaustedException e) {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>      t = e;<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    } catch (RemoteException e) {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      IOException ioe = e.unwrapRemoteException();<a name="line.331"></a>
-<span class="sourceLineNo">332</span>      t = ioe;<a name="line.332"></a>
-<span class="sourceLineNo">333</span>    } catch (IOException e) {<a name="line.333"></a>
-<span class="sourceLineNo">334</span>      Throwable cause = e.getCause();<a name="line.334"></a>
-<span class="sourceLineNo">335</span>      if (cause != null &amp;&amp; cause instanceof EOFException) {<a name="line.335"></a>
-<span class="sourceLineNo">336</span>        t = cause;<a name="line.336"></a>
-<span class="sourceLineNo">337</span>      } else if (cause != null &amp;&amp; cause.getMessage() != null<a name="line.337"></a>
-<span class="sourceLineNo">338</span>          &amp;&amp; cause.getMessage().contains("Connection reset")) {<a name="line.338"></a>
-<span class="sourceLineNo">339</span>        t = cause;<a name="line.339"></a>
-<span class="sourceLineNo">340</span>      } else {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>        t = e;<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>    LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) +<a name="line.344"></a>
-<span class="sourceLineNo">345</span>      " at address=" + address + ", exception=" + t.getMessage());<a name="line.345"></a>
-<span class="sourceLineNo">346</span>    return false;<a name="line.346"></a>
-<span class="sourceLineNo">347</span>  }<a name="line.347"></a>
-<span class="sourceLineNo">348</span><a name="line.348"></a>
-<span class="sourceLineNo">349</span>  /**<a name="line.349"></a>
-<span class="sourceLineNo">350</span>   * Gets a connection to the server hosting meta, as reported by ZooKeeper,<a name="line.350"></a>
-<span class="sourceLineNo">351</span>   * waiting up to the specified timeout for availability.<a name="line.351"></a>
-<span class="sourceLineNo">352</span>   * &lt;p&gt;WARNING: Does not retry.  Use an {@link org.apache.hadoop.hbase.client.HTable} instead.<a name="line.352"></a>
-<span class="sourceLineNo">353</span>   * @param connection<a name="line.353"></a>
-<span class="sourceLineNo">354</span>   * @param zkw<a name="line.354"></a>
-<span class="sourceLineNo">355</span>   * @param timeout How long to wait on meta location<a name="line.355"></a>
-<span class="sourceLineNo">356</span>   * @param replicaId<a name="line.356"></a>
-<span class="sourceLineNo">357</span>   * @return connection to server hosting meta<a name="line.357"></a>
-<span class="sourceLineNo">358</span>   * @throws InterruptedException<a name="line.358"></a>
-<span class="sourceLineNo">359</span>   * @throws NotAllMetaRegionsOnlineException if timed out waiting<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   * @throws IOException<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   */<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  private AdminService.BlockingInterface getMetaServerConnection(ClusterConnection connection,<a name="line.362"></a>
-<span class="sourceLineNo">363</span>                                                                 ZKWatcher zkw, long timeout, int replicaId)<a name="line.363"></a>
-<span class="sourceLineNo">364</span>  throws InterruptedException, NotAllMetaRegionsOnlineException, IOException {<a name="line.364"></a>
-<span class="sourceLineNo">365</span>    return getCachedConnection(connection, waitMetaRegionLocation(zkw, replicaId, timeout));<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>   * @param sn ServerName to get a connection against.<a name="line.369"></a>
-<span class="sourceLineNo">370</span>   * @return The AdminProtocol we got when we connected to &lt;code&gt;sn&lt;/code&gt;<a name="line.370"></a>
-<span class="sourceLineNo">371</span>   * May have come from cache, may not be good, may have been setup by this<a name="line.371"></a>
-<span class="sourceLineNo">372</span>   * invocation, or may be null.<a name="line.372"></a>
-<span class="sourceLineNo">373</span>   * @throws IOException<a name="line.373"></a>
-<span class="sourceLineNo">374</span>   */<a name="line.374"></a>
-<span class="sourceLineNo">375</span>  private static AdminService.BlockingInterface getCachedConnection(ClusterConnection connection,<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    ServerName sn)<a name="line.376"></a>
-<span class="sourceLineNo">377</span>  throws IOException {<a name="line.377"></a>
-<span class="sourceLineNo">378</span>    if (sn == null) {<a name="line.378"></a>
-<span class="sourceLineNo">379</span>      return null;<a name="line.379"></a>
-<span class="sourceLineNo">380</span>    }<a name="line.380"></a>
-<span class="sourceLineNo">381</span>    AdminService.BlockingInterface service = null;<a name="line.381"></a>
-<span class="sourceLineNo">382</span>    try {<a name="line.382"></a>
-<span class="sourceLineNo">383</span>      service = connection.getAdmin(sn);<a name="line.383"></a>
-<span class="sourceLineNo">384</span>    } catch (RetriesExhaustedException e) {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>      if (e.getCause() != null &amp;&amp; e.getCause() instanceof ConnectException) {<a name="line.385"></a>
-<span class="sourceLineNo">386</span>        // Catch this; presume it means the cached connection has gone bad.<a name="line.386"></a>
-<span class="sourceLineNo">387</span>      } else {<a name="line.387"></a>
-<span class="sourceLineNo">388</span>        throw e;<a name="line.388"></a>
-<span class="sourceLineNo">389</span>      }<a name="line.389"></a>
-<span class="sourceLineNo">390</span>    } catch (SocketTimeoutException e) {<a name="line.390"></a>
-<span class="sourceLineNo">391</span>      LOG.debug("Timed out connecting to " + sn);<a name="line.391"></a>
-<span class="sourceLineNo">392</span>    } catch (NoRouteToHostException e) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>      LOG.debug("Connecting to " + sn, e);<a name="line.393"></a>
-<span class="sourceLineNo">394</span>    } catch (SocketException e) {<a name="line.394"></a>
-<span class="sourceLineNo">395</span>      LOG.debug("Exception connecting to " + sn);<a name="line.395"></a>
-<span class="sourceLineNo">396</span>    } catch (UnknownHostException e) {<a name="line.396"></a>
-<span class="sourceLineNo">397</span>      LOG.debug("Unknown host exception connecting to  " + sn);<a name="line.397"></a>
-<span class="sourceLineNo">398</span>    } catch (FailedServerException e) {<a name="line.398"></a>
-<span class="sourceLineNo">399</span>      if (LOG.isDebugEnabled()) {<a name="line.399"></a>
-<span class="sourceLineNo">400</span>        LOG.debug("Server " + sn + " is in failed server list.");<a name="line.400"></a>
-<span class="sourceLineNo">401</span>      }<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    } catch (IOException ioe) {<a name="line.402"></a>
-<span class="sourceLineNo">403</span>      Throwable cause = ioe.getCause();<a name="line.403"></a>
-<span class="sourceLineNo">404</span>      if (ioe instanceof ConnectException) {<a name="line.404"></a>
-<span class="sourceLineNo">405</span>        // Catch. Connect refused.<a name="line.405"></a>
-<span class="sourceLineNo">406</span>      } else if (cause != null &amp;&amp; cause instanceof EOFException) {<a name="line.406"></a>
-<span class="sourceLineNo">407</span>        // Catch. Other end disconnected us.<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      } else if (cause != null &amp;&amp; cause.getMessage() != null &amp;&amp;<a name="line.408"></a>
-<span class="sourceLineNo">409</span>        cause.getMessage().toLowerCase(Locale.ROOT).contains("connection reset")) {<a name="line.409"></a>
-<span class="sourceLineNo">410</span>        // Catch. Connection reset.<a name="line.410"></a>
-<span class="sourceLineNo">411</span>      } else {<a name="line.411"></a>
-<span class="sourceLineNo">412</span>        throw ioe;<a name="line.412"></a>
-<span class="sourceLineNo">413</span>      }<a name="line.413"></a>
-<span class="sourceLineNo">414</span><a name="line.414"></a>
-<span class="sourceLineNo">415</span>    }<a name="line.415"></a>
-<span class="sourceLineNo">416</span>    return service;<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>   * Sets the location of &lt;code&gt;hbase:meta&lt;/code&gt; in ZooKeeper to the<a name="line.420"></a>
-<span class="sourceLineNo">421</span>   * specified server address.<a name="line.421"></a>
-<span class="sourceLineNo">422</span>   * @param zookeeper zookeeper reference<a name="line.422"></a>
-<span class="sourceLineNo">423</span>   * @param serverName The server hosting &lt;code&gt;hbase:meta&lt;/code&gt;<a name="line.423"></a>
-<span class="sourceLineNo">424</span>   * @param state The region transition state<a name="line.424"></a>
-<span class="sourceLineNo">425</span>   * @throws KeeperException unexpected zookeeper exception<a name="line.425"></a>
-<span class="sourceLineNo">426</span>   */<a name="line.426"></a>
-<span class="sourceLineNo">427</span>  public static void setMetaLocation(ZKWatcher zookeeper,<a name="line.427"></a>
-<span class="sourceLineNo">428</span>      ServerName serverName, RegionState.State state) throws KeeperException {<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    setMetaLocation(zookeeper, serverName, RegionInfo.DEFAULT_REPLICA_ID, state);<a name="line.429"></a>
-<span class="sourceLineNo">430</span>  }<a name="line.430"></a>
-<span class="sourceLineNo">431</span><a name="line.431"></a>
-<span class="sourceLineNo">432</span>  /**<a name="line.432"></a>
-<span class="sourceLineNo">433</span>   * Sets the location of &lt;code&gt;hbase:meta&lt;/code&gt; in ZooKeeper to the<a name="line.433"></a>
-<span class="sourceLineNo">434</span>   * specified server address.<a name="line.434"></a>
-<span class="sourceLineNo">435</span>   * @param zookeeper<a name="line.435"></a>
-<span class="sourceLineNo">436</span>   * @param serverName<a name="line.436"></a>
-<span class="sourceLineNo">437</span>   * @param replicaId<a name="line.437"></a>
-<span class="sourceLineNo">438</span>   * @param state<a name="line.438"></a>
-<span class="sourceLineNo">439</span>   * @throws KeeperException<a name="line.439"></a>
-<span class="sourceLineNo">440</span>   */<a name="line.440"></a>
-<span class="sourceLineNo">441</span>  public static void setMetaLocation(ZKWatcher zookeeper,<a name="line.441"></a>
-<span class="sourceLineNo">442</span>      ServerName serverName, int replicaId, RegionState.State state) throws KeeperException {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>    if (serverName == null) {<a name="line.443"></a>
-<span class="sourceLineNo">444</span>      LOG.warn("Tried to set null ServerName in hbase:meta; skipping -- ServerName required");<a name="line.444"></a>
-<span class="sourceLineNo">445</span>      return;<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    LOG.info("Setting hbase:meta (replicaId=" + replicaId + ") location in ZooKeeper as " +<a name="line.447"></a>
-<span class="sourceLineNo">448</span>      serverName);<a name="line.448"></a>
-<span class="sourceLineNo">449</span>    // Make the MetaRegionServer pb and then get its bytes and save this as<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    // the znode content.<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    MetaRegionServer pbrsr = MetaRegionServer.newBuilder()<a name="line.451"></a>
-<span class="sourceLineNo">452</span>      .setServer(ProtobufUtil.toServerName(serverName))<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      .setRpcVersion(HConstants.RPC_CURRENT_VERSION)<a name="line.453"></a>
-<span class="sourceLineNo">454</span>      .setState(state.convert()).build();<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    try {<a name="line.456"></a>
-<span class="sourceLineNo">457</span>      ZKUtil.setData(zookeeper,<a name="line.457"></a>
-<span class="sourceLineNo">458</span>          zookeeper.znodePaths.getZNodeForReplica(replicaId), data);<a name="line.458"></a>
-<span class="sourceLineNo">459</span>    } catch(KeeperException.NoNodeException nne) {<a name="line.459"></a>
-<span class="sourceLineNo">460</span>      if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {<a name="line.460"></a>
-<span class="sourceLineNo">461</span>        LOG.debug("META region location doesn't exist, create it");<a name="line.461"></a>
-<span class="sourceLineNo">462</span>      } else {<a name="line.462"></a>
-<span class="sourceLineNo">463</span>        LOG.debug("META region location doesn't exist for replicaId=" + replicaId +<a name="line.463"></a>
-<span class="sourceLineNo">464</span>            ", create it");<a name="line.464"></a>
-<span class="sourceLineNo">465</span>      }<a name="line.465"></a>
-<span class="sourceLineNo">466</span>      ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);<a name="line.466"></a>
-<span class="sourceLineNo">467</span>    }<a name="line.467"></a>
-<span class="sourceLineNo">468</span>  }<a name="line.468"></a>
-<span class="sourceLineNo">469</span><a name="line.469"></a>
-<span class="sourceLineNo">470</span>  /**<a name="line.470"></a>
-<span class="sourceLineNo">471</span>   * Load the meta region state from the meta server ZNode.<a name="line.471"></a>
-<span class="sourceLineNo">472</span>   */<a name="line.472"></a>
-<span class="sourceLineNo">473</span>  public static RegionState getMetaRegionState(ZKWatcher zkw) throws KeeperException {<a name="line.473"></a>
-<span class="sourceLineNo">474</span>    return getMetaRegionState(zkw, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.474"></a>
-<span class="sourceLineNo">475</span>  }<a name="line.475"></a>
-<span class="sourceLineNo">476</span><a name="line.476"></a>
-<span class="sourceLineNo">477</span>  /**<a name="line.477"></a>
-<span class="sourceLineNo">478</span>   * Load the meta region state from the meta server ZNode.<a name="line.478"></a>
-<span class="sourceLineNo">479</span>   * @param zkw<a name="line.479"></a>
-<span class="sourceLineNo">480</span>   * @param replicaId<a name="line.480"></a>
-<span class="sourceLineNo">481</span>   * @return regionstate<a name="line.481"></a>
-<span class="sourceLineNo">482</span>   * @throws KeeperException<a name="line.482"></a>
-<span class="sourceLineNo">483</span>   */<a name="line.483"></a>
-<span class="sourceLineNo">484</span>  public static RegionState getMetaRegionState(ZKWatcher zkw, int replicaId)<a name="line.484"></a>
-<span class="sourceLineNo">485</span>      throws KeeperException {<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    RegionState.State state = RegionState.State.OPEN;<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    ServerName serverName = null;<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    try {<a name="line.488"></a>
-<span class="sourceLineNo">489</span>      byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId));<a name="line.489"></a>
-<span class="sourceLineNo">490</span>      if (data != null &amp;&amp; data.length &gt; 0 &amp;&amp; ProtobufUtil.isPBMagicPrefix(data)) {<a name="line.490"></a>
-<span class="sourceLineNo">491</span>        try {<a name="line.491"></a>
-<span class="sourceLineNo">492</span>          int prefixLen = ProtobufUtil.lengthOfPBMagic();<a name="line.492"></a>
-<span class="sourceLineNo">493</span>          ZooKeeperProtos.MetaRegionServer rl =<a name="line.493"></a>
-<span class="sourceLineNo">494</span>            ZooKeeperProtos.MetaRegionServer.PARSER.parseFrom<a name="line.494"></a>
-<span class="sourceLineNo">495</span>              (data, prefixLen, data.length - prefixLen);<a name="line.495"></a>
-<span class="sourceLineNo">496</span>          if (rl.hasState()) {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>            state = RegionState.State.convert(rl.getState());<a name="line.497"></a>
-<span class="sourceLineNo">498</span>          }<a name="line.498"></a>
-<span class="sourceLineNo">499</span>          HBaseProtos.ServerName sn = rl.getServer();<a name="line.499"></a>
-<span class="sourceLineNo">500</span>          serverName = ServerName.valueOf(<a name="line.500"></a>
-<span class="sourceLineNo">501</span>            sn.getHostName(), sn.getPort(), sn.getStartCode());<a name="line.501"></a>
-<span class="sourceLineNo">502</span>        } catch (InvalidProtocolBufferException e) {<a name="line.502"></a>
-<span class="sourceLineNo">503</span>          throw new DeserializationException("Unable to parse meta region location");<a name="line.503"></a>
-<span class="sourceLineNo">504</span>        }<a name="line.504"></a>
-<span class="sourceLineNo">505</span>      } else {<a name="line.505"></a>
-<span class="sourceLineNo">506</span>        // old style of meta region location?<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        serverName = ProtobufUtil.parseServerNameFrom(data);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
-<span class="sourceLineNo">509</span>    } catch (DeserializationException e) {<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      throw ZKUtil.convert(e);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>    } catch (InterruptedException e) {<a name="line.511"></a>
-<span class="sourceLineNo">512</span>      Thread.currentThread().interrupt();<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    }<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    if (serverName == null) {<a name="line.514"></a>
-<span class="sourceLineNo">515</span>      state = RegionState.State.OFFLINE;<a name="line.515"></a>
-<span class="sourceLineNo">516</span>    }<a name="line.516"></a>
-<span class="sourceLineNo">517</span>    return new RegionState(<a name="line.517"></a>
-<span class="sourceLineNo">518</span>        RegionReplicaUtil.getRegionInfoForReplica(<a name="line.518"></a>
-<span class="sourceLineNo">519</span>            RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId),<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        state, serverName);<a name="line.520"></a>
-<span class="sourceLineNo">521</span>  }<a name="line.521"></a>
-<span class="sourceLineNo">522</span><a name="line.522"></a>
-<span class="sourceLineNo">523</span>  /**<a name="line.523"></a>
-<span class="sourceLineNo">524</span>   * Deletes the location of &lt;code&gt;hbase:meta&lt;/code&gt; in ZooKeeper.<a name="line.524"></a>
-<span class="sourceLineNo">525</span>   * @param zookeeper zookeeper reference<a name="line.525"></a>
-<span class="sourceLineNo">526</span>   * @throws KeeperException unexpected zookeeper exception<a name="line.526"></a>
-<span class="sourceLineNo">527</span>   */<a name="line.527"></a>
-<span class="sourceLineNo">528</span>  public void deleteMetaLocation(ZKWatcher zookeeper)<a name="line.528"></a>
-<span class="sourceLineNo">529</span>  throws KeeperException {<a name="line.529"></a>
-<span class="sourceLineNo">530</span>    deleteMetaLocation(zookeeper, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>  }<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>  public void deleteMetaLocation(ZKWatcher zookeeper, int replicaId)<a name="line.533"></a>
-<span class="sourceLineNo">534</span>  throws KeeperException {<a name="line.534"></a>
-<span class="sourceLineNo">535</span>    if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {<a name="line.535"></a>
-<span class="sourceLineNo">536</span>      LOG.info("Deleting hbase:meta region location in ZooKeeper");<a name="line.536"></a>
-<span class="sourceLineNo">537</span>    } else {<a name="line.537"></a>
-<span class="sourceLineNo">538</span>      LOG.info("Deleting hbase:meta for " + replicaId + " region location in ZooKeeper");<a name="line.538"></a>
-<span class="sourceLineNo">539</span>    }<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    try {<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      // Just delete the node.  Don't need any watches.<a name="line.541"></a>
-<span class="sourceLineNo">542</span>      ZKUtil.deleteNode(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId));<a name="line.542"></a>
-<span class="sourceLineNo">543</span>    } catch(KeeperException.NoNodeException nne) {<a name="line.543"></a>
-<span class="sourceLineNo">544</span>      // Has already been deleted<a name="line.544"></a>
-<span class="sourceLineNo">545</span>    }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>  }<a name="line.546"></a>
-<span class="sourceLineNo">547</span>  /**<a name="line.547"></a>
-<span class="sourceLineNo">548</span>   * Wait until the primary meta region is available. Get the secondary<a name="line.548"></a>
-<span class="sourceLineNo">549</span>   * locations as well but don't block for those.<a name="line.549"></a>
-<span class="sourceLineNo">550</span>   * @param zkw<a name="line.550"></a>
-<span class="sourceLineNo">551</span>   * @param timeout<a name="line.551"></a>
-<span class="sourceLineNo">552</span>   * @param conf<a name="line.552"></a>
-<span class="sourceLineNo">553</span>   * @return ServerName or null if we timed out.<a name="line.553"></a>
-<span class="sourceLineNo">554</span>   * @throws InterruptedException<a name="line.554"></a>
-<span class="sourceLineNo">555</span>   */<a name="line.555"></a>
-<span class="sourceLineNo">556</span>  public List&lt;ServerName&gt; blockUntilAvailable(final ZKWatcher zkw,<a name="line.556"></a>
-<span class="sourceLineNo">557</span>      final long timeout, Configuration conf)<a name="line.557"></a>
-<span class="sourceLineNo">558</span>          throws InterruptedException {<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    int numReplicasConfigured = 1;<a name="line.559"></a>
-<span class="sourceLineNo">560</span><a name="line.560"></a>
-<span class="sourceLineNo">561</span>    List&lt;ServerName&gt; servers = new ArrayList&lt;&gt;();<a name="line.561"></a>
-<span class="sourceLineNo">562</span>    // Make the blocking call first so that we do the wait to know<a name="line.562"></a>
-<span class="sourceLineNo">563</span>    // the znodes are all in place or timeout.<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    ServerName server = blockUntilAvailable(zkw, timeout);<a name="line.564"></a>
-<span class="sourceLineNo">565</span>    if (server == null) return null;<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    servers.add(server);<a name="line.566"></a>
+<span class="sourceLineNo">226</span>    if (sn == null) {<a name="line.226"></a>
+<span class="sourceLineNo">227</span>      throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");<a name="line.227"></a>
+<span class="sourceLineNo">228</span>    }<a name="line.228"></a>
+<span class="sourceLineNo">229</span><a name="line.229"></a>
+<span class="sourceLineNo">230</span>    return sn;<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>  /**<a name="line.233"></a>
+<span class="sourceLineNo">234</span>   * Waits indefinitely for availability of &lt;code&gt;hbase:meta&lt;/code&gt;.  Used during<a name="line.234"></a>
+<span class="sourceLineNo">235</span>   * cluster startup.  Does not verify meta, just that something has been<a name="line.235"></a>
+<span class="sourceLineNo">236</span>   * set up in zk.<a name="line.236"></a>
+<span class="sourceLineNo">237</span>   * @see #waitMetaRegionLocation(ZKWatcher, long)<a name="line.237"></a>
+<span class="sourceLineNo">238</span>   * @throws InterruptedException if interrupted while waiting<a name="line.238"></a>
+<span class="sourceLineNo">239</span>   */<a name="line.239"></a>
+<span class="sourceLineNo">240</span>  public void waitMetaRegionLocation(ZKWatcher zkw) throws InterruptedException {<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    long startTime = System.currentTimeMillis();<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    while (!stopped) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      try {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>        if (waitMetaRegionLocation(zkw, 100) != null) {<a name="line.244"></a>
+<span class="sourceLineNo">245</span>          break;<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>        long sleepTime = System.currentTimeMillis() - startTime;<a name="line.248"></a>
+<span class="sourceLineNo">249</span>        // +1 in case sleepTime=0<a name="line.249"></a>
+<span class="sourceLineNo">250</span>        if ((sleepTime + 1) % 10000 == 0) {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>          LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");<a name="line.251"></a>
+<span class="sourceLineNo">252</span>        }<a name="line.252"></a>
+<span class="sourceLineNo">253</span>      } catch (NotAllMetaRegionsOnlineException e) {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>        if (LOG.isTraceEnabled()) {<a name="line.254"></a>
+<span class="sourceLineNo">255</span>          LOG.trace("hbase:meta still not available, sleeping and retrying." +<a name="line.255"></a>
+<span class="sourceLineNo">256</span>            " Reason: " + e.getMessage());<a name="line.256"></a>
+<span class="sourceLineNo">257</span>        }<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>  }<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>   * Verify &lt;code&gt;hbase:meta&lt;/code&gt; is deployed and accessible.<a name="line.263"></a>
+<span class="sourceLineNo">264</span>   *<a name="line.264"></a>
+<span class="sourceLineNo">265</span>   * @param hConnection the connection to use<a name="line.265"></a>
+<span class="sourceLineNo">266</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.266"></a>
+<span class="sourceLineNo">267</span>   * @param timeout How long to wait on zk for meta address (passed through to<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   *                the internal call to {@link #getMetaServerConnection}.<a name="line.268"></a>
+<span class="sourceLineNo">269</span>   * @return True if the &lt;code&gt;hbase:meta&lt;/code&gt; location is healthy.<a name="line.269"></a>
+<span class="sourceLineNo">270</span>   * @throws IOException if the number of retries for getting the connection is exceeded<a name="line.270"></a>
+<span class="sourceLineNo">271</span>   * @throws InterruptedException if waiting for the socket operation fails<a name="line.271"></a>
+<span class="sourceLineNo">272</span>   */<a name="line.272"></a>
+<span class="sourceLineNo">273</span>  public boolean verifyMetaRegionLocation(ClusterConnection hConnection, ZKWatcher zkw,<a name="line.273"></a>
+<span class="sourceLineNo">274</span>      final long timeout) throws InterruptedException, IOException {<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    return verifyMetaRegionLocation(hConnection, zkw, timeout, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.275"></a>
+<span class="sourceLineNo">276</span>  }<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>   * Verify &lt;code&gt;hbase:meta&lt;/code&gt; is deployed and accessible.<a name="line.279"></a>
+<span class="sourceLineNo">280</span>   *<a name="line.280"></a>
+<span class="sourceLineNo">281</span>   * @param connection the connection to use<a name="line.281"></a>
+<span class="sourceLineNo">282</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.282"></a>
+<span class="sourceLineNo">283</span>   * @param timeout How long to wait on zk for meta address (passed through to<a name="line.283"></a>
+<span class="sourceLineNo">284</span>   * @param replicaId the ID of the replica<a name="line.284"></a>
+<span class="sourceLineNo">285</span>   * @return True if the &lt;code&gt;hbase:meta&lt;/code&gt; location is healthy.<a name="line.285"></a>
+<span class="sourceLineNo">286</span>   * @throws InterruptedException if waiting for the socket operation fails<a name="line.286"></a>
+<span class="sourceLineNo">287</span>   * @throws IOException if the number of retries for getting the connection is exceeded<a name="line.287"></a>
+<span class="sourceLineNo">288</span>   */<a name="line.288"></a>
+<span class="sourceLineNo">289</span>  public boolean verifyMetaRegionLocation(ClusterConnection connection, ZKWatcher zkw,<a name="line.289"></a>
+<span class="sourceLineNo">290</span>      final long timeout, int replicaId) throws InterruptedException, IOException {<a name="line.290"></a>
+<span class="sourceLineNo">291</span>    AdminProtos.AdminService.BlockingInterface service = null;<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    try {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>      service = getMetaServerConnection(connection, zkw, timeout, replicaId);<a name="line.293"></a>
+<span class="sourceLineNo">294</span>    } catch (NotAllMetaRegionsOnlineException e) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>      // Pass<a name="line.295"></a>
+<span class="sourceLineNo">296</span>    } catch (ServerNotRunningYetException e) {<a name="line.296"></a>
+<span class="sourceLineNo">297</span>      // Pass -- remote server is not up so can't be carrying root<a name="line.297"></a>
+<span class="sourceLineNo">298</span>    } catch (UnknownHostException e) {<a name="line.298"></a>
+<span class="sourceLineNo">299</span>      // Pass -- server name doesn't resolve so it can't be assigned anything.<a name="line.299"></a>
+<span class="sourceLineNo">300</span>    } catch (RegionServerStoppedException e) {<a name="line.300"></a>
+<span class="sourceLineNo">301</span>      // Pass -- server name sends us to a server that is dying or already dead.<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    }<a name="line.302"></a>
+<span class="sourceLineNo">303</span>    return (service != null) &amp;&amp; verifyRegionLocation(connection, service,<a name="line.303"></a>
+<span class="sourceLineNo">304</span>            getMetaRegionLocation(zkw, replicaId), RegionReplicaUtil.getRegionInfoForReplica(<a name="line.304"></a>
+<span class="sourceLineNo">305</span>                RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId).getRegionName());<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>  /**<a name="line.308"></a>
+<span class="sourceLineNo">309</span>   * Verify we can connect to &lt;code&gt;hostingServer&lt;/code&gt; and that its carrying<a name="line.309"></a>
+<span class="sourceLineNo">310</span>   * &lt;code&gt;regionName&lt;/code&gt;.<a name="line.310"></a>
+<span class="sourceLineNo">311</span>   * @param hostingServer Interface to the server hosting &lt;code&gt;regionName&lt;/code&gt;<a name="line.311"></a>
+<span class="sourceLineNo">312</span>   * @param address The servername that goes with the &lt;code&gt;metaServer&lt;/code&gt; interface.<a name="line.312"></a>
+<span class="sourceLineNo">313</span>   *                Used logging.<a name="line.313"></a>
+<span class="sourceLineNo">314</span>   * @param regionName The regionname we are interested in.<a name="line.314"></a>
+<span class="sourceLineNo">315</span>   * @return True if we were able to verify the region located at other side of the interface.<a name="line.315"></a>
+<span class="sourceLineNo">316</span>   */<a name="line.316"></a>
+<span class="sourceLineNo">317</span>  // TODO: We should be able to get the ServerName from the AdminProtocol<a name="line.317"></a>
+<span class="sourceLineNo">318</span>  // rather than have to pass it in.  Its made awkward by the fact that the<a name="line.318"></a>
+<span class="sourceLineNo">319</span>  // HRI is likely a proxy against remote server so the getServerName needs<a name="line.319"></a>
+<span class="sourceLineNo">320</span>  // to be fixed to go to a local method or to a cache before we can do this.<a name="line.320"></a>
+<span class="sourceLineNo">321</span>  private boolean verifyRegionLocation(final ClusterConnection connection,<a name="line.321"></a>
+<span class="sourceLineNo">322</span>      AdminService.BlockingInterface hostingServer, final ServerName address,<a name="line.322"></a>
+<span class="sourceLineNo">323</span>      final byte [] regionName) {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>    if (hostingServer == null) {<a name="line.324"></a>
+<span class="sourceLineNo">325</span>      LOG.info("Passed hostingServer is null");<a name="line.325"></a>
+<span class="sourceLineNo">326</span>      return false;<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    }<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    Throwable t;<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    HBaseRpcController controller = connection.getRpcControllerFactory().newController();<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    try {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      // Try and get regioninfo from the hosting server.<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      return ProtobufUtil.getRegionInfo(controller, hostingServer, regionName) != null;<a name="line.332"></a>
+<span class="sourceLineNo">333</span>    } catch (ConnectException e) {<a name="line.333"></a>
+<span class="sourceLineNo">334</span>      t = e;<a name="line.334"></a>
+<span class="sourceLineNo">335</span>    } catch (RetriesExhaustedException e) {<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      t = e;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>    } catch (RemoteException e) {<a name="line.337"></a>
+<span class="sourceLineNo">338</span>      IOException ioe = e.unwrapRemoteException();<a name="line.338"></a>
+<span class="sourceLineNo">339</span>      t = ioe;<a name="line.339"></a>
+<span class="sourceLineNo">340</span>    } catch (IOException e) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      Throwable cause = e.getCause();<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      if (cause != null &amp;&amp; cause instanceof EOFException) {<a name="line.342"></a>
+<span class="sourceLineNo">343</span>        t = cause;<a name="line.343"></a>
+<span class="sourceLineNo">344</span>      } else if (cause != null &amp;&amp; cause.getMessage() != null<a name="line.344"></a>
+<span class="sourceLineNo">345</span>          &amp;&amp; cause.getMessage().contains("Connection reset")) {<a name="line.345"></a>
+<span class="sourceLineNo">346</span>        t = cause;<a name="line.346"></a>
+<span class="sourceLineNo">347</span>      } else {<a name="line.347"></a>
+<span class="sourceLineNo">348</span>        t = e;<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>    LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) +<a name="line.351"></a>
+<span class="sourceLineNo">352</span>      " at address=" + address + ", exception=" + t.getMessage());<a name="line.352"></a>
+<span class="sourceLineNo">353</span>    return false;<a name="line.353"></a>
+<span class="sourceLineNo">354</span>  }<a name="line.354"></a>
+<span class="sourceLineNo">355</span><a name="line.355"></a>
+<span class="sourceLineNo">356</span>  /**<a name="line.356"></a>
+<span class="sourceLineNo">357</span>   * Gets a connection to the server hosting meta, as reported by ZooKeeper, waiting up to the<a name="line.357"></a>
+<span class="sourceLineNo">358</span>   * specified timeout for availability.<a name="line.358"></a>
+<span class="sourceLineNo">359</span>   *<a name="line.359"></a>
+<span class="sourceLineNo">360</span>   * &lt;p&gt;WARNING: Does not retry.  Use an {@link org.apache.hadoop.hbase.client.HTable} instead.<a name="line.360"></a>
+<span class="sourceLineNo">361</span>   *<a name="line.361"></a>
+<span class="sourceLineNo">362</span>   * @param connection the connection to use<a name="line.362"></a>
+<span class="sourceLineNo">363</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.363"></a>
+<span class="sourceLineNo">364</span>   * @param timeout How long to wait on meta location<a name="line.364"></a>
+<span class="sourceLineNo">365</span>   * @param replicaId the ID of the replica<a name="line.365"></a>
+<span class="sourceLineNo">366</span>   * @return connection to server hosting meta<a name="line.366"></a>
+<span class="sourceLineNo">367</span>   * @throws InterruptedException if waiting for the socket operation fails<a name="line.367"></a>
+<span class="sourceLineNo">368</span>   * @throws IOException if the number of retries for getting the connection is exceeded<a name="line.368"></a>
+<span class="sourceLineNo">369</span>   */<a name="line.369"></a>
+<span class="sourceLineNo">370</span>  private AdminService.BlockingInterface getMetaServerConnection(ClusterConnection connection,<a name="line.370"></a>
+<span class="sourceLineNo">371</span>      ZKWatcher zkw, long timeout, int replicaId) throws InterruptedException, IOException {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>    return getCachedConnection(connection, waitMetaRegionLocation(zkw, replicaId, timeout));<a name="line.372"></a>
+<span class="sourceLineNo">373</span>  }<a name="line.373"></a>
+<span class="sourceLineNo">374</span><a name="line.374"></a>
+<span class="sourceLineNo">375</span>  /**<a name="line.375"></a>
+<span class="sourceLineNo">376</span>   * @param sn ServerName to get a connection against.<a name="line.376"></a>
+<span class="sourceLineNo">377</span>   * @return The AdminProtocol we got when we connected to &lt;code&gt;sn&lt;/code&gt;<a name="line.377"></a>
+<span class="sourceLineNo">378</span>   *         May have come from cache, may not be good, may have been setup by this invocation, or<a name="line.378"></a>
+<span class="sourceLineNo">379</span>   *         may be null.<a name="line.379"></a>
+<span class="sourceLineNo">380</span>   * @throws IOException if the number of retries for getting the connection is exceeded<a name="line.380"></a>
+<span class="sourceLineNo">381</span>   */<a name="line.381"></a>
+<span class="sourceLineNo">382</span>  private static AdminService.BlockingInterface getCachedConnection(ClusterConnection connection,<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      ServerName sn) throws IOException {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>    if (sn == null) {<a name="line.384"></a>
+<span class="sourceLineNo">385</span>      return null;<a name="line.385"></a>
+<span class="sourceLineNo">386</span>    }<a name="line.386"></a>
+<span class="sourceLineNo">387</span>    AdminService.BlockingInterface service = null;<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    try {<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      service = connection.getAdmin(sn);<a name="line.389"></a>
+<span class="sourceLineNo">390</span>    } catch (RetriesExhaustedException e) {<a name="line.390"></a>
+<span class="sourceLineNo">391</span>      if (e.getCause() != null &amp;&amp; e.getCause() instanceof ConnectException) {<a name="line.391"></a>
+<span class="sourceLineNo">392</span>        // Catch this; presume it means the cached connection has gone bad.<a name="line.392"></a>
+<span class="sourceLineNo">393</span>      } else {<a name="line.393"></a>
+<span class="sourceLineNo">394</span>        throw e;<a name="line.394"></a>
+<span class="sourceLineNo">395</span>      }<a name="line.395"></a>
+<span class="sourceLineNo">396</span>    } catch (SocketTimeoutException e) {<a name="line.396"></a>
+<span class="sourceLineNo">397</span>      LOG.debug("Timed out connecting to " + sn);<a name="line.397"></a>
+<span class="sourceLineNo">398</span>    } catch (NoRouteToHostException e) {<a name="line.398"></a>
+<span class="sourceLineNo">399</span>      LOG.debug("Connecting to " + sn, e);<a name="line.399"></a>
+<span class="sourceLineNo">400</span>    } catch (SocketException e) {<a name="line.400"></a>
+<span class="sourceLineNo">401</span>      LOG.debug("Exception connecting to " + sn);<a name="line.401"></a>
+<span class="sourceLineNo">402</span>    } catch (UnknownHostException e) {<a name="line.402"></a>
+<span class="sourceLineNo">403</span>      LOG.debug("Unknown host exception connecting to  " + sn);<a name="line.403"></a>
+<span class="sourceLineNo">404</span>    } catch (FailedServerException e) {<a name="line.404"></a>
+<span class="sourceLineNo">405</span>      if (LOG.isDebugEnabled()) {<a name="line.405"></a>
+<span class="sourceLineNo">406</span>        LOG.debug("Server " + sn + " is in failed server list.");<a name="line.406"></a>
+<span class="sourceLineNo">407</span>      }<a name="line.407"></a>
+<span class="sourceLineNo">408</span>    } catch (IOException ioe) {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>      Throwable cause = ioe.getCause();<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      if (ioe instanceof ConnectException) {<a name="line.410"></a>
+<span class="sourceLineNo">411</span>        // Catch. Connect refused.<a name="line.411"></a>
+<span class="sourceLineNo">412</span>      } else if (cause != null &amp;&amp; cause instanceof EOFException) {<a name="line.412"></a>
+<span class="sourceLineNo">413</span>        // Catch. Other end disconnected us.<a name="line.413"></a>
+<span class="sourceLineNo">414</span>      } else if (cause != null &amp;&amp; cause.getMessage() != null &amp;&amp;<a name="line.414"></a>
+<span class="sourceLineNo">415</span>        cause.getMessage().toLowerCase(Locale.ROOT).contains("connection reset")) {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>        // Catch. Connection reset.<a name="line.416"></a>
+<span class="sourceLineNo">417</span>      } else {<a name="line.417"></a>
+<span class="sourceLineNo">418</span>        throw ioe;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>      }<a name="line.419"></a>
+<span class="sourceLineNo">420</span><a name="line.420"></a>
+<span class="sourceLineNo">421</span>    }<a name="line.421"></a>
+<span class="sourceLineNo">422</span>    return service;<a name="line.422"></a>
+<span class="sourceLineNo">423</span>  }<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>  /**<a name="line.425"></a>
+<span class="sourceLineNo">426</span>   * Sets the location of &lt;code&gt;hbase:meta&lt;/code&gt; in ZooKeeper to the<a name="line.426"></a>
+<span class="sourceLineNo">427</span>   * specified server address.<a name="line.427"></a>
+<span class="sourceLineNo">428</span>   * @param zookeeper zookeeper reference<a name="line.428"></a>
+<span class="sourceLineNo">429</span>   * @param serverName The server hosting &lt;code&gt;hbase:meta&lt;/code&gt;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>   * @param state The region transition state<a name="line.430"></a>
+<span class="sourceLineNo">431</span>   * @throws KeeperException unexpected zookeeper exception<a name="line.431"></a>
+<span class="sourceLineNo">432</span>   */<a name="line.432"></a>
+<span class="sourceLineNo">433</span>  public static void setMetaLocation(ZKWatcher zookeeper,<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      ServerName serverName, RegionState.State state) throws KeeperException {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    setMetaLocation(zookeeper, serverName, RegionInfo.DEFAULT_REPLICA_ID, state);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
+<span class="sourceLineNo">437</span><a name="line.437"></a>
+<span class="sourceLineNo">438</span>  /**<a name="line.438"></a>
+<span class="sourceLineNo">439</span>   * Sets the location of &lt;code&gt;hbase:meta&lt;/code&gt; in ZooKeeper to the specified server address.<a name="line.439"></a>
+<span class="sourceLineNo">440</span>   * @param zookeeper reference to the {@link ZKWatcher} which also contains configuration and<a name="line.440"></a>
+<span class="sourceLineNo">441</span>   *                  operation<a name="line.441"></a>
+<span class="sourceLineNo">442</span>   * @param serverName the name of the server<a name="line.442"></a>
+<span class="sourceLineNo">443</span>   * @param replicaId the ID of the replica<a name="line.443"></a>
+<span class="sourceLineNo">444</span>   * @param state the state of the region<a name="line.444"></a>
+<span class="sourceLineNo">445</span>   * @throws KeeperException if a ZooKeeper operation fails<a name="line.445"></a>
+<span class="sourceLineNo">446</span>   */<a name="line.446"></a>
+<span class="sourceLineNo">447</span>  public static void setMetaLocation(ZKWatcher zookeeper, ServerName serverName, int replicaId,<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      RegionState.State state) throws KeeperException {<a name="line.448"></a>
+<span class="sourceLineNo">449</span>    if (serverName == null) {<a name="line.449"></a>
+<span class="sourceLineNo">450</span>      LOG.warn("Tried to set null ServerName in hbase:meta; skipping -- ServerName required");<a name="line.450"></a>
+<span class="sourceLineNo">451</span>      return;<a name="line.451"></a>
+<span class="sourceLineNo">452</span>    }<a name="line.452"></a>
+<span class="sourceLineNo">453</span>    LOG.info("Setting hbase:meta (replicaId=" + replicaId + ") location in ZooKeeper as " +<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      serverName);<a name="line.454"></a>
+<span class="sourceLineNo">455</span>    // Make the MetaRegionServer pb and then get its bytes and save this as<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    // the znode content.<a name="line.456"></a>
+<span class="sourceLineNo">457</span>    MetaRegionServer pbrsr = MetaRegionServer.newBuilder()<a name="line.457"></a>
+<span class="sourceLineNo">458</span>      .setServer(ProtobufUtil.toServerName(serverName))<a name="line.458"></a>
+<span class="sourceLineNo">459</span>      .setRpcVersion(HConstants.RPC_CURRENT_VERSION)<a name="line.459"></a>
+<span class="sourceLineNo">460</span>      .setState(state.convert()).build();<a name="line.460"></a>
+<span class="sourceLineNo">461</span>    byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray());<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    try {<a name="line.462"></a>
+<span class="sourceLineNo">463</span>      ZKUtil.setData(zookeeper,<a name="line.463"></a>
+<span class="sourceLineNo">464</span>          zookeeper.znodePaths.getZNodeForReplica(replicaId), data);<a name="line.464"></a>
+<span class="sourceLineNo">465</span>    } catch(KeeperException.NoNodeException nne) {<a name="line.465"></a>
+<span class="sourceLineNo">466</span>      if (replicaId == RegionInfo.DEFAULT_REPLICA_ID) {<a name="line.466"></a>
+<span class="sourceLineNo">467</span>        LOG.debug("META region location doesn't exist, create it");<a name="line.467"></a>
+<span class="sourceLineNo">468</span>      } else {<a name="line.468"></a>
+<span class="sourceLineNo">469</span>        LOG.debug("META region location doesn't exist for replicaId=" + replicaId +<a name="line.469"></a>
+<span class="sourceLineNo">470</span>            ", create it");<a name="line.470"></a>
+<span class="sourceLineNo">471</span>      }<a name="line.471"></a>
+<span class="sourceLineNo">472</span>      ZKUtil.createAndWatch(zookeeper, zookeeper.znodePaths.getZNodeForReplica(replicaId), data);<a name="line.472"></a>
+<span class="sourceLineNo">473</span>    }<a name="line.473"></a>
+<span class="sourceLineNo">474</span>  }<a name="line.474"></a>
+<span class="sourceLineNo">475</span><a name="line.475"></a>
+<span class="sourceLineNo">476</span>  /**<a name="line.476"></a>
+<span class="sourceLineNo">477</span>   * Load the meta region state from the meta server ZNode.<a name="line.477"></a>
+<span class="sourceLineNo">478</span>   */<a name="line.478"></a>
+<span class="sourceLineNo">479</span>  public static RegionState getMetaRegionState(ZKWatcher zkw) throws KeeperException {<a name="line.479"></a>
+<span class="sourceLineNo">480</span>    return getMetaRegionState(zkw, RegionInfo.DEFAULT_REPLICA_ID);<a name="line.480"></a>
+<span class="sourceLineNo">481</span>  }<a name="line.481"></a>
+<span class="sourceLineNo">482</span><a name="line.482"></a>
+<span class="sourceLineNo">483</span>  /**<a name="line.483"></a>
+<span class="sourceLineNo">484</span>   * Load the meta region state from the meta server ZNode.<a name="line.484"></a>
+<span class="sourceLineNo">485</span>   *<a name="line.485"></a>
+<span class="sourceLineNo">486</span>   * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation<a name="line.486"></a>
+<span class="sourceLineNo">487</span>   * @param replicaId the ID of the replica<a name="line.487"></a>
+<span class="sourceLineNo">488</span>   * @return regionstate<a name="line.488"></a>
+<span class="sourceLineNo">489</span>   * @throws KeeperException if a ZooKeeper operation fails<a name="line.489"></a>
+<span class="sourceLineNo">490</span>   */<a name="line.490"></a>
+<span class="sourceLineNo">491</span>  public static RegionState getMetaRegionState(ZKWatcher zkw, int replicaId)<a name="line.491"></a>
+<span class="sourceLineNo">492</span>          throws KeeperException {<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    RegionState.State state = RegionState.State.OPEN;<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    ServerName serverName = null;<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    try {<a name="line.495"></a>
+<span class="sourceLineNo">496</span>      byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId));<a name="line.496"></a>
+<span class="sourceLineNo">497</span>      if (data != null &amp;&amp; data.length &gt; 0 &amp;&amp; ProtobufUtil.isPBMagicPrefix(data)) {<a name="line.497"></a>
+<span class="sourceLineNo">498</span>        try {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>          int prefixLen = ProtobufUtil.lengthOfPBMagic();<a name="line.499"></a>
+<span class="sourceLineNo">500</span>          ZooKeeperProtos.MetaRegionServer rl =<a name="line.500"></a>
+<span class="sourceLineNo">501</span>            ZooKeeperProtos.MetaRegionServer.PARSER.parseFrom(data, prefixLen,<a name="line.501"></a>
+<span class="sourceLineNo">502</span>                    data.length - prefixLen);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>          if (rl.hasState()) {<a nam

<TRUNCATED>

Mime
View raw message