Repository: hbase-site Updated Branches: refs/heads/asf-site 76952d27a -> 4abd958d5
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4abd958d/devapidocs/src-html/org/apache/hadoop/hbase/client/ClusterStatusListener.DeadServerHandler.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/ClusterStatusListener.DeadServerHandler.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/ClusterStatusListener.DeadServerHandler.html index b7e66b5..267ef6f 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/client/ClusterStatusListener.DeadServerHandler.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/ClusterStatusListener.DeadServerHandler.html @@ -28,41 +28,41 @@ <span class="sourceLineNo">020</span>package org.apache.hadoop.hbase.client;<a name="line.20"></a> <span class="sourceLineNo">021</span><a name="line.21"></a> <span class="sourceLineNo">022</span><a name="line.22"></a> -<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.shaded.io.netty.bootstrap.Bootstrap;<a name="line.23"></a> -<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.shaded.io.netty.buffer.ByteBufInputStream;<a name="line.24"></a> -<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.ChannelHandlerContext;<a name="line.25"></a> -<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.ChannelOption;<a name="line.26"></a> -<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.EventLoopGroup;<a name="line.27"></a> -<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.SimpleChannelInboundHandler;<a name="line.28"></a> -<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.nio.NioEventLoopGroup;<a name="line.29"></a> -<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.DatagramChannel;<a name="line.30"></a> -<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.DatagramPacket;<a name="line.31"></a> -<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.nio.NioDatagramChannel;<a name="line.32"></a> +<span class="sourceLineNo">023</span><a name="line.23"></a> +<span class="sourceLineNo">024</span>import java.io.Closeable;<a name="line.24"></a> +<span class="sourceLineNo">025</span>import java.io.IOException;<a name="line.25"></a> +<span class="sourceLineNo">026</span>import java.lang.reflect.Constructor;<a name="line.26"></a> +<span class="sourceLineNo">027</span>import java.lang.reflect.InvocationTargetException;<a name="line.27"></a> +<span class="sourceLineNo">028</span>import java.net.InetAddress;<a name="line.28"></a> +<span class="sourceLineNo">029</span>import java.net.NetworkInterface;<a name="line.29"></a> +<span class="sourceLineNo">030</span>import java.net.UnknownHostException;<a name="line.30"></a> +<span class="sourceLineNo">031</span>import java.util.ArrayList;<a name="line.31"></a> +<span class="sourceLineNo">032</span>import java.util.List;<a name="line.32"></a> <span class="sourceLineNo">033</span><a name="line.33"></a> -<span class="sourceLineNo">034</span>import java.io.Closeable;<a name="line.34"></a> -<span class="sourceLineNo">035</span>import java.io.IOException;<a name="line.35"></a> -<span class="sourceLineNo">036</span>import java.lang.reflect.Constructor;<a name="line.36"></a> -<span class="sourceLineNo">037</span>import java.lang.reflect.InvocationTargetException;<a name="line.37"></a> -<span class="sourceLineNo">038</span>import java.net.InetAddress;<a name="line.38"></a> -<span class="sourceLineNo">039</span>import java.net.NetworkInterface;<a name="line.39"></a> -<span class="sourceLineNo">040</span>import java.net.UnknownHostException;<a name="line.40"></a> -<span class="sourceLineNo">041</span>import java.util.ArrayList;<a name="line.41"></a> -<span class="sourceLineNo">042</span>import java.util.List;<a name="line.42"></a> -<span class="sourceLineNo">043</span><a name="line.43"></a> -<span class="sourceLineNo">044</span>import org.apache.commons.logging.Log;<a name="line.44"></a> -<span class="sourceLineNo">045</span>import org.apache.commons.logging.LogFactory;<a name="line.45"></a> -<span class="sourceLineNo">046</span>import org.apache.hadoop.conf.Configuration;<a name="line.46"></a> -<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.ClusterStatus;<a name="line.47"></a> -<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.HBaseInterfaceAudience;<a name="line.48"></a> -<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.HConstants;<a name="line.49"></a> -<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.ServerName;<a name="line.50"></a> -<span class="sourceLineNo">051</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.51"></a> -<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.52"></a> -<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;<a name="line.53"></a> -<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.util.Addressing;<a name="line.54"></a> -<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.55"></a> -<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.util.Threads;<a name="line.56"></a> -<span class="sourceLineNo">057</span><a name="line.57"></a> +<span class="sourceLineNo">034</span>import org.apache.commons.logging.Log;<a name="line.34"></a> +<span class="sourceLineNo">035</span>import org.apache.commons.logging.LogFactory;<a name="line.35"></a> +<span class="sourceLineNo">036</span>import org.apache.hadoop.conf.Configuration;<a name="line.36"></a> +<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.ClusterStatus;<a name="line.37"></a> +<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.HBaseInterfaceAudience;<a name="line.38"></a> +<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.HConstants;<a name="line.39"></a> +<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.ServerName;<a name="line.40"></a> +<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.Addressing;<a name="line.41"></a> +<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.util.ExceptionUtil;<a name="line.42"></a> +<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.util.Threads;<a name="line.43"></a> +<span class="sourceLineNo">044</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.44"></a> +<span class="sourceLineNo">045</span><a name="line.45"></a> +<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.shaded.io.netty.bootstrap.Bootstrap;<a name="line.46"></a> +<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.shaded.io.netty.buffer.ByteBufInputStream;<a name="line.47"></a> +<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.ChannelHandlerContext;<a name="line.48"></a> +<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.ChannelOption;<a name="line.49"></a> +<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.EventLoopGroup;<a name="line.50"></a> +<span class="sourceLineNo">051</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.SimpleChannelInboundHandler;<a name="line.51"></a> +<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.nio.NioEventLoopGroup;<a name="line.52"></a> +<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.DatagramChannel;<a name="line.53"></a> +<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.DatagramPacket;<a name="line.54"></a> +<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.shaded.io.netty.channel.socket.nio.NioDatagramChannel;<a name="line.55"></a> +<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.56"></a> +<span class="sourceLineNo">057</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;<a name="line.57"></a> <span class="sourceLineNo">058</span><a name="line.58"></a> <span class="sourceLineNo">059</span>/**<a name="line.59"></a> <span class="sourceLineNo">060</span> * A class that receives the cluster status, and provide it as a set of service to the client.<a name="line.60"></a> @@ -112,7 +112,7 @@ <span class="sourceLineNo">104</span> * Called to connect.<a name="line.104"></a> <span class="sourceLineNo">105</span> *<a name="line.105"></a> <span class="sourceLineNo">106</span> * @param conf Configuration to use.<a name="line.106"></a> -<span class="sourceLineNo">107</span> * @throws IOException<a name="line.107"></a> +<span class="sourceLineNo">107</span> * @throws IOException if failing to connect<a name="line.107"></a> <span class="sourceLineNo">108</span> */<a name="line.108"></a> <span class="sourceLineNo">109</span> void connect(Configuration conf) throws IOException;<a name="line.109"></a> <span class="sourceLineNo">110</span> }<a name="line.110"></a> @@ -205,76 +205,83 @@ <span class="sourceLineNo">197</span> HConstants.DEFAULT_STATUS_MULTICAST_BIND_ADDRESS);<a name="line.197"></a> <span class="sourceLineNo">198</span> int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,<a name="line.198"></a> <span class="sourceLineNo">199</span> HConstants.DEFAULT_STATUS_MULTICAST_PORT);<a name="line.199"></a> -<span class="sourceLineNo">200</span><a name="line.200"></a> -<span class="sourceLineNo">201</span> InetAddress ina;<a name="line.201"></a> -<span class="sourceLineNo">202</span> try {<a name="line.202"></a> -<span class="sourceLineNo">203</span> ina = InetAddress.getByName(mcAddress);<a name="line.203"></a> -<span class="sourceLineNo">204</span> } catch (UnknownHostException e) {<a name="line.204"></a> -<span class="sourceLineNo">205</span> close();<a name="line.205"></a> -<span class="sourceLineNo">206</span> throw new IOException("Can't connect to " + mcAddress, e);<a name="line.206"></a> -<span class="sourceLineNo">207</span> }<a name="line.207"></a> -<span class="sourceLineNo">208</span><a name="line.208"></a> -<span class="sourceLineNo">209</span> try {<a name="line.209"></a> -<span class="sourceLineNo">210</span> Bootstrap b = new Bootstrap();<a name="line.210"></a> -<span class="sourceLineNo">211</span> b.group(group)<a name="line.211"></a> -<span class="sourceLineNo">212</span> .channel(NioDatagramChannel.class)<a name="line.212"></a> -<span class="sourceLineNo">213</span> .option(ChannelOption.SO_REUSEADDR, true)<a name="line.213"></a> -<span class="sourceLineNo">214</span> .handler(new ClusterStatusHandler());<a name="line.214"></a> -<span class="sourceLineNo">215</span><a name="line.215"></a> -<span class="sourceLineNo">216</span> channel = (DatagramChannel)b.bind(bindAddress, port).sync().channel();<a name="line.216"></a> -<span class="sourceLineNo">217</span> } catch (InterruptedException e) {<a name="line.217"></a> -<span class="sourceLineNo">218</span> close();<a name="line.218"></a> -<span class="sourceLineNo">219</span> throw ExceptionUtil.asInterrupt(e);<a name="line.219"></a> -<span class="sourceLineNo">220</span> }<a name="line.220"></a> -<span class="sourceLineNo">221</span><a name="line.221"></a> -<span class="sourceLineNo">222</span> NetworkInterface ni = NetworkInterface.getByInetAddress(Addressing.getIpAddress());<a name="line.222"></a> -<span class="sourceLineNo">223</span> channel.joinGroup(ina, ni, null, channel.newPromise());<a name="line.223"></a> -<span class="sourceLineNo">224</span> }<a name="line.224"></a> -<span class="sourceLineNo">225</span><a name="line.225"></a> -<span class="sourceLineNo">226</span> @Override<a name="line.226"></a> -<span class="sourceLineNo">227</span> public void close() {<a name="line.227"></a> -<span class="sourceLineNo">228</span> if (channel != null) {<a name="line.228"></a> -<span class="sourceLineNo">229</span> channel.close();<a name="line.229"></a> -<span class="sourceLineNo">230</span> channel = null;<a name="line.230"></a> -<span class="sourceLineNo">231</span> }<a name="line.231"></a> -<span class="sourceLineNo">232</span> group.shutdownGracefully();<a name="line.232"></a> -<span class="sourceLineNo">233</span> }<a name="line.233"></a> -<span class="sourceLineNo">234</span><a name="line.234"></a> -<span class="sourceLineNo">235</span><a name="line.235"></a> -<span class="sourceLineNo">236</span><a name="line.236"></a> -<span class="sourceLineNo">237</span> /**<a name="line.237"></a> -<span class="sourceLineNo">238</span> * Class, conforming to the Netty framework, that manages the message received.<a name="line.238"></a> -<span class="sourceLineNo">239</span> */<a name="line.239"></a> -<span class="sourceLineNo">240</span> private class ClusterStatusHandler extends SimpleChannelInboundHandler<DatagramPacket> {<a name="line.240"></a> +<span class="sourceLineNo">200</span> String niName = conf.get(HConstants.STATUS_MULTICAST_NI_NAME);<a name="line.200"></a> +<span class="sourceLineNo">201</span><a name="line.201"></a> +<span class="sourceLineNo">202</span> InetAddress ina;<a name="line.202"></a> +<span class="sourceLineNo">203</span> try {<a name="line.203"></a> +<span class="sourceLineNo">204</span> ina = InetAddress.getByName(mcAddress);<a name="line.204"></a> +<span class="sourceLineNo">205</span> } catch (UnknownHostException e) {<a name="line.205"></a> +<span class="sourceLineNo">206</span> close();<a name="line.206"></a> +<span class="sourceLineNo">207</span> throw new IOException("Can't connect to " + mcAddress, e);<a name="line.207"></a> +<span class="sourceLineNo">208</span> }<a name="line.208"></a> +<span class="sourceLineNo">209</span><a name="line.209"></a> +<span class="sourceLineNo">210</span> try {<a name="line.210"></a> +<span class="sourceLineNo">211</span> Bootstrap b = new Bootstrap();<a name="line.211"></a> +<span class="sourceLineNo">212</span> b.group(group)<a name="line.212"></a> +<span class="sourceLineNo">213</span> .channel(NioDatagramChannel.class)<a name="line.213"></a> +<span class="sourceLineNo">214</span> .option(ChannelOption.SO_REUSEADDR, true)<a name="line.214"></a> +<span class="sourceLineNo">215</span> .handler(new ClusterStatusHandler());<a name="line.215"></a> +<span class="sourceLineNo">216</span><a name="line.216"></a> +<span class="sourceLineNo">217</span> channel = (DatagramChannel)b.bind(bindAddress, port).sync().channel();<a name="line.217"></a> +<span class="sourceLineNo">218</span> } catch (InterruptedException e) {<a name="line.218"></a> +<span class="sourceLineNo">219</span> close();<a name="line.219"></a> +<span class="sourceLineNo">220</span> throw ExceptionUtil.asInterrupt(e);<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> NetworkInterface ni;<a name="line.223"></a> +<span class="sourceLineNo">224</span> if (niName != null) {<a name="line.224"></a> +<span class="sourceLineNo">225</span> ni = NetworkInterface.getByName(niName);<a name="line.225"></a> +<span class="sourceLineNo">226</span> } else {<a name="line.226"></a> +<span class="sourceLineNo">227</span> ni = NetworkInterface.getByInetAddress(Addressing.getIpAddress());<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> channel.joinGroup(ina, ni, null, channel.newPromise());<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> @Override<a name="line.233"></a> +<span class="sourceLineNo">234</span> public void close() {<a name="line.234"></a> +<span class="sourceLineNo">235</span> if (channel != null) {<a name="line.235"></a> +<span class="sourceLineNo">236</span> channel.close();<a name="line.236"></a> +<span class="sourceLineNo">237</span> channel = null;<a name="line.237"></a> +<span class="sourceLineNo">238</span> }<a name="line.238"></a> +<span class="sourceLineNo">239</span> group.shutdownGracefully();<a name="line.239"></a> +<span class="sourceLineNo">240</span> }<a name="line.240"></a> <span class="sourceLineNo">241</span><a name="line.241"></a> -<span class="sourceLineNo">242</span> @Override<a name="line.242"></a> -<span class="sourceLineNo">243</span> public void exceptionCaught(<a name="line.243"></a> -<span class="sourceLineNo">244</span> ChannelHandlerContext ctx, Throwable cause)<a name="line.244"></a> -<span class="sourceLineNo">245</span> throws Exception {<a name="line.245"></a> -<span class="sourceLineNo">246</span> LOG.error("Unexpected exception, continuing.", cause);<a name="line.246"></a> -<span class="sourceLineNo">247</span> }<a name="line.247"></a> +<span class="sourceLineNo">242</span><a name="line.242"></a> +<span class="sourceLineNo">243</span><a name="line.243"></a> +<span class="sourceLineNo">244</span> /**<a name="line.244"></a> +<span class="sourceLineNo">245</span> * Class, conforming to the Netty framework, that manages the message received.<a name="line.245"></a> +<span class="sourceLineNo">246</span> */<a name="line.246"></a> +<span class="sourceLineNo">247</span> private class ClusterStatusHandler extends SimpleChannelInboundHandler<DatagramPacket> {<a name="line.247"></a> <span class="sourceLineNo">248</span><a name="line.248"></a> <span class="sourceLineNo">249</span> @Override<a name="line.249"></a> -<span class="sourceLineNo">250</span> public boolean acceptInboundMessage(Object msg)<a name="line.250"></a> -<span class="sourceLineNo">251</span> throws Exception {<a name="line.251"></a> -<span class="sourceLineNo">252</span> return super.acceptInboundMessage(msg);<a name="line.252"></a> -<span class="sourceLineNo">253</span> }<a name="line.253"></a> -<span class="sourceLineNo">254</span><a name="line.254"></a> +<span class="sourceLineNo">250</span> public void exceptionCaught(<a name="line.250"></a> +<span class="sourceLineNo">251</span> ChannelHandlerContext ctx, Throwable cause)<a name="line.251"></a> +<span class="sourceLineNo">252</span> throws Exception {<a name="line.252"></a> +<span class="sourceLineNo">253</span> LOG.error("Unexpected exception, continuing.", cause);<a name="line.253"></a> +<span class="sourceLineNo">254</span> }<a name="line.254"></a> <span class="sourceLineNo">255</span><a name="line.255"></a> <span class="sourceLineNo">256</span> @Override<a name="line.256"></a> -<span class="sourceLineNo">257</span> protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket dp) throws Exception {<a name="line.257"></a> -<span class="sourceLineNo">258</span> ByteBufInputStream bis = new ByteBufInputStream(dp.content());<a name="line.258"></a> -<span class="sourceLineNo">259</span> try {<a name="line.259"></a> -<span class="sourceLineNo">260</span> ClusterStatusProtos.ClusterStatus csp = ClusterStatusProtos.ClusterStatus.parseFrom(bis);<a name="line.260"></a> -<span class="sourceLineNo">261</span> ClusterStatus ncs = ProtobufUtil.convert(csp);<a name="line.261"></a> -<span class="sourceLineNo">262</span> receive(ncs);<a name="line.262"></a> -<span class="sourceLineNo">263</span> } finally {<a name="line.263"></a> -<span class="sourceLineNo">264</span> bis.close();<a name="line.264"></a> -<span class="sourceLineNo">265</span> }<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>}<a name="line.269"></a> +<span class="sourceLineNo">257</span> public boolean acceptInboundMessage(Object msg)<a name="line.257"></a> +<span class="sourceLineNo">258</span> throws Exception {<a name="line.258"></a> +<span class="sourceLineNo">259</span> return super.acceptInboundMessage(msg);<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> @Override<a name="line.263"></a> +<span class="sourceLineNo">264</span> protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket dp) throws Exception {<a name="line.264"></a> +<span class="sourceLineNo">265</span> ByteBufInputStream bis = new ByteBufInputStream(dp.content());<a name="line.265"></a> +<span class="sourceLineNo">266</span> try {<a name="line.266"></a> +<span class="sourceLineNo">267</span> ClusterStatusProtos.ClusterStatus csp = ClusterStatusProtos.ClusterStatus.parseFrom(bis);<a name="line.267"></a> +<span class="sourceLineNo">268</span> ClusterStatus ncs = ProtobufUtil.convert(csp);<a name="line.268"></a> +<span class="sourceLineNo">269</span> receive(ncs);<a name="line.269"></a> +<span class="sourceLineNo">270</span> } finally {<a name="line.270"></a> +<span class="sourceLineNo">271</span> bis.close();<a name="line.271"></a> +<span class="sourceLineNo">272</span> }<a name="line.272"></a> +<span class="sourceLineNo">273</span> }<a name="line.273"></a> +<span class="sourceLineNo">274</span> }<a name="line.274"></a> +<span class="sourceLineNo">275</span> }<a name="line.275"></a> +<span class="sourceLineNo">276</span>}<a name="line.276"></a>