http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f183e80f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html index e743560..163ade0 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html @@ -2124,1654 +2124,1642 @@ <span class="sourceLineNo">2116</span> return healthy;<a name="line.2116"></a> <span class="sourceLineNo">2117</span> }<a name="line.2117"></a> <span class="sourceLineNo">2118</span><a name="line.2118"></a> -<span class="sourceLineNo">2119</span> private static final byte[] UNSPECIFIED_REGION = new byte[]{};<a name="line.2119"></a> -<span class="sourceLineNo">2120</span><a name="line.2120"></a> -<span class="sourceLineNo">2121</span> @Override<a name="line.2121"></a> -<span class="sourceLineNo">2122</span> public List<WAL> getWALs() throws IOException {<a name="line.2122"></a> -<span class="sourceLineNo">2123</span> return walFactory.getWALs();<a name="line.2123"></a> -<span class="sourceLineNo">2124</span> }<a name="line.2124"></a> -<span class="sourceLineNo">2125</span><a name="line.2125"></a> -<span class="sourceLineNo">2126</span> @Override<a name="line.2126"></a> -<span class="sourceLineNo">2127</span> public WAL getWAL(RegionInfo regionInfo) throws IOException {<a name="line.2127"></a> -<span class="sourceLineNo">2128</span> WAL wal;<a name="line.2128"></a> -<span class="sourceLineNo">2129</span> // _ROOT_ and hbase:meta regions have separate WAL.<a name="line.2129"></a> -<span class="sourceLineNo">2130</span> if (regionInfo != null && regionInfo.isMetaRegion()<a name="line.2130"></a> -<span class="sourceLineNo">2131</span> && regionInfo.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {<a name="line.2131"></a> -<span class="sourceLineNo">2132</span> wal = walFactory.getMetaWAL(regionInfo.getEncodedNameAsBytes());<a name="line.2132"></a> -<span class="sourceLineNo">2133</span> } else if (regionInfo == null) {<a name="line.2133"></a> -<span class="sourceLineNo">2134</span> wal = walFactory.getWAL(UNSPECIFIED_REGION, null);<a name="line.2134"></a> -<span class="sourceLineNo">2135</span> } else {<a name="line.2135"></a> -<span class="sourceLineNo">2136</span> byte[] namespace = regionInfo.getTable().getNamespace();<a name="line.2136"></a> -<span class="sourceLineNo">2137</span> wal = walFactory.getWAL(regionInfo.getEncodedNameAsBytes(), namespace);<a name="line.2137"></a> -<span class="sourceLineNo">2138</span> }<a name="line.2138"></a> -<span class="sourceLineNo">2139</span> if (this.walRoller != null) {<a name="line.2139"></a> -<span class="sourceLineNo">2140</span> this.walRoller.addWAL(wal);<a name="line.2140"></a> -<span class="sourceLineNo">2141</span> }<a name="line.2141"></a> -<span class="sourceLineNo">2142</span> return wal;<a name="line.2142"></a> -<span class="sourceLineNo">2143</span> }<a name="line.2143"></a> -<span class="sourceLineNo">2144</span><a name="line.2144"></a> -<span class="sourceLineNo">2145</span> public LogRoller getWalRoller() {<a name="line.2145"></a> -<span class="sourceLineNo">2146</span> return walRoller;<a name="line.2146"></a> -<span class="sourceLineNo">2147</span> }<a name="line.2147"></a> -<span class="sourceLineNo">2148</span><a name="line.2148"></a> -<span class="sourceLineNo">2149</span> @Override<a name="line.2149"></a> -<span class="sourceLineNo">2150</span> public Connection getConnection() {<a name="line.2150"></a> -<span class="sourceLineNo">2151</span> return getClusterConnection();<a name="line.2151"></a> -<span class="sourceLineNo">2152</span> }<a name="line.2152"></a> -<span class="sourceLineNo">2153</span><a name="line.2153"></a> -<span class="sourceLineNo">2154</span> @Override<a name="line.2154"></a> -<span class="sourceLineNo">2155</span> public ClusterConnection getClusterConnection() {<a name="line.2155"></a> -<span class="sourceLineNo">2156</span> return this.clusterConnection;<a name="line.2156"></a> -<span class="sourceLineNo">2157</span> }<a name="line.2157"></a> -<span class="sourceLineNo">2158</span><a name="line.2158"></a> -<span class="sourceLineNo">2159</span> @Override<a name="line.2159"></a> -<span class="sourceLineNo">2160</span> public MetaTableLocator getMetaTableLocator() {<a name="line.2160"></a> -<span class="sourceLineNo">2161</span> return this.metaTableLocator;<a name="line.2161"></a> -<span class="sourceLineNo">2162</span> }<a name="line.2162"></a> -<span class="sourceLineNo">2163</span><a name="line.2163"></a> -<span class="sourceLineNo">2164</span> @Override<a name="line.2164"></a> -<span class="sourceLineNo">2165</span> public void stop(final String msg) {<a name="line.2165"></a> -<span class="sourceLineNo">2166</span> stop(msg, false, RpcServer.getRequestUser().orElse(null));<a name="line.2166"></a> -<span class="sourceLineNo">2167</span> }<a name="line.2167"></a> -<span class="sourceLineNo">2168</span><a name="line.2168"></a> -<span class="sourceLineNo">2169</span> /**<a name="line.2169"></a> -<span class="sourceLineNo">2170</span> * Stops the regionserver.<a name="line.2170"></a> -<span class="sourceLineNo">2171</span> * @param msg Status message<a name="line.2171"></a> -<span class="sourceLineNo">2172</span> * @param force True if this is a regionserver abort<a name="line.2172"></a> -<span class="sourceLineNo">2173</span> * @param user The user executing the stop request, or null if no user is associated<a name="line.2173"></a> -<span class="sourceLineNo">2174</span> */<a name="line.2174"></a> -<span class="sourceLineNo">2175</span> public void stop(final String msg, final boolean force, final User user) {<a name="line.2175"></a> -<span class="sourceLineNo">2176</span> if (!this.stopped) {<a name="line.2176"></a> -<span class="sourceLineNo">2177</span> LOG.info("***** STOPPING region server '" + this + "' *****");<a name="line.2177"></a> -<span class="sourceLineNo">2178</span> if (this.rsHost != null) {<a name="line.2178"></a> -<span class="sourceLineNo">2179</span> // when forced via abort don't allow CPs to override<a name="line.2179"></a> -<span class="sourceLineNo">2180</span> try {<a name="line.2180"></a> -<span class="sourceLineNo">2181</span> this.rsHost.preStop(msg, user);<a name="line.2181"></a> -<span class="sourceLineNo">2182</span> } catch (IOException ioe) {<a name="line.2182"></a> -<span class="sourceLineNo">2183</span> if (!force) {<a name="line.2183"></a> -<span class="sourceLineNo">2184</span> LOG.warn("The region server did not stop", ioe);<a name="line.2184"></a> -<span class="sourceLineNo">2185</span> return;<a name="line.2185"></a> -<span class="sourceLineNo">2186</span> }<a name="line.2186"></a> -<span class="sourceLineNo">2187</span> LOG.warn("Skipping coprocessor exception on preStop() due to forced shutdown", ioe);<a name="line.2187"></a> -<span class="sourceLineNo">2188</span> }<a name="line.2188"></a> -<span class="sourceLineNo">2189</span> }<a name="line.2189"></a> -<span class="sourceLineNo">2190</span> this.stopped = true;<a name="line.2190"></a> -<span class="sourceLineNo">2191</span> LOG.info("STOPPED: " + msg);<a name="line.2191"></a> -<span class="sourceLineNo">2192</span> // Wakes run() if it is sleeping<a name="line.2192"></a> -<span class="sourceLineNo">2193</span> sleeper.skipSleepCycle();<a name="line.2193"></a> -<span class="sourceLineNo">2194</span> }<a name="line.2194"></a> -<span class="sourceLineNo">2195</span> }<a name="line.2195"></a> -<span class="sourceLineNo">2196</span><a name="line.2196"></a> -<span class="sourceLineNo">2197</span> public void waitForServerOnline(){<a name="line.2197"></a> -<span class="sourceLineNo">2198</span> while (!isStopped() && !isOnline()) {<a name="line.2198"></a> -<span class="sourceLineNo">2199</span> synchronized (online) {<a name="line.2199"></a> -<span class="sourceLineNo">2200</span> try {<a name="line.2200"></a> -<span class="sourceLineNo">2201</span> online.wait(msgInterval);<a name="line.2201"></a> -<span class="sourceLineNo">2202</span> } catch (InterruptedException ie) {<a name="line.2202"></a> -<span class="sourceLineNo">2203</span> Thread.currentThread().interrupt();<a name="line.2203"></a> -<span class="sourceLineNo">2204</span> break;<a name="line.2204"></a> -<span class="sourceLineNo">2205</span> }<a name="line.2205"></a> -<span class="sourceLineNo">2206</span> }<a name="line.2206"></a> -<span class="sourceLineNo">2207</span> }<a name="line.2207"></a> -<span class="sourceLineNo">2208</span> }<a name="line.2208"></a> -<span class="sourceLineNo">2209</span><a name="line.2209"></a> -<span class="sourceLineNo">2210</span> @Override<a name="line.2210"></a> -<span class="sourceLineNo">2211</span> public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.2211"></a> -<span class="sourceLineNo">2212</span> throws KeeperException, IOException {<a name="line.2212"></a> -<span class="sourceLineNo">2213</span> HRegion r = context.getRegion();<a name="line.2213"></a> -<span class="sourceLineNo">2214</span> long masterSystemTime = context.getMasterSystemTime();<a name="line.2214"></a> -<span class="sourceLineNo">2215</span> rpcServices.checkOpen();<a name="line.2215"></a> -<span class="sourceLineNo">2216</span> LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2216"></a> -<span class="sourceLineNo">2217</span> // Do checks to see if we need to compact (references or too many files)<a name="line.2217"></a> -<span class="sourceLineNo">2218</span> for (HStore s : r.stores.values()) {<a name="line.2218"></a> -<span class="sourceLineNo">2219</span> if (s.hasReferences() || s.needsCompaction()) {<a name="line.2219"></a> -<span class="sourceLineNo">2220</span> this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.2220"></a> -<span class="sourceLineNo">2221</span> }<a name="line.2221"></a> -<span class="sourceLineNo">2222</span> }<a name="line.2222"></a> -<span class="sourceLineNo">2223</span> long openSeqNum = r.getOpenSeqNum();<a name="line.2223"></a> -<span class="sourceLineNo">2224</span> if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.2224"></a> -<span class="sourceLineNo">2225</span> // If we opened a region, we should have read some sequence number from it.<a name="line.2225"></a> -<span class="sourceLineNo">2226</span> LOG.error("No sequence number found when opening " +<a name="line.2226"></a> -<span class="sourceLineNo">2227</span> r.getRegionInfo().getRegionNameAsString());<a name="line.2227"></a> -<span class="sourceLineNo">2228</span> openSeqNum = 0;<a name="line.2228"></a> -<span class="sourceLineNo">2229</span> }<a name="line.2229"></a> +<span class="sourceLineNo">2119</span> @Override<a name="line.2119"></a> +<span class="sourceLineNo">2120</span> public List<WAL> getWALs() throws IOException {<a name="line.2120"></a> +<span class="sourceLineNo">2121</span> return walFactory.getWALs();<a name="line.2121"></a> +<span class="sourceLineNo">2122</span> }<a name="line.2122"></a> +<span class="sourceLineNo">2123</span><a name="line.2123"></a> +<span class="sourceLineNo">2124</span> @Override<a name="line.2124"></a> +<span class="sourceLineNo">2125</span> public WAL getWAL(RegionInfo regionInfo) throws IOException {<a name="line.2125"></a> +<span class="sourceLineNo">2126</span> WAL wal = walFactory.getWAL(regionInfo);<a name="line.2126"></a> +<span class="sourceLineNo">2127</span> if (this.walRoller != null) {<a name="line.2127"></a> +<span class="sourceLineNo">2128</span> this.walRoller.addWAL(wal);<a name="line.2128"></a> +<span class="sourceLineNo">2129</span> }<a name="line.2129"></a> +<span class="sourceLineNo">2130</span> return wal;<a name="line.2130"></a> +<span class="sourceLineNo">2131</span> }<a name="line.2131"></a> +<span class="sourceLineNo">2132</span><a name="line.2132"></a> +<span class="sourceLineNo">2133</span> public LogRoller getWalRoller() {<a name="line.2133"></a> +<span class="sourceLineNo">2134</span> return walRoller;<a name="line.2134"></a> +<span class="sourceLineNo">2135</span> }<a name="line.2135"></a> +<span class="sourceLineNo">2136</span><a name="line.2136"></a> +<span class="sourceLineNo">2137</span> @Override<a name="line.2137"></a> +<span class="sourceLineNo">2138</span> public Connection getConnection() {<a name="line.2138"></a> +<span class="sourceLineNo">2139</span> return getClusterConnection();<a name="line.2139"></a> +<span class="sourceLineNo">2140</span> }<a name="line.2140"></a> +<span class="sourceLineNo">2141</span><a name="line.2141"></a> +<span class="sourceLineNo">2142</span> @Override<a name="line.2142"></a> +<span class="sourceLineNo">2143</span> public ClusterConnection getClusterConnection() {<a name="line.2143"></a> +<span class="sourceLineNo">2144</span> return this.clusterConnection;<a name="line.2144"></a> +<span class="sourceLineNo">2145</span> }<a name="line.2145"></a> +<span class="sourceLineNo">2146</span><a name="line.2146"></a> +<span class="sourceLineNo">2147</span> @Override<a name="line.2147"></a> +<span class="sourceLineNo">2148</span> public MetaTableLocator getMetaTableLocator() {<a name="line.2148"></a> +<span class="sourceLineNo">2149</span> return this.metaTableLocator;<a name="line.2149"></a> +<span class="sourceLineNo">2150</span> }<a name="line.2150"></a> +<span class="sourceLineNo">2151</span><a name="line.2151"></a> +<span class="sourceLineNo">2152</span> @Override<a name="line.2152"></a> +<span class="sourceLineNo">2153</span> public void stop(final String msg) {<a name="line.2153"></a> +<span class="sourceLineNo">2154</span> stop(msg, false, RpcServer.getRequestUser().orElse(null));<a name="line.2154"></a> +<span class="sourceLineNo">2155</span> }<a name="line.2155"></a> +<span class="sourceLineNo">2156</span><a name="line.2156"></a> +<span class="sourceLineNo">2157</span> /**<a name="line.2157"></a> +<span class="sourceLineNo">2158</span> * Stops the regionserver.<a name="line.2158"></a> +<span class="sourceLineNo">2159</span> * @param msg Status message<a name="line.2159"></a> +<span class="sourceLineNo">2160</span> * @param force True if this is a regionserver abort<a name="line.2160"></a> +<span class="sourceLineNo">2161</span> * @param user The user executing the stop request, or null if no user is associated<a name="line.2161"></a> +<span class="sourceLineNo">2162</span> */<a name="line.2162"></a> +<span class="sourceLineNo">2163</span> public void stop(final String msg, final boolean force, final User user) {<a name="line.2163"></a> +<span class="sourceLineNo">2164</span> if (!this.stopped) {<a name="line.2164"></a> +<span class="sourceLineNo">2165</span> LOG.info("***** STOPPING region server '" + this + "' *****");<a name="line.2165"></a> +<span class="sourceLineNo">2166</span> if (this.rsHost != null) {<a name="line.2166"></a> +<span class="sourceLineNo">2167</span> // when forced via abort don't allow CPs to override<a name="line.2167"></a> +<span class="sourceLineNo">2168</span> try {<a name="line.2168"></a> +<span class="sourceLineNo">2169</span> this.rsHost.preStop(msg, user);<a name="line.2169"></a> +<span class="sourceLineNo">2170</span> } catch (IOException ioe) {<a name="line.2170"></a> +<span class="sourceLineNo">2171</span> if (!force) {<a name="line.2171"></a> +<span class="sourceLineNo">2172</span> LOG.warn("The region server did not stop", ioe);<a name="line.2172"></a> +<span class="sourceLineNo">2173</span> return;<a name="line.2173"></a> +<span class="sourceLineNo">2174</span> }<a name="line.2174"></a> +<span class="sourceLineNo">2175</span> LOG.warn("Skipping coprocessor exception on preStop() due to forced shutdown", ioe);<a name="line.2175"></a> +<span class="sourceLineNo">2176</span> }<a name="line.2176"></a> +<span class="sourceLineNo">2177</span> }<a name="line.2177"></a> +<span class="sourceLineNo">2178</span> this.stopped = true;<a name="line.2178"></a> +<span class="sourceLineNo">2179</span> LOG.info("STOPPED: " + msg);<a name="line.2179"></a> +<span class="sourceLineNo">2180</span> // Wakes run() if it is sleeping<a name="line.2180"></a> +<span class="sourceLineNo">2181</span> sleeper.skipSleepCycle();<a name="line.2181"></a> +<span class="sourceLineNo">2182</span> }<a name="line.2182"></a> +<span class="sourceLineNo">2183</span> }<a name="line.2183"></a> +<span class="sourceLineNo">2184</span><a name="line.2184"></a> +<span class="sourceLineNo">2185</span> public void waitForServerOnline(){<a name="line.2185"></a> +<span class="sourceLineNo">2186</span> while (!isStopped() && !isOnline()) {<a name="line.2186"></a> +<span class="sourceLineNo">2187</span> synchronized (online) {<a name="line.2187"></a> +<span class="sourceLineNo">2188</span> try {<a name="line.2188"></a> +<span class="sourceLineNo">2189</span> online.wait(msgInterval);<a name="line.2189"></a> +<span class="sourceLineNo">2190</span> } catch (InterruptedException ie) {<a name="line.2190"></a> +<span class="sourceLineNo">2191</span> Thread.currentThread().interrupt();<a name="line.2191"></a> +<span class="sourceLineNo">2192</span> break;<a name="line.2192"></a> +<span class="sourceLineNo">2193</span> }<a name="line.2193"></a> +<span class="sourceLineNo">2194</span> }<a name="line.2194"></a> +<span class="sourceLineNo">2195</span> }<a name="line.2195"></a> +<span class="sourceLineNo">2196</span> }<a name="line.2196"></a> +<span class="sourceLineNo">2197</span><a name="line.2197"></a> +<span class="sourceLineNo">2198</span> @Override<a name="line.2198"></a> +<span class="sourceLineNo">2199</span> public void postOpenDeployTasks(final PostOpenDeployContext context)<a name="line.2199"></a> +<span class="sourceLineNo">2200</span> throws KeeperException, IOException {<a name="line.2200"></a> +<span class="sourceLineNo">2201</span> HRegion r = context.getRegion();<a name="line.2201"></a> +<span class="sourceLineNo">2202</span> long masterSystemTime = context.getMasterSystemTime();<a name="line.2202"></a> +<span class="sourceLineNo">2203</span> rpcServices.checkOpen();<a name="line.2203"></a> +<span class="sourceLineNo">2204</span> LOG.info("Post open deploy tasks for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2204"></a> +<span class="sourceLineNo">2205</span> // Do checks to see if we need to compact (references or too many files)<a name="line.2205"></a> +<span class="sourceLineNo">2206</span> for (HStore s : r.stores.values()) {<a name="line.2206"></a> +<span class="sourceLineNo">2207</span> if (s.hasReferences() || s.needsCompaction()) {<a name="line.2207"></a> +<span class="sourceLineNo">2208</span> this.compactSplitThread.requestSystemCompaction(r, s, "Opening Region");<a name="line.2208"></a> +<span class="sourceLineNo">2209</span> }<a name="line.2209"></a> +<span class="sourceLineNo">2210</span> }<a name="line.2210"></a> +<span class="sourceLineNo">2211</span> long openSeqNum = r.getOpenSeqNum();<a name="line.2211"></a> +<span class="sourceLineNo">2212</span> if (openSeqNum == HConstants.NO_SEQNUM) {<a name="line.2212"></a> +<span class="sourceLineNo">2213</span> // If we opened a region, we should have read some sequence number from it.<a name="line.2213"></a> +<span class="sourceLineNo">2214</span> LOG.error("No sequence number found when opening " +<a name="line.2214"></a> +<span class="sourceLineNo">2215</span> r.getRegionInfo().getRegionNameAsString());<a name="line.2215"></a> +<span class="sourceLineNo">2216</span> openSeqNum = 0;<a name="line.2216"></a> +<span class="sourceLineNo">2217</span> }<a name="line.2217"></a> +<span class="sourceLineNo">2218</span><a name="line.2218"></a> +<span class="sourceLineNo">2219</span> // Notify master<a name="line.2219"></a> +<span class="sourceLineNo">2220</span> if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.2220"></a> +<span class="sourceLineNo">2221</span> TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.2221"></a> +<span class="sourceLineNo">2222</span> throw new IOException("Failed to report opened region to master: "<a name="line.2222"></a> +<span class="sourceLineNo">2223</span> + r.getRegionInfo().getRegionNameAsString());<a name="line.2223"></a> +<span class="sourceLineNo">2224</span> }<a name="line.2224"></a> +<span class="sourceLineNo">2225</span><a name="line.2225"></a> +<span class="sourceLineNo">2226</span> triggerFlushInPrimaryRegion(r);<a name="line.2226"></a> +<span class="sourceLineNo">2227</span><a name="line.2227"></a> +<span class="sourceLineNo">2228</span> LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2228"></a> +<span class="sourceLineNo">2229</span> }<a name="line.2229"></a> <span class="sourceLineNo">2230</span><a name="line.2230"></a> -<span class="sourceLineNo">2231</span> // Notify master<a name="line.2231"></a> -<span class="sourceLineNo">2232</span> if (!reportRegionStateTransition(new RegionStateTransitionContext(<a name="line.2232"></a> -<span class="sourceLineNo">2233</span> TransitionCode.OPENED, openSeqNum, masterSystemTime, r.getRegionInfo()))) {<a name="line.2233"></a> -<span class="sourceLineNo">2234</span> throw new IOException("Failed to report opened region to master: "<a name="line.2234"></a> -<span class="sourceLineNo">2235</span> + r.getRegionInfo().getRegionNameAsString());<a name="line.2235"></a> -<span class="sourceLineNo">2236</span> }<a name="line.2236"></a> +<span class="sourceLineNo">2231</span> @Override<a name="line.2231"></a> +<span class="sourceLineNo">2232</span> public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.2232"></a> +<span class="sourceLineNo">2233</span> TransitionCode code = context.getCode();<a name="line.2233"></a> +<span class="sourceLineNo">2234</span> long openSeqNum = context.getOpenSeqNum();<a name="line.2234"></a> +<span class="sourceLineNo">2235</span> long masterSystemTime = context.getMasterSystemTime();<a name="line.2235"></a> +<span class="sourceLineNo">2236</span> RegionInfo[] hris = context.getHris();<a name="line.2236"></a> <span class="sourceLineNo">2237</span><a name="line.2237"></a> -<span class="sourceLineNo">2238</span> triggerFlushInPrimaryRegion(r);<a name="line.2238"></a> -<span class="sourceLineNo">2239</span><a name="line.2239"></a> -<span class="sourceLineNo">2240</span> LOG.debug("Finished post open deploy task for " + r.getRegionInfo().getRegionNameAsString());<a name="line.2240"></a> -<span class="sourceLineNo">2241</span> }<a name="line.2241"></a> -<span class="sourceLineNo">2242</span><a name="line.2242"></a> -<span class="sourceLineNo">2243</span> @Override<a name="line.2243"></a> -<span class="sourceLineNo">2244</span> public boolean reportRegionStateTransition(final RegionStateTransitionContext context) {<a name="line.2244"></a> -<span class="sourceLineNo">2245</span> TransitionCode code = context.getCode();<a name="line.2245"></a> -<span class="sourceLineNo">2246</span> long openSeqNum = context.getOpenSeqNum();<a name="line.2246"></a> -<span class="sourceLineNo">2247</span> long masterSystemTime = context.getMasterSystemTime();<a name="line.2247"></a> -<span class="sourceLineNo">2248</span> RegionInfo[] hris = context.getHris();<a name="line.2248"></a> -<span class="sourceLineNo">2249</span><a name="line.2249"></a> -<span class="sourceLineNo">2250</span> if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.2250"></a> -<span class="sourceLineNo">2251</span> // This is for testing only in case there is no master<a name="line.2251"></a> -<span class="sourceLineNo">2252</span> // to handle the region transition report at all.<a name="line.2252"></a> -<span class="sourceLineNo">2253</span> if (code == TransitionCode.OPENED) {<a name="line.2253"></a> -<span class="sourceLineNo">2254</span> Preconditions.checkArgument(hris != null && hris.length == 1);<a name="line.2254"></a> -<span class="sourceLineNo">2255</span> if (hris[0].isMetaRegion()) {<a name="line.2255"></a> -<span class="sourceLineNo">2256</span> try {<a name="line.2256"></a> -<span class="sourceLineNo">2257</span> MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.2257"></a> -<span class="sourceLineNo">2258</span> hris[0].getReplicaId(),State.OPEN);<a name="line.2258"></a> -<span class="sourceLineNo">2259</span> } catch (KeeperException e) {<a name="line.2259"></a> -<span class="sourceLineNo">2260</span> LOG.info("Failed to update meta location", e);<a name="line.2260"></a> -<span class="sourceLineNo">2261</span> return false;<a name="line.2261"></a> -<span class="sourceLineNo">2262</span> }<a name="line.2262"></a> -<span class="sourceLineNo">2263</span> } else {<a name="line.2263"></a> -<span class="sourceLineNo">2264</span> try {<a name="line.2264"></a> -<span class="sourceLineNo">2265</span> MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.2265"></a> -<span class="sourceLineNo">2266</span> hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.2266"></a> -<span class="sourceLineNo">2267</span> } catch (IOException e) {<a name="line.2267"></a> -<span class="sourceLineNo">2268</span> LOG.info("Failed to update meta", e);<a name="line.2268"></a> -<span class="sourceLineNo">2269</span> return false;<a name="line.2269"></a> -<span class="sourceLineNo">2270</span> }<a name="line.2270"></a> -<span class="sourceLineNo">2271</span> }<a name="line.2271"></a> -<span class="sourceLineNo">2272</span> }<a name="line.2272"></a> -<span class="sourceLineNo">2273</span> return true;<a name="line.2273"></a> +<span class="sourceLineNo">2238</span> if (TEST_SKIP_REPORTING_TRANSITION) {<a name="line.2238"></a> +<span class="sourceLineNo">2239</span> // This is for testing only in case there is no master<a name="line.2239"></a> +<span class="sourceLineNo">2240</span> // to handle the region transition report at all.<a name="line.2240"></a> +<span class="sourceLineNo">2241</span> if (code == TransitionCode.OPENED) {<a name="line.2241"></a> +<span class="sourceLineNo">2242</span> Preconditions.checkArgument(hris != null && hris.length == 1);<a name="line.2242"></a> +<span class="sourceLineNo">2243</span> if (hris[0].isMetaRegion()) {<a name="line.2243"></a> +<span class="sourceLineNo">2244</span> try {<a name="line.2244"></a> +<span class="sourceLineNo">2245</span> MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,<a name="line.2245"></a> +<span class="sourceLineNo">2246</span> hris[0].getReplicaId(),State.OPEN);<a name="line.2246"></a> +<span class="sourceLineNo">2247</span> } catch (KeeperException e) {<a name="line.2247"></a> +<span class="sourceLineNo">2248</span> LOG.info("Failed to update meta location", e);<a name="line.2248"></a> +<span class="sourceLineNo">2249</span> return false;<a name="line.2249"></a> +<span class="sourceLineNo">2250</span> }<a name="line.2250"></a> +<span class="sourceLineNo">2251</span> } else {<a name="line.2251"></a> +<span class="sourceLineNo">2252</span> try {<a name="line.2252"></a> +<span class="sourceLineNo">2253</span> MetaTableAccessor.updateRegionLocation(clusterConnection,<a name="line.2253"></a> +<span class="sourceLineNo">2254</span> hris[0], serverName, openSeqNum, masterSystemTime);<a name="line.2254"></a> +<span class="sourceLineNo">2255</span> } catch (IOException e) {<a name="line.2255"></a> +<span class="sourceLineNo">2256</span> LOG.info("Failed to update meta", e);<a name="line.2256"></a> +<span class="sourceLineNo">2257</span> return false;<a name="line.2257"></a> +<span class="sourceLineNo">2258</span> }<a name="line.2258"></a> +<span class="sourceLineNo">2259</span> }<a name="line.2259"></a> +<span class="sourceLineNo">2260</span> }<a name="line.2260"></a> +<span class="sourceLineNo">2261</span> return true;<a name="line.2261"></a> +<span class="sourceLineNo">2262</span> }<a name="line.2262"></a> +<span class="sourceLineNo">2263</span><a name="line.2263"></a> +<span class="sourceLineNo">2264</span> ReportRegionStateTransitionRequest.Builder builder =<a name="line.2264"></a> +<span class="sourceLineNo">2265</span> ReportRegionStateTransitionRequest.newBuilder();<a name="line.2265"></a> +<span class="sourceLineNo">2266</span> builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.2266"></a> +<span class="sourceLineNo">2267</span> RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.2267"></a> +<span class="sourceLineNo">2268</span> transition.setTransitionCode(code);<a name="line.2268"></a> +<span class="sourceLineNo">2269</span> if (code == TransitionCode.OPENED && openSeqNum >= 0) {<a name="line.2269"></a> +<span class="sourceLineNo">2270</span> transition.setOpenSeqNum(openSeqNum);<a name="line.2270"></a> +<span class="sourceLineNo">2271</span> }<a name="line.2271"></a> +<span class="sourceLineNo">2272</span> for (RegionInfo hri: hris) {<a name="line.2272"></a> +<span class="sourceLineNo">2273</span> transition.addRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.2273"></a> <span class="sourceLineNo">2274</span> }<a name="line.2274"></a> -<span class="sourceLineNo">2275</span><a name="line.2275"></a> -<span class="sourceLineNo">2276</span> ReportRegionStateTransitionRequest.Builder builder =<a name="line.2276"></a> -<span class="sourceLineNo">2277</span> ReportRegionStateTransitionRequest.newBuilder();<a name="line.2277"></a> -<span class="sourceLineNo">2278</span> builder.setServer(ProtobufUtil.toServerName(serverName));<a name="line.2278"></a> -<span class="sourceLineNo">2279</span> RegionStateTransition.Builder transition = builder.addTransitionBuilder();<a name="line.2279"></a> -<span class="sourceLineNo">2280</span> transition.setTransitionCode(code);<a name="line.2280"></a> -<span class="sourceLineNo">2281</span> if (code == TransitionCode.OPENED && openSeqNum >= 0) {<a name="line.2281"></a> -<span class="sourceLineNo">2282</span> transition.setOpenSeqNum(openSeqNum);<a name="line.2282"></a> -<span class="sourceLineNo">2283</span> }<a name="line.2283"></a> -<span class="sourceLineNo">2284</span> for (RegionInfo hri: hris) {<a name="line.2284"></a> -<span class="sourceLineNo">2285</span> transition.addRegionInfo(ProtobufUtil.toRegionInfo(hri));<a name="line.2285"></a> -<span class="sourceLineNo">2286</span> }<a name="line.2286"></a> -<span class="sourceLineNo">2287</span> ReportRegionStateTransitionRequest request = builder.build();<a name="line.2287"></a> -<span class="sourceLineNo">2288</span> int tries = 0;<a name="line.2288"></a> -<span class="sourceLineNo">2289</span> long pauseTime = INIT_PAUSE_TIME_MS;<a name="line.2289"></a> -<span class="sourceLineNo">2290</span> // Keep looping till we get an error. We want to send reports even though server is going down.<a name="line.2290"></a> -<span class="sourceLineNo">2291</span> // Only go down if clusterConnection is null. It is set to null almost as last thing as the<a name="line.2291"></a> -<span class="sourceLineNo">2292</span> // HRegionServer does down.<a name="line.2292"></a> -<span class="sourceLineNo">2293</span> while (this.clusterConnection != null && !this.clusterConnection.isClosed()) {<a name="line.2293"></a> -<span class="sourceLineNo">2294</span> RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2294"></a> -<span class="sourceLineNo">2295</span> try {<a name="line.2295"></a> -<span class="sourceLineNo">2296</span> if (rss == null) {<a name="line.2296"></a> -<span class="sourceLineNo">2297</span> createRegionServerStatusStub();<a name="line.2297"></a> -<span class="sourceLineNo">2298</span> continue;<a name="line.2298"></a> -<span class="sourceLineNo">2299</span> }<a name="line.2299"></a> -<span class="sourceLineNo">2300</span> ReportRegionStateTransitionResponse response =<a name="line.2300"></a> -<span class="sourceLineNo">2301</span> rss.reportRegionStateTransition(null, request);<a name="line.2301"></a> -<span class="sourceLineNo">2302</span> if (response.hasErrorMessage()) {<a name="line.2302"></a> -<span class="sourceLineNo">2303</span> LOG.info("TRANSITION FAILED " + request + ": " + response.getErrorMessage());<a name="line.2303"></a> -<span class="sourceLineNo">2304</span> break;<a name="line.2304"></a> -<span class="sourceLineNo">2305</span> }<a name="line.2305"></a> -<span class="sourceLineNo">2306</span> // Log if we had to retry else don't log unless TRACE. We want to<a name="line.2306"></a> -<span class="sourceLineNo">2307</span> // know if were successful after an attempt showed in logs as failed.<a name="line.2307"></a> -<span class="sourceLineNo">2308</span> if (tries > 0 || LOG.isTraceEnabled()) {<a name="line.2308"></a> -<span class="sourceLineNo">2309</span> LOG.info("TRANSITION REPORTED " + request);<a name="line.2309"></a> +<span class="sourceLineNo">2275</span> ReportRegionStateTransitionRequest request = builder.build();<a name="line.2275"></a> +<span class="sourceLineNo">2276</span> int tries = 0;<a name="line.2276"></a> +<span class="sourceLineNo">2277</span> long pauseTime = INIT_PAUSE_TIME_MS;<a name="line.2277"></a> +<span class="sourceLineNo">2278</span> // Keep looping till we get an error. We want to send reports even though server is going down.<a name="line.2278"></a> +<span class="sourceLineNo">2279</span> // Only go down if clusterConnection is null. It is set to null almost as last thing as the<a name="line.2279"></a> +<span class="sourceLineNo">2280</span> // HRegionServer does down.<a name="line.2280"></a> +<span class="sourceLineNo">2281</span> while (this.clusterConnection != null && !this.clusterConnection.isClosed()) {<a name="line.2281"></a> +<span class="sourceLineNo">2282</span> RegionServerStatusService.BlockingInterface rss = rssStub;<a name="line.2282"></a> +<span class="sourceLineNo">2283</span> try {<a name="line.2283"></a> +<span class="sourceLineNo">2284</span> if (rss == null) {<a name="line.2284"></a> +<span class="sourceLineNo">2285</span> createRegionServerStatusStub();<a name="line.2285"></a> +<span class="sourceLineNo">2286</span> continue;<a name="line.2286"></a> +<span class="sourceLineNo">2287</span> }<a name="line.2287"></a> +<span class="sourceLineNo">2288</span> ReportRegionStateTransitionResponse response =<a name="line.2288"></a> +<span class="sourceLineNo">2289</span> rss.reportRegionStateTransition(null, request);<a name="line.2289"></a> +<span class="sourceLineNo">2290</span> if (response.hasErrorMessage()) {<a name="line.2290"></a> +<span class="sourceLineNo">2291</span> LOG.info("TRANSITION FAILED " + request + ": " + response.getErrorMessage());<a name="line.2291"></a> +<span class="sourceLineNo">2292</span> break;<a name="line.2292"></a> +<span class="sourceLineNo">2293</span> }<a name="line.2293"></a> +<span class="sourceLineNo">2294</span> // Log if we had to retry else don't log unless TRACE. We want to<a name="line.2294"></a> +<span class="sourceLineNo">2295</span> // know if were successful after an attempt showed in logs as failed.<a name="line.2295"></a> +<span class="sourceLineNo">2296</span> if (tries > 0 || LOG.isTraceEnabled()) {<a name="line.2296"></a> +<span class="sourceLineNo">2297</span> LOG.info("TRANSITION REPORTED " + request);<a name="line.2297"></a> +<span class="sourceLineNo">2298</span> }<a name="line.2298"></a> +<span class="sourceLineNo">2299</span> // NOTE: Return mid-method!!!<a name="line.2299"></a> +<span class="sourceLineNo">2300</span> return true;<a name="line.2300"></a> +<span class="sourceLineNo">2301</span> } catch (ServiceException se) {<a name="line.2301"></a> +<span class="sourceLineNo">2302</span> IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2302"></a> +<span class="sourceLineNo">2303</span> boolean pause = ioe instanceof ServerNotRunningYetException ||<a name="line.2303"></a> +<span class="sourceLineNo">2304</span> ioe instanceof PleaseHoldException;<a name="line.2304"></a> +<span class="sourceLineNo">2305</span> if (pause) {<a name="line.2305"></a> +<span class="sourceLineNo">2306</span> // Do backoff else we flood the Master with requests.<a name="line.2306"></a> +<span class="sourceLineNo">2307</span> pauseTime = ConnectionUtils.getPauseTime(INIT_PAUSE_TIME_MS, tries);<a name="line.2307"></a> +<span class="sourceLineNo">2308</span> } else {<a name="line.2308"></a> +<span class="sourceLineNo">2309</span> pauseTime = INIT_PAUSE_TIME_MS; // Reset.<a name="line.2309"></a> <span class="sourceLineNo">2310</span> }<a name="line.2310"></a> -<span class="sourceLineNo">2311</span> // NOTE: Return mid-method!!!<a name="line.2311"></a> -<span class="sourceLineNo">2312</span> return true;<a name="line.2312"></a> -<span class="sourceLineNo">2313</span> } catch (ServiceException se) {<a name="line.2313"></a> -<span class="sourceLineNo">2314</span> IOException ioe = ProtobufUtil.getRemoteException(se);<a name="line.2314"></a> -<span class="sourceLineNo">2315</span> boolean pause = ioe instanceof ServerNotRunningYetException ||<a name="line.2315"></a> -<span class="sourceLineNo">2316</span> ioe instanceof PleaseHoldException;<a name="line.2316"></a> -<span class="sourceLineNo">2317</span> if (pause) {<a name="line.2317"></a> -<span class="sourceLineNo">2318</span> // Do backoff else we flood the Master with requests.<a name="line.2318"></a> -<span class="sourceLineNo">2319</span> pauseTime = ConnectionUtils.getPauseTime(INIT_PAUSE_TIME_MS, tries);<a name="line.2319"></a> -<span class="sourceLineNo">2320</span> } else {<a name="line.2320"></a> -<span class="sourceLineNo">2321</span> pauseTime = INIT_PAUSE_TIME_MS; // Reset.<a name="line.2321"></a> -<span class="sourceLineNo">2322</span> }<a name="line.2322"></a> -<span class="sourceLineNo">2323</span> LOG.info("Failed report transition " +<a name="line.2323"></a> -<span class="sourceLineNo">2324</span> TextFormat.shortDebugString(request) + "; retry (#" + tries + ")" +<a name="line.2324"></a> -<span class="sourceLineNo">2325</span> (pause?<a name="line.2325"></a> -<span class="sourceLineNo">2326</span> " after " + pauseTime + "ms delay (Master is coming online...).":<a name="line.2326"></a> -<span class="sourceLineNo">2327</span> " immediately."),<a name="line.2327"></a> -<span class="sourceLineNo">2328</span> ioe);<a name="line.2328"></a> -<span class="sourceLineNo">2329</span> if (pause) Threads.sleep(pauseTime);<a name="line.2329"></a> -<span class="sourceLineNo">2330</span> tries++;<a name="line.2330"></a> -<span class="sourceLineNo">2331</span> if (rssStub == rss) {<a name="line.2331"></a> -<span class="sourceLineNo">2332</span> rssStub = null;<a name="line.2332"></a> -<span class="sourceLineNo">2333</span> }<a name="line.2333"></a> -<span class="sourceLineNo">2334</span> }<a name="line.2334"></a> -<span class="sourceLineNo">2335</span> }<a name="line.2335"></a> -<span class="sourceLineNo">2336</span> return false;<a name="line.2336"></a> -<span class="sourceLineNo">2337</span> }<a name="line.2337"></a> -<span class="sourceLineNo">2338</span><a name="line.2338"></a> -<span class="sourceLineNo">2339</span> /**<a name="line.2339"></a> -<span class="sourceLineNo">2340</span> * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2340"></a> -<span class="sourceLineNo">2341</span> * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2341"></a> -<span class="sourceLineNo">2342</span> */<a name="line.2342"></a> -<span class="sourceLineNo">2343</span> void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2343"></a> -<span class="sourceLineNo">2344</span> if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2344"></a> -<span class="sourceLineNo">2345</span> return;<a name="line.2345"></a> -<span class="sourceLineNo">2346</span> }<a name="line.2346"></a> -<span class="sourceLineNo">2347</span> if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2347"></a> -<span class="sourceLineNo">2348</span> !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2348"></a> -<span class="sourceLineNo">2349</span> region.conf)) {<a name="line.2349"></a> -<span class="sourceLineNo">2350</span> region.setReadsEnabled(true);<a name="line.2350"></a> -<span class="sourceLineNo">2351</span> return;<a name="line.2351"></a> -<span class="sourceLineNo">2352</span> }<a name="line.2352"></a> -<span class="sourceLineNo">2353</span><a name="line.2353"></a> -<span class="sourceLineNo">2354</span> region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2354"></a> -<span class="sourceLineNo">2355</span> // RegionReplicaFlushHandler might reset this.<a name="line.2355"></a> +<span class="sourceLineNo">2311</span> LOG.info("Failed report transition " +<a name="line.2311"></a> +<span class="sourceLineNo">2312</span> TextFormat.shortDebugString(request) + "; retry (#" + tries + ")" +<a name="line.2312"></a> +<span class="sourceLineNo">2313</span> (pause?<a name="line.2313"></a> +<span class="sourceLineNo">2314</span> " after " + pauseTime + "ms delay (Master is coming online...).":<a name="line.2314"></a> +<span class="sourceLineNo">2315</span> " immediately."),<a name="line.2315"></a> +<span class="sourceLineNo">2316</span> ioe);<a name="line.2316"></a> +<span class="sourceLineNo">2317</span> if (pause) Threads.sleep(pauseTime);<a name="line.2317"></a> +<span class="sourceLineNo">2318</span> tries++;<a name="line.2318"></a> +<span class="sourceLineNo">2319</span> if (rssStub == rss) {<a name="line.2319"></a> +<span class="sourceLineNo">2320</span> rssStub = null;<a name="line.2320"></a> +<span class="sourceLineNo">2321</span> }<a name="line.2321"></a> +<span class="sourceLineNo">2322</span> }<a name="line.2322"></a> +<span class="sourceLineNo">2323</span> }<a name="line.2323"></a> +<span class="sourceLineNo">2324</span> return false;<a name="line.2324"></a> +<span class="sourceLineNo">2325</span> }<a name="line.2325"></a> +<span class="sourceLineNo">2326</span><a name="line.2326"></a> +<span class="sourceLineNo">2327</span> /**<a name="line.2327"></a> +<span class="sourceLineNo">2328</span> * Trigger a flush in the primary region replica if this region is a secondary replica. Does not<a name="line.2328"></a> +<span class="sourceLineNo">2329</span> * block this thread. See RegionReplicaFlushHandler for details.<a name="line.2329"></a> +<span class="sourceLineNo">2330</span> */<a name="line.2330"></a> +<span class="sourceLineNo">2331</span> void triggerFlushInPrimaryRegion(final HRegion region) {<a name="line.2331"></a> +<span class="sourceLineNo">2332</span> if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) {<a name="line.2332"></a> +<span class="sourceLineNo">2333</span> return;<a name="line.2333"></a> +<span class="sourceLineNo">2334</span> }<a name="line.2334"></a> +<span class="sourceLineNo">2335</span> if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) ||<a name="line.2335"></a> +<span class="sourceLineNo">2336</span> !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled(<a name="line.2336"></a> +<span class="sourceLineNo">2337</span> region.conf)) {<a name="line.2337"></a> +<span class="sourceLineNo">2338</span> region.setReadsEnabled(true);<a name="line.2338"></a> +<span class="sourceLineNo">2339</span> return;<a name="line.2339"></a> +<span class="sourceLineNo">2340</span> }<a name="line.2340"></a> +<span class="sourceLineNo">2341</span><a name="line.2341"></a> +<span class="sourceLineNo">2342</span> region.setReadsEnabled(false); // disable reads before marking the region as opened.<a name="line.2342"></a> +<span class="sourceLineNo">2343</span> // RegionReplicaFlushHandler might reset this.<a name="line.2343"></a> +<span class="sourceLineNo">2344</span><a name="line.2344"></a> +<span class="sourceLineNo">2345</span> // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2345"></a> +<span class="sourceLineNo">2346</span> if (this.executorService != null) {<a name="line.2346"></a> +<span class="sourceLineNo">2347</span> this.executorService.submit(new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2347"></a> +<span class="sourceLineNo">2348</span> rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2348"></a> +<span class="sourceLineNo">2349</span> }<a name="line.2349"></a> +<span class="sourceLineNo">2350</span> }<a name="line.2350"></a> +<span class="sourceLineNo">2351</span><a name="line.2351"></a> +<span class="sourceLineNo">2352</span> @Override<a name="line.2352"></a> +<span class="sourceLineNo">2353</span> public RpcServerInterface getRpcServer() {<a name="line.2353"></a> +<span class="sourceLineNo">2354</span> return rpcServices.rpcServer;<a name="line.2354"></a> +<span class="sourceLineNo">2355</span> }<a name="line.2355"></a> <span class="sourceLineNo">2356</span><a name="line.2356"></a> -<span class="sourceLineNo">2357</span> // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler<a name="line.2357"></a> -<span class="sourceLineNo">2358</span> if (this.executorService != null) {<a name="line.2358"></a> -<span class="sourceLineNo">2359</span> this.executorService.submit(new RegionReplicaFlushHandler(this, clusterConnection,<a name="line.2359"></a> -<span class="sourceLineNo">2360</span> rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region));<a name="line.2360"></a> -<span class="sourceLineNo">2361</span> }<a name="line.2361"></a> -<span class="sourceLineNo">2362</span> }<a name="line.2362"></a> -<span class="sourceLineNo">2363</span><a name="line.2363"></a> -<span class="sourceLineNo">2364</span> @Override<a name="line.2364"></a> -<span class="sourceLineNo">2365</span> public RpcServerInterface getRpcServer() {<a name="line.2365"></a> -<span class="sourceLineNo">2366</span> return rpcServices.rpcServer;<a name="line.2366"></a> -<span class="sourceLineNo">2367</span> }<a name="line.2367"></a> -<span class="sourceLineNo">2368</span><a name="line.2368"></a> -<span class="sourceLineNo">2369</span> @VisibleForTesting<a name="line.2369"></a> -<span class="sourceLineNo">2370</span> public RSRpcServices getRSRpcServices() {<a name="line.2370"></a> -<span class="sourceLineNo">2371</span> return rpcServices;<a name="line.2371"></a> -<span class="sourceLineNo">2372</span> }<a name="line.2372"></a> -<span class="sourceLineNo">2373</span><a name="line.2373"></a> -<span class="sourceLineNo">2374</span> /**<a name="line.2374"></a> -<span class="sourceLineNo">2375</span> * Cause the server to exit without closing the regions it is serving, the log<a name="line.2375"></a> -<span class="sourceLineNo">2376</span> * it is using and without notifying the master. Used unit testing and on<a name="line.2376"></a> -<span class="sourceLineNo">2377</span> * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2377"></a> -<span class="sourceLineNo">2378</span> *<a name="line.2378"></a> -<span class="sourceLineNo">2379</span> * @param reason<a name="line.2379"></a> -<span class="sourceLineNo">2380</span> * the reason we are aborting<a name="line.2380"></a> -<span class="sourceLineNo">2381</span> * @param cause<a name="line.2381"></a> -<span class="sourceLineNo">2382</span> * the exception that caused the abort, or null<a name="line.2382"></a> -<span class="sourceLineNo">2383</span> */<a name="line.2383"></a> -<span class="sourceLineNo">2384</span> @Override<a name="line.2384"></a> -<span class="sourceLineNo">2385</span> public void abort(String reason, Throwable cause) {<a name="line.2385"></a> -<span class="sourceLineNo">2386</span> String msg = "***** ABORTING region server " + this + ": " + reason + " *****";<a name="line.2386"></a> -<span class="sourceLineNo">2387</span> if (cause != null) {<a name="line.2387"></a> -<span class="sourceLineNo">2388</span> LOG.error(HBaseMarkers.FATAL, msg, cause);<a name="line.2388"></a> -<span class="sourceLineNo">2389</span> } else {<a name="line.2389"></a> -<span class="sourceLineNo">2390</span> LOG.error(HBaseMarkers.FATAL, msg);<a name="line.2390"></a> +<span class="sourceLineNo">2357</span> @VisibleForTesting<a name="line.2357"></a> +<span class="sourceLineNo">2358</span> public RSRpcServices getRSRpcServices() {<a name="line.2358"></a> +<span class="sourceLineNo">2359</span> return rpcServices;<a name="line.2359"></a> +<span class="sourceLineNo">2360</span> }<a name="line.2360"></a> +<span class="sourceLineNo">2361</span><a name="line.2361"></a> +<span class="sourceLineNo">2362</span> /**<a name="line.2362"></a> +<span class="sourceLineNo">2363</span> * Cause the server to exit without closing the regions it is serving, the log<a name="line.2363"></a> +<span class="sourceLineNo">2364</span> * it is using and without notifying the master. Used unit testing and on<a name="line.2364"></a> +<span class="sourceLineNo">2365</span> * catastrophic events such as HDFS is yanked out from under hbase or we OOME.<a name="line.2365"></a> +<span class="sourceLineNo">2366</span> *<a name="line.2366"></a> +<span class="sourceLineNo">2367</span> * @param reason<a name="line.2367"></a> +<span class="sourceLineNo">2368</span> * the reason we are aborting<a name="line.2368"></a> +<span class="sourceLineNo">2369</span> * @param cause<a name="line.2369"></a> +<span class="sourceLineNo">2370</span> * the exception that caused the abort, or null<a name="line.2370"></a> +<span class="sourceLineNo">2371</span> */<a name="line.2371"></a> +<span class="sourceLineNo">2372</span> @Override<a name="line.2372"></a> +<span class="sourceLineNo">2373</span> public void abort(String reason, Throwable cause) {<a name="line.2373"></a> +<span class="sourceLineNo">2374</span> String msg = "***** ABORTING region server " + this + ": " + reason + " *****";<a name="line.2374"></a> +<span class="sourceLineNo">2375</span> if (cause != null) {<a name="line.2375"></a> +<span class="sourceLineNo">2376</span> LOG.error(HBaseMarkers.FATAL, msg, cause);<a name="line.2376"></a> +<span class="sourceLineNo">2377</span> } else {<a name="line.2377"></a> +<span class="sourceLineNo">2378</span> LOG.error(HBaseMarkers.FATAL, msg);<a name="line.2378"></a> +<span class="sourceLineNo">2379</span> }<a name="line.2379"></a> +<span class="sourceLineNo">2380</span> this.abortRequested = true;<a name="line.2380"></a> +<span class="sourceLineNo">2381</span> // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2381"></a> +<span class="sourceLineNo">2382</span> // regionserver crashes.Note that we're implicitly using<a name="line.2382"></a> +<span class="sourceLineNo">2383</span> // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2383"></a> +<span class="sourceLineNo">2384</span> LOG.error(HBaseMarkers.FATAL, "RegionServer abort: loaded coprocessors are: " +<a name="line.2384"></a> +<span class="sourceLineNo">2385</span> CoprocessorHost.getLoadedCoprocessors());<a name="line.2385"></a> +<span class="sourceLineNo">2386</span> // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2386"></a> +<span class="sourceLineNo">2387</span> try {<a name="line.2387"></a> +<span class="sourceLineNo">2388</span> LOG.info("Dump of metrics as JSON on abort: " + DumpRegionServerMetrics.dumpMetrics());<a name="line.2388"></a> +<span class="sourceLineNo">2389</span> } catch (MalformedObjectNameException | IOException e) {<a name="line.2389"></a> +<span class="sourceLineNo">2390</span> LOG.warn("Failed dumping metrics", e);<a name="line.2390"></a> <span class="sourceLineNo">2391</span> }<a name="line.2391"></a> -<span class="sourceLineNo">2392</span> this.abortRequested = true;<a name="line.2392"></a> -<span class="sourceLineNo">2393</span> // HBASE-4014: show list of coprocessors that were loaded to help debug<a name="line.2393"></a> -<span class="sourceLineNo">2394</span> // regionserver crashes.Note that we're implicitly using<a name="line.2394"></a> -<span class="sourceLineNo">2395</span> // java.util.HashSet's toString() method to print the coprocessor names.<a name="line.2395"></a> -<span class="sourceLineNo">2396</span> LOG.error(HBaseMarkers.FATAL, "RegionServer abort: loaded coprocessors are: " +<a name="line.2396"></a> -<span class="sourceLineNo">2397</span> CoprocessorHost.getLoadedCoprocessors());<a name="line.2397"></a> -<span class="sourceLineNo">2398</span> // Try and dump metrics if abort -- might give clue as to how fatal came about....<a name="line.2398"></a> -<span class="sourceLineNo">2399</span> try {<a name="line.2399"></a> -<span class="sourceLineNo">2400</span> LOG.info("Dump of metrics as JSON on abort: " + DumpRegionServerMetrics.dumpMetrics());<a name="line.2400"></a> -<span class="sourceLineNo">2401</span> } catch (MalformedObjectNameException | IOException e) {<a name="line.2401"></a> -<span class="sourceLineNo">2402</span> LOG.warn("Failed dumping metrics", e);<a name="line.2402"></a> -<span class="sourceLineNo">2403</span> }<a name="line.2403"></a> -<span class="sourceLineNo">2404</span><a name="line.2404"></a> -<span class="sourceLineNo">2405</span> // Do our best to report our abort to the master, but this may not work<a name="line.2405"></a> -<span class="sourceLineNo">2406</span> try {<a name="line.2406"></a> -<span class="sourceLineNo">2407</span> if (cause != null) {<a name="line.2407"></a> -<span class="sourceLineNo">2408</span> msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2408"></a> -<span class="sourceLineNo">2409</span> }<a name="line.2409"></a> -<span class="sourceLineNo">2410</span> // Report to the master but only if we have already registered with the master.<a name="line.2410"></a> -<span class="sourceLineNo">2411</span> if (rssStub != null && this.serverName != null) {<a name="line.2411"></a> -<span class="sourceLineNo">2412</span> ReportRSFatalErrorRequest.Builder builder =<a name="line.2412"></a> -<span class="sourceLineNo">2413</span> ReportRSFatalErrorRequest.newBuilder();<a name="line.2413"></a> -<span class="sourceLineNo">2414</span> ServerName sn =<a name="line.2414"></a> -<span class="sourceLineNo">2415</span> ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2415"></a> -<span class="sourceLineNo">2416</span> builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2416"></a> -<span class="sourceLineNo">2417</span> builder.setErrorMessage(msg);<a name="line.2417"></a> -<span class="sourceLineNo">2418</span> rssStub.reportRSFatalError(null, builder.build());<a name="line.2418"></a> -<span class="sourceLineNo">2419</span> }<a name="line.2419"></a> -<span class="sourceLineNo">2420</span> } catch (Throwable t) {<a name="line.2420"></a> -<span class="sourceLineNo">2421</span> LOG.warn("Unable to report fatal error to master", t);<a name="line.2421"></a> -<span class="sourceLineNo">2422</span> }<a name="line.2422"></a> -<span class="sourceLineNo">2423</span> // shutdown should be run as the internal user<a name="line.2423"></a> -<span class="sourceLineNo">2424</span> stop(reason, true, null);<a name="line.2424"></a> +<span class="sourceLineNo">2392</span><a name="line.2392"></a> +<span class="sourceLineNo">2393</span> // Do our best to report our abort to the master, but this may not work<a name="line.2393"></a> +<span class="sourceLineNo">2394</span> try {<a name="line.2394"></a> +<span class="sourceLineNo">2395</span> if (cause != null) {<a name="line.2395"></a> +<span class="sourceLineNo">2396</span> msg += "\nCause:\n" + StringUtils.stringifyException(cause);<a name="line.2396"></a> +<span class="sourceLineNo">2397</span> }<a name="line.2397"></a> +<span class="sourceLineNo">2398</span> // Report to the master but only if we have already registered with the master.<a name="line.2398"></a> +<span class="sourceLineNo">2399</span> if (rssStub != null && this.serverName != null) {<a name="line.2399"></a> +<span class="sourceLineNo">2400</span> ReportRSFatalErrorRequest.Builder builder =<a name="line.2400"></a> +<span class="sourceLineNo">2401</span> ReportRSFatalErrorRequest.newBuilder();<a name="line.2401"></a> +<span class="sourceLineNo">2402</span> ServerName sn =<a name="line.2402"></a> +<span class="sourceLineNo">2403</span> ServerName.parseVersionedServerName(this.serverName.getVersionedBytes());<a name="line.2403"></a> +<span class="sourceLineNo">2404</span> builder.setServer(ProtobufUtil.toServerName(sn));<a name="line.2404"></a> +<span class="sourceLineNo">2405</span> builder.setErrorMessage(msg);<a name="line.2405"></a> +<span class="sourceLineNo">2406</span> rssStub.reportRSFatalError(null, builder.build());<a name="line.2406"></a> +<span class="sourceLineNo">2407</span> }<a name="line.2407"></a> +<span class="sourceLineNo">2408</span> } catch (Throwable t) {<a name="line.2408"></a> +<span class="sourceLineNo">2409</span> LOG.warn("Unable to report fatal error to master", t);<a name="line.2409"></a> +<span class="sourceLineNo">2410</span> }<a name="line.2410"></a> +<span class="sourceLineNo">2411</span> // shutdown should be run as the internal user<a name="line.2411"></a> +<span class="sourceLineNo">2412</span> stop(reason, true, null);<a name="line.2412"></a> +<span class="sourceLineNo">2413</span> }<a name="line.2413"></a> +<span class="sourceLineNo">2414</span><a name="line.2414"></a> +<span class="sourceLineNo">2415</span> /**<a name="line.2415"></a> +<span class="sourceLineNo">2416</span> * @see HRegionServer#abort(String, Throwable)<a name="line.2416"></a> +<span class="sourceLineNo">2417</span> */<a name="line.2417"></a> +<span class="sourceLineNo">2418</span> public void abort(String reason) {<a name="line.2418"></a> +<span class="sourceLineNo">2419</span> abort(reason, null);<a name="line.2419"></a> +<span class="sourceLineNo">2420</span> }<a name="line.2420"></a> +<span class="sourceLineNo">2421</span><a name="line.2421"></a> +<span class="sourceLineNo">2422</span> @Override<a name="line.2422"></a> +<span class="sourceLineNo">2423</span> public boolean isAborted() {<a name="line.2423"></a> +<span class="sourceLineNo">2424</span> return this.abortRequested;<a name="line.2424"></a> <span class="sourceLineNo">2425</span> }<a name="line.2425"></a> <span class="sourceLineNo">2426</span><a name="line.2426"></a> -<span class="sourceLineNo">2427</span> /**<a name="line.2427"></a> -<span class="sourceLineNo">2428</span> * @see HRegionServer#abort(String, Throwable)<a name="line.2428"></a> -<span class="sourceLineNo">2429</span> */<a name="line.2429"></a> -<span class="sourceLineNo">2430</span> public void abort(String reason) {<a name="line.2430"></a> -<span class="sourceLineNo">2431</span> abort(reason, null);<a name="line.2431"></a> -<span class="sourceLineNo">2432</span> }<a name="line.2432"></a> -<span class="sourceLineNo">2433</span><a name="line.2433"></a> -<span class="sourceLineNo">2434</span> @Override<a name="line.2434"></a> -<span class="sourceLineNo">2435</span> public boolean isAborted() {<a name="line.2435"></a> -<span class="sourceLineNo">2436</span> return this.abortRequested;<a name="line.2436"></a> -<span class="sourceLineNo">2437</span> }<a name="line.2437"></a> -<span class="sourceLineNo">2438</span><a name="line.2438"></a> -<span class="sourceLineNo">2439</span> /*<a name="line.2439"></a> -<span class="sourceLineNo">2440</span> * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2440"></a> -<span class="sourceLineNo">2441</span> * logs but it does close socket in case want to bring up server on old<a name="line.2441"></a> -<span class="sourceLineNo">2442</span> * hostname+port immediately.<a name="line.2442"></a> -<span class="sourceLineNo">2443</span> */<a name="line.2443"></a> -<span class="sourceLineNo">2444</span> @VisibleForTesting<a name="line.2444"></a> -<span class="sourceLineNo">2445</span> protected void kill() {<a name="line.2445"></a> -<span class="sourceLineNo">2446</span> this.killed = true;<a name="line.2446"></a> -<span class="sourceLineNo">2447</span> abort("Simulated kill");<a name="line.2447"></a> -<span class="sourceLineNo">2448</span> }<a name="line.2448"></a> -<span class="sourceLineNo">2449</span><a name="line.2449"></a> -<span class="sourceLineNo">2450</span> /**<a name="line.2450"></a> -<span class="sourceLineNo">2451</span> * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2451"></a> -<span class="sourceLineNo">2452</span> */<a name="line.2452"></a> -<span class="sourceLineNo">2453</span> protected void sendShutdownInterrupt() {<a name="line.2453"></a> -<span class="sourceLineNo">2454</span> }<a name="line.2454"></a> -<span class="sourceLineNo">2455</span><a name="line.2455"></a> -<span class="sourceLineNo">2456</span> /**<a name="line.2456"></a> -<span class="sourceLineNo">2457</span> * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2457"></a> -<span class="sourceLineNo">2458</span> * have already been called.<a name="line.2458"></a> -<span class="sourceLineNo">2459</span> */<a name="line.2459"></a> -<span class="sourceLineNo">2460</span> protected void stopServiceThreads() {<a name="line.2460"></a> -<span class="sourceLineNo">2461</span> // clean up the scheduled chores<a name="line.2461"></a> -<span class="sourceLineNo">2462</span> if (this.choreService != null) choreService.shutdown();<a name="line.2462"></a> -<span class="sourceLineNo">2463</span> if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2463"></a> -<span class="sourceLineNo">2464</span> if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2464"></a> -<span class="sourceLineNo">2465</span> if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2465"></a> -<span class="sourceLineNo">2466</span> if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2466"></a> -<span class="sourceLineNo">2467</span> if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2467"></a> -<span class="sourceLineNo">2468</span> if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2468"></a> -<span class="sourceLineNo">2469</span> if (this.fsUtilizationChore != null) fsUtilizationChore.cancel(true);<a name="line.2469"></a> -<span class="sourceLineNo">2470</span><a name="line.2470"></a> -<span class="sourceLineNo">2471</span> if (this.cacheFlusher != null) {<a name="line.2471"></a> -<span class="sourceLineNo">2472</span> this.cacheFlusher.join();<a name="line.2472"></a> -<span class="sourceLineNo">2473</span> }<a name="line.2473"></a> -<span class="sourceLineNo">2474</span><a name="line.2474"></a> -<span class="sourceLineNo">2475</span> if (this.spanReceiverHost != null) {<a name="line.2475"></a> -<span class="sourceLineNo">2476</span> this.spanReceiverHost.closeReceivers();<a name="line.2476"></a> -<span class="sourceLineNo">2477</span> }<a name="line.2477"></a> -<span class="sourceLineNo">2478</span> if (this.walRoller != null) {<a name="line.2478"></a> -<span class="sourceLineNo">2479</span> this.walRoller.close();<a name="line.2479"></a> -<span class="sourceLineNo">2480</span> }<a name="line.2480"></a> -<span class="sourceLineNo">2481</span> if (this.compactSplitThread != null) {<a name="line.2481"></a> -<span class="sourceLineNo">2482</span> this.compactSplitThread.join();<a name="line.2482"></a> +<span class="sourceLineNo">2427</span> /*<a name="line.2427"></a> +<span class="sourceLineNo">2428</span> * Simulate a kill -9 of this server. Exits w/o closing regions or cleaninup<a name="line.2428"></a> +<span class="sourceLineNo">2429</span> * logs but it does close socket in case want to bring up server on old<a name="line.2429"></a> +<span class="sourceLineNo">2430</span> * hostname+port immediately.<a name="line.2430"></a> +<span class="sourceLineNo">2431</span> */<a name="line.2431"></a> +<span class="sourceLineNo">2432</span> @VisibleForTesting<a name="line.2432"></a> +<span class="sourceLineNo">2433</span> protected void kill() {<a name="line.2433"></a> +<span class="sourceLineNo">2434</span> this.killed = true;<a name="line.2434"></a> +<span class="sourceLineNo">2435</span> abort("Simulated kill");<a name="line.2435"></a> +<span class="sourceLineNo">2436</span> }<a name="line.2436"></a> +<span class="sourceLineNo">2437</span><a name="line.2437"></a> +<span class="sourceLineNo">2438</span> /**<a name="line.2438"></a> +<span class="sourceLineNo">2439</span> * Called on stop/abort before closing the cluster connection and meta locator.<a name="line.2439"></a> +<span class="sourceLineNo">2440</span> */<a name="line.2440"></a> +<span class="sourceLineNo">2441</span> protected void sendShutdownInterrupt() {<a name="line.2441"></a> +<span class="sourceLineNo">2442</span> }<a name="line.2442"></a> +<span class="sourceLineNo">2443</span><a name="line.2443"></a> +<span class="sourceLineNo">2444</span> /**<a name="line.2444"></a> +<span class="sourceLineNo">2445</span> * Wait on all threads to finish. Presumption is that all closes and stops<a name="line.2445"></a> +<span class="sourceLineNo">2446</span> * have already been called.<a name="line.2446"></a> +<span class="sourceLineNo">2447</span> */<a name="line.2447"></a> +<span class="sourceLineNo">2448</span> protected void stopServiceThreads() {<a name="line.2448"></a> +<span class="sourceLineNo">2449</span> // clean up the scheduled chores<a name="line.2449"></a> +<span class="sourceLineNo">2450</span> if (this.choreService != null) choreService.shutdown();<a name="line.2450"></a> +<span class="sourceLineNo">2451</span> if (this.nonceManagerChore != null) nonceManagerChore.cancel(true);<a name="line.2451"></a> +<span class="sourceLineNo">2452</span> if (this.compactionChecker != null) compactionChecker.cancel(true);<a name="line.2452"></a> +<span class="sourceLineNo">2453</span> if (this.periodicFlusher != null) periodicFlusher.cancel(true);<a name="line.2453"></a> +<span class="sourceLineNo">2454</span> if (this.healthCheckChore != null) healthCheckChore.cancel(true);<a name="line.2454"></a> +<span class="sourceLineNo">2455</span> if (this.storefileRefresher != null) storefileRefresher.cancel(true);<a name="line.2455"></a> +<span class="sourceLineNo">2456</span> if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true);<a name="line.2456"></a> +<span class="sourceLineNo">2457</span> if (this.fsUtilizationChore != null) fsUtilizationChore.cancel(true);<a name="line.2457"></a> +<span class="sourceLineNo">2458</span><a name="line.2458"></a> +<span class="sourceLineNo">2459</span> if (this.cacheFlusher != null) {<a name="line.2459"></a> +<span class="sourceLineNo">2460</span> this.cacheFlusher.join();<a name="line.2460"></a> +<span class="sourceLineNo">2461</span> }<a name="line.2461"></a> +<span class="sourceLineNo">2462</span><a name="line.2462"></a> +<span class="sourceLineNo">2463</span> if (this.spanReceiverHost != null) {<a name="line.2463"></a> +<span class="sourceLineNo">2464</span> this.spanReceiverHost.closeReceivers();<a name="line.2464"></a> +<span class="sourceLineNo">2465</span> }<a name="line.2465"></a> +<span class="sourceLineNo">2466</span> if (this.walRoller != null) {<a name="line.2466"></a> +<span class="sourceLineNo">2467</span> this.walRoller.close();<a name="line.2467"></a> +<span class="sourceLineNo">2468</span> }<a name="line.2468"></a> +<span class="sourceLineNo">2469</span> if (this.compactSplitThread != null) {<a name="line.2469"></a> +<span class="sourceLineNo">2470</span> this.compactSplitThread.join();<a name="line.2470"></a> +<span class="sourceLineNo">2471</span> }<a name="line.2471"></a> +<span class="sourceLineNo">2472</span> if (this.executorService != null) this.executorService.shutdown();<a name="line.2472"></a> +<span class="sourceLineNo">2473</span> if (this.replicationSourceHandler != null &&<a name="line.2473"></a> +<span class="sourceLineNo">2474</span> this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2474"></a> +<span class="sourceLineNo">2475</span> this.replicationSourceHandler.stopReplicationService();<a name="line.2475"></a> +<span class="sourceLineNo">2476</span> } else {<a name="line.2476"></a> +<span class="sourceLineNo">2477</span> if (this.replicationSourceHandler != null) {<a name="line.2477"></a> +<span class="sourceLineNo">2478</span> this.replicationSourceHandler.stopReplicationService();<a name="line.2478"></a> +<span class="sourceLineNo">2479</span> }<a name="line.2479"></a> +<span class="sourceLineNo">2480</span> if (this.replicationSinkHandler != null) {<a name="line.2480"></a> +<span class="sourceLineNo">2481</span> this.replicationSinkHandler.stopReplicationService();<a name="line.2481"></a> +<span class="sourceLineNo">2482</span> }<a name="line.2482"></a> <span class="sourceLineNo">2483</span> }<a name="line.2483"></a> -<span class="sourceLineNo">2484</span> if (this.executorService != null) this.executorService.shutdown();<a name="line.2484"></a> -<span class="sourceLineNo">2485</span> if (this.replicationSourceHandler != null &&<a name="line.2485"></a> -<span class="sourceLineNo">2486</span> this.replicationSourceHandler == this.replicationSinkHandler) {<a name="line.2486"></a> -<span class="sourceLineNo">2487</span> this.replicationSourceHandler.stopReplicationService();<a name="line.2487"></a> -<span class="sourceLineNo">2488</span> } else {<a name="line.2488"></a> -<span class="sourceLineNo">2489</span> if (this.replicationSourceHandler != null) {<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> this.replicationSourceHandler.stopReplicationService();<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> }<a name="line.2491"></a> -<span class="sourceLineNo">2492</span> if (this.replicationSinkHandler != null) {<a name="line.2492"></a> -<span class="sourceLineNo">2493</span> this.replicationSinkHandler.stopReplicationService();<a name="line.2493"></a> -<span class="sourceLineNo">2494</span> }<a name="line.2494"></a> -<span class="sourceLineNo">2495</span> }<a name="line.2495"></a> -<span class="sourceLineNo">2496</span> }<a name="line.2496"></a> -<span class="sourceLineNo">2497</span><a name="line.2497"></a> -<span class="sourceLineNo">2498</span> /**<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> * @return Return the object that implements the replication<a name="line.2499"></a> -<span class="sourceLineNo">2500</span> * source executorService.<a name="line.2500"></a> -<span class="sourceLineNo">2501</span> */<a name="line.2501"></a> -<span class="sourceLineNo">2502</span> @VisibleForTesting<a name="line.2502"></a> -<span class="sourceLineNo">2503</span> public ReplicationSourceService getReplicationSourceService() {<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> return replicationSourceHandler;<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> }<a name="line.2505"></a> -<span class="sourceLineNo">2506</span><a name="line.2506"></a> -<span class="sourceLineNo">2507</span> /**<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> * @return Return the object that implements the replication<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> * sink executorService.<a name="line.2509"></a> +<span class="sourceLineNo">2484</span> }<a name="line.2484"></a> +<span class="sourceLineNo">2485</span><a name="line.2485"></a> +<span class="sourceLineNo">2486</span> /**<a name="line.2486"></a> +<span class="sourceLineNo">2487</span> * @return Return the object that implements the replication<a name="line.2487"></a> +<span class="sourceLineNo">2488</span> * source executorService.<a name="line.2488"></a> +<span class="sourceLineNo">2489</span> */<a name="line.2489"></a> +<span class="sourceLineNo">2490</span> @VisibleForTesting<a name="line.2490"></a> +<span class="sourceLineNo">2491</span> public ReplicationSourceService getReplicationSourceService() {<a name="line.2491"></a> +<span class="sourceLineNo">2492</span> return replicationSourceHandler;<a name="line.2492"></a> +<span class="sourceLineNo">2493</span> }<a name="line.2493"></a> +<span class="sourceLineNo">2494</span><a name="line.2494"></a> +<span class="sourceLineNo">2495</span> /**<a name="line.2495"></a> +<span class="sourceLineNo">2496</span> * @return Return the object that implements the replication<a name="line.2496"></a> +<span class="sourceLineNo">2497</span> * sink executorService.<a name="line.2497"></a> +<span class="sourceLineNo">2498</span> */<a name="line.2498"></a> +<span class="sourceLineNo">2499</span> ReplicationSinkService getReplicationSinkService() {<a name="line.2499"></a> +<span class="sourceLineNo">2500</span> return replicationSinkHandler;<a name="line.2500"></a> +<span class="sourceLineNo">2501</span> }<a name="line.2501"></a> +<span class="sourceLineNo">2502</span><a name="line.2502"></a> +<span class="sourceLineNo">2503</span> /**<a name="line.2503"></a> +<span class="sourceLineNo">2504</span> * Get the current master from ZooKeeper and open the RPC connection to it.<a name="line.2504"></a> +<span class="sourceLineNo">2505</span> * To get a fresh connection, the current rssStub must be null.<a name="line.2505"></a> +<span class="sourceLineNo">2506</span> * Method will block until a master is available. You can break from this<a name="line.2506"></a> +<span class="sourceLineNo">2507</span> * block by requesting the server stop.<a name="line.2507"></a> +<span class="sourceLineNo">2508</span> *<a name="line.2508"></a> +<span class="sourceLineNo">2509</span> * @return master + port, or null if server has been stopped<a name="line.2509"></a> <span class="sourceLineNo">2510</span> */<a name="line.2510"></a> -<span class="sourceLineNo">2511</span> ReplicationSinkService getReplicationSinkService() {<a name="line.2511"></a> -<span class="sourceLineNo">2512</span> return replicationSinkHandler;<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> }<a name="line.2513"></a> -<span class="sourceLineNo">2514</span><a name="line.2514"></a> -<span class="sourceLineNo">2515</span> /**<a name="line.2515"></a> -<span class="sourceLineNo">2516</span> * Get the current master from ZooKeeper and open the RPC connection to it.<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> * To get a fresh connection, the current rssStub must be null.<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> * Method will block until a master is available. You can break from this<a name="line.2518"></a> -<span class="sourceLineNo">2519</span> * block by requesting the server stop.<a name="line.2519"></a> -<span class="sourceLineNo">2520</span> *<a name="line.2520"></a> -<span class="sourceLineNo">2521</span> * @return master + port, or null if server has been stopped<a name="line.2521"></a> -<span class="sourceLineNo">2522</span> */<a name="line.2522"></a> -<span class="sourceLineNo">2523</span> @VisibleForTesting<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> protected synchronized ServerName createRegionServerStatusStub() {<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> // Create RS stub without refreshing the master node from ZK, use cached data<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> return createRegionServerStatusStub(false);<a name="line.2526"></a> -<span class="sourceLineNo">2527</span> }<a name="line.2527"></a> -<span class="sourceLineNo">2528</span><a name="line.2528"></a> -<span class="sourceLineNo">2529</span> /**<a name="line.2529"></a> -<span class="sourceLineNo">2530</span> * Get the current master from ZooKeeper and open the RPC connection to it. To get a fresh<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> * connection, the current rssStub must be null. Method will block until a master is available.<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> * You can break from this block by requesting the server stop.<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> * @param refresh If true then master address will be read from ZK, otherwise use cached data<a name="line.2533"></a> -<span class="sourceLineNo">2534</span> * @return master + port, or null if server has been stopped<a name="line.2534"></a> -<span class="sourceLineNo">2535</span> */<a name="line.2535"></a> -<span class="sourceLineNo">2536</span> @VisibleForTesting<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> protected synchronized ServerName createRegionServerStatusStub(boolean refresh) {<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> if (rssStub != null) {<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> return masterAddressTracker.getMasterAddress();<a name="line.2539"></a> -<span class="sourceLineNo">2540</span> }<a name="line.2540"></a> -<span class="sourceLineNo">2541</span> ServerName sn = null;<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> long previousLogTime = 0;<a name="line.2542"></a> -<span class="sourceLineNo">2543</span> RegionServerStatusService.BlockingInterface intRssStub = null;<a name="line.2543"></a> -<span class="sourceLineNo">2544</span> LockService.BlockingInterface intLockStub = null;<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> boolean interrupted = false;<a name="line.2545"></a> -<span class="sourceLineNo">2546</span> try {<a name="line.2546"></a> -<span class="sourceLineNo">2547</span> while (keepLooping()) {<a name="line.2547"></a> -<span class="sourceLineNo">2548</span> sn = this.masterAddressTracker.getMasterAddress(refresh);<a name="line.2548"></a> -<span class="sourceLineNo">2549</span> if (sn == null) {<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> if (!keepLooping()) {<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> // give up with no connection.<a name="line.2551"></a> -<span class="sourceLineNo">2552</span> LOG.debug("No master found and cluster is stopped; bailing out");<a name="line.2552"></a> -<span class="sourceLineNo">2553</span> return null;<a name="line.2553"></a> -<span class="sourceLineNo">2554</span> }<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> if (System.currentTimeMillis() > (previousLogTime + 1000)) {<a name="line.2555"></a> -<span class="sourceLineNo">2556</span> LOG.debug("No master found; retry");<a name="line.2556"></a> -<span class="sourceLineNo">2557</span> previousLogTime = System.currentTimeMillis();<a name="line.2557"></a> -<span class="sourceLineNo">2558</span> }<a name="line.2558"></a> -<span class="sourceLineNo">2559</span> refresh = true; // let's try pull it from ZK directly<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> if (sleep(200)) {<a name="line.2560"></a> -<span class="sourceLineNo">2561</span> interrupted = true;<a name="line.2561"></a> -<span class="sourceLineNo">2562</span> }<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> continue;<a name="line.2563"></a> -<span class="sourceLineNo">2564</span> }<a name="line.2564"></a> -<span class="sourceLineNo">2565</span><a name="line.2565"></a> -<span class="sourceLineNo">2566</span> // If we are on the active master, use the shortcut<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> if (this instanceof HMaster && sn.equals(getServerName())) {<a name="line.2567"></a> -<span class="sourceLineNo">2568</span> intRssStub = ((HMaster)this).getMasterRpcServices();<a name="line.2568"></a> -<span class="sourceLineNo">2569</span> intLockStub = ((HMaster)this).getMasterRpcServices();<a name="line.2569"></a> -<span class="sourceLineNo">2570</span> break;<a name="line.2570"></a> -<span class="sourceLineNo">2571</span> }<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> try {<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> BlockingRpcChannel channel =<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> this.rpcClient.createBlockingRpcChannel(sn, userProvider.getCurrent(),<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> shortOperationTimeout);<a name="line.2575"></a> -<span class="sourceLineNo">2576</span> intRssStub = RegionServerStatusService.newBlockingStub(channel);<a name="line.2576"></a> -<span class="sourceLineNo">2577</span> intLockStub = LockService.newBlockingStub(channel);<a name="line.2577"></a> -<span class="sourceLineNo">2578</span> break;<a name="line.2578"></a> -<span class="sourceLineNo">2579</span> } catch (IOException e) {<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> if (System.currentTimeMillis() > (previousLogTime + 1000)) {<a name="line.2580"></a> -<span class="sourceLineNo">2581</span> e = e instanceof RemoteException ?<a name="line.2581"></a> -<span class="sourceLineNo">2582</span> ((RemoteException)e).unwrapRemoteException() : e;<a name="line.2582"></a> -<span class="sourceLineNo">2583</span> if (e instanceof ServerNotRunningYetException) {<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> LOG.info("Master isn't available yet, retrying");<a name="line.2584"></a> -<span class="sourceLineNo">2585</span> } else {<a name="line.2585"></a> -<span class="sourceLineNo">2586</span> LOG.warn("Unable to connect to master. Retrying. Error was:", e);<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> }<a name="line.2587"></a> -<span class="sourceLineNo">2588</span> previousLogTime = System.currentTimeMillis();<a name="line.2588"></a> -<span class="sourceLineNo">2589</span> }<a name="line.2589"></a> -<span class="sourceLineNo">2590</span> if (sleep(200)) {<a name="line.2590"></a> -<span class="sourceLineNo">2591</span> interrupted = true;<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> }<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> }<a name="line.2593"></a> -<span class="sourceLineNo">2594</span> }<a name="line.2594"></a> -<span class="sourceLineNo">2595</span> } finally {<a name="line.2595"></a> -<span class="sourceLineNo">2596</span> if (interrupted) {<a name="line.2596"></a> -<span class="sourceLineNo">2597</span> Thread.currentThread().interrupt();<a name="line.2597"></a> -<span class="sourceLineNo">2598</span> }<a name="line.2598"></a> -<span class="sourceLineNo">2599</span> }<a name="line.2599"></a> -<span class="sourceLineNo">2600</span> this.rssStub = intRssStub;<a name="line.2600"></a> -<span class="sourceLineNo">2601</span> this.lockStub = intLockStub;<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> return sn;<a name="line.2602"></a> -<span class="sourceLineNo">2603</span> }<a name="line.2603"></a> -<span class="sourceLineNo">2604</span><a name="line.2604"></a> -<span class="sourceLineNo">2605</span> /**<a name="line.2605"></a> -<span class="sourceLineNo">2606</span> * @return True if we should break loop because cluster is going down or<a name="line.2606"></a> -<span class="sourceLineNo">2607</span> * this server has been stopped or hdfs has gone bad.<a name="line.2607"></a> -<span class="sourceLineNo">2608</span> */<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> private boolean keepLooping() {<a name="line.2609"></a> -<span class="sourceLineNo">2610</span> return !this.stopped && isClusterUp();<a name="line.2610"></a> -<span class="sourceLineNo">2611</span> }<a name="line.2611"></a> -<span class="sourceLineNo">2612</span><a name="line.2612"></a> -<span class="sourceLineNo">2613</span> /*<a name="line.2613"></a> -<span class="sourceLineNo">2614</span> * Let the master know we're here Run initialization using parameters passed<a name="line.2614"></a> -<span class="sourceLineNo">2615</span> * us by the master.<a name="line.2615"></a> -<span class="sourceLineNo">2616</span> * @return A Map of key/value configurations we got from the Master else<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> * null if we failed to register.<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> * @throws IOException<a name="line.2618"></a> -<span class="sourceLineNo">2619</span> */<a name="line.2619"></a> -<span class="sourceLineNo">2620</span> private RegionServerStartupResponse reportForDuty() throws IOException {<a name="line.2620"></a> -<span class="sourceLineNo">2621</span> if (this.masterless) return RegionServerStartupResponse.getDefaultInstance();<a name="line.2621"></a> -<span class="sourceLineNo">2622</span> ServerName masterServerName = createRegionServerStatusStub(true);<a name="line.2622"></a> -<span class="sourceLineNo">2623</span> if (masterServerName == null) return null;<a name="line.2623"></a> -<span class="sourceLineNo">2624</span> RegionServerStartupResponse result = null;<a name="line.2624"></a> -<span class="sourceLineNo">2625</span> try {<a name="line.2625"></a> -<span class="sourceLineNo">2626</span> rpcServices.requestCount.reset();<a name="line.2626"></a> -<span class="sourceLineNo">2627</span> rpcServices.rpcGetRequestCount.reset();<a name="line.2627"></a> -<span class="sourceLineNo">2628</span> rpcServices.rpcScanRequestCount.reset();<a name="line.2628"></a> -<span class="sourceLineNo">2629</span> rpcServices.rpcMultiRequestCount.reset();<a name="line.2629"></a> -<span class="sourceLineNo">2630</span>
<TRUNCATED>