hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [23/30] hbase-site git commit: Published site at 28cd48b673ca743d193874b2951bc995699e8e89.
Date Wed, 24 Feb 2016 17:45:22 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/89b638a4/devapidocs/src-html/org/apache/hadoop/hbase/ipc/RpcServer.Call.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/ipc/RpcServer.Call.html b/devapidocs/src-html/org/apache/hadoop/hbase/ipc/RpcServer.Call.html
index e5d9af6..ea9ea4d 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/ipc/RpcServer.Call.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/ipc/RpcServer.Call.html
@@ -2107,556 +2107,559 @@
 <span class="sourceLineNo">2099</span>  @Override<a name="line.2099"></a>
 <span class="sourceLineNo">2100</span>  public void onConfigurationChange(Configuration newConf) {<a name="line.2100"></a>
 <span class="sourceLineNo">2101</span>    initReconfigurable(newConf);<a name="line.2101"></a>
-<span class="sourceLineNo">2102</span>  }<a name="line.2102"></a>
-<span class="sourceLineNo">2103</span><a name="line.2103"></a>
-<span class="sourceLineNo">2104</span>  private void initReconfigurable(Configuration confToLoad) {<a name="line.2104"></a>
-<span class="sourceLineNo">2105</span>    this.allowFallbackToSimpleAuth = confToLoad.getBoolean(FALLBACK_TO_INSECURE_CLIENT_AUTH, false);<a name="line.2105"></a>
-<span class="sourceLineNo">2106</span>    if (isSecurityEnabled &amp;&amp; allowFallbackToSimpleAuth) {<a name="line.2106"></a>
-<span class="sourceLineNo">2107</span>      LOG.warn("********* WARNING! *********");<a name="line.2107"></a>
-<span class="sourceLineNo">2108</span>      LOG.warn("This server is configured to allow connections from INSECURE clients");<a name="line.2108"></a>
-<span class="sourceLineNo">2109</span>      LOG.warn("(" + FALLBACK_TO_INSECURE_CLIENT_AUTH + " = true).");<a name="line.2109"></a>
-<span class="sourceLineNo">2110</span>      LOG.warn("While this option is enabled, client identities cannot be secured, and user");<a name="line.2110"></a>
-<span class="sourceLineNo">2111</span>      LOG.warn("impersonation is possible!");<a name="line.2111"></a>
-<span class="sourceLineNo">2112</span>      LOG.warn("For secure operation, please disable SIMPLE authentication as soon as possible,");<a name="line.2112"></a>
-<span class="sourceLineNo">2113</span>      LOG.warn("by setting " + FALLBACK_TO_INSECURE_CLIENT_AUTH + " = false in hbase-site.xml");<a name="line.2113"></a>
-<span class="sourceLineNo">2114</span>      LOG.warn("****************************");<a name="line.2114"></a>
-<span class="sourceLineNo">2115</span>    }<a name="line.2115"></a>
-<span class="sourceLineNo">2116</span>  }<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>   * Subclasses of HBaseServer can override this to provide their own<a name="line.2119"></a>
-<span class="sourceLineNo">2120</span>   * Connection implementations.<a name="line.2120"></a>
-<span class="sourceLineNo">2121</span>   */<a name="line.2121"></a>
-<span class="sourceLineNo">2122</span>  protected Connection getConnection(SocketChannel channel, long time) {<a name="line.2122"></a>
-<span class="sourceLineNo">2123</span>    return new Connection(channel, time);<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>  /**<a name="line.2126"></a>
-<span class="sourceLineNo">2127</span>   * Setup response for the RPC Call.<a name="line.2127"></a>
-<span class="sourceLineNo">2128</span>   *<a name="line.2128"></a>
-<span class="sourceLineNo">2129</span>   * @param response buffer to serialize the response into<a name="line.2129"></a>
-<span class="sourceLineNo">2130</span>   * @param call {@link Call} to which we are setting up the response<a name="line.2130"></a>
-<span class="sourceLineNo">2131</span>   * @param error error message, if the call failed<a name="line.2131"></a>
-<span class="sourceLineNo">2132</span>   * @throws IOException<a name="line.2132"></a>
-<span class="sourceLineNo">2133</span>   */<a name="line.2133"></a>
-<span class="sourceLineNo">2134</span>  private void setupResponse(ByteArrayOutputStream response, Call call, Throwable t, String error)<a name="line.2134"></a>
-<span class="sourceLineNo">2135</span>  throws IOException {<a name="line.2135"></a>
-<span class="sourceLineNo">2136</span>    if (response != null) response.reset();<a name="line.2136"></a>
-<span class="sourceLineNo">2137</span>    call.setResponse(null, null, t, error);<a name="line.2137"></a>
-<span class="sourceLineNo">2138</span>  }<a name="line.2138"></a>
-<span class="sourceLineNo">2139</span><a name="line.2139"></a>
-<span class="sourceLineNo">2140</span>  protected void closeConnection(Connection connection) {<a name="line.2140"></a>
-<span class="sourceLineNo">2141</span>    synchronized (connectionList) {<a name="line.2141"></a>
-<span class="sourceLineNo">2142</span>      if (connectionList.remove(connection)) {<a name="line.2142"></a>
-<span class="sourceLineNo">2143</span>        numConnections--;<a name="line.2143"></a>
-<span class="sourceLineNo">2144</span>      }<a name="line.2144"></a>
-<span class="sourceLineNo">2145</span>    }<a name="line.2145"></a>
-<span class="sourceLineNo">2146</span>    connection.close();<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>  Configuration getConf() {<a name="line.2149"></a>
-<span class="sourceLineNo">2150</span>    return conf;<a name="line.2150"></a>
-<span class="sourceLineNo">2151</span>  }<a name="line.2151"></a>
-<span class="sourceLineNo">2152</span><a name="line.2152"></a>
-<span class="sourceLineNo">2153</span>  /** Sets the socket buffer size used for responding to RPCs.<a name="line.2153"></a>
-<span class="sourceLineNo">2154</span>   * @param size send size<a name="line.2154"></a>
-<span class="sourceLineNo">2155</span>   */<a name="line.2155"></a>
-<span class="sourceLineNo">2156</span>  @Override<a name="line.2156"></a>
-<span class="sourceLineNo">2157</span>  public void setSocketSendBufSize(int size) { this.socketSendBufferSize = size; }<a name="line.2157"></a>
-<span class="sourceLineNo">2158</span><a name="line.2158"></a>
+<span class="sourceLineNo">2102</span>    if (scheduler instanceof ConfigurationObserver) {<a name="line.2102"></a>
+<span class="sourceLineNo">2103</span>      ((ConfigurationObserver)scheduler).onConfigurationChange(newConf);<a name="line.2103"></a>
+<span class="sourceLineNo">2104</span>    }<a name="line.2104"></a>
+<span class="sourceLineNo">2105</span>  }<a name="line.2105"></a>
+<span class="sourceLineNo">2106</span><a name="line.2106"></a>
+<span class="sourceLineNo">2107</span>  private void initReconfigurable(Configuration confToLoad) {<a name="line.2107"></a>
+<span class="sourceLineNo">2108</span>    this.allowFallbackToSimpleAuth = confToLoad.getBoolean(FALLBACK_TO_INSECURE_CLIENT_AUTH, false);<a name="line.2108"></a>
+<span class="sourceLineNo">2109</span>    if (isSecurityEnabled &amp;&amp; allowFallbackToSimpleAuth) {<a name="line.2109"></a>
+<span class="sourceLineNo">2110</span>      LOG.warn("********* WARNING! *********");<a name="line.2110"></a>
+<span class="sourceLineNo">2111</span>      LOG.warn("This server is configured to allow connections from INSECURE clients");<a name="line.2111"></a>
+<span class="sourceLineNo">2112</span>      LOG.warn("(" + FALLBACK_TO_INSECURE_CLIENT_AUTH + " = true).");<a name="line.2112"></a>
+<span class="sourceLineNo">2113</span>      LOG.warn("While this option is enabled, client identities cannot be secured, and user");<a name="line.2113"></a>
+<span class="sourceLineNo">2114</span>      LOG.warn("impersonation is possible!");<a name="line.2114"></a>
+<span class="sourceLineNo">2115</span>      LOG.warn("For secure operation, please disable SIMPLE authentication as soon as possible,");<a name="line.2115"></a>
+<span class="sourceLineNo">2116</span>      LOG.warn("by setting " + FALLBACK_TO_INSECURE_CLIENT_AUTH + " = false in hbase-site.xml");<a name="line.2116"></a>
+<span class="sourceLineNo">2117</span>      LOG.warn("****************************");<a name="line.2117"></a>
+<span class="sourceLineNo">2118</span>    }<a name="line.2118"></a>
+<span class="sourceLineNo">2119</span>  }<a name="line.2119"></a>
+<span class="sourceLineNo">2120</span><a name="line.2120"></a>
+<span class="sourceLineNo">2121</span>  /**<a name="line.2121"></a>
+<span class="sourceLineNo">2122</span>   * Subclasses of HBaseServer can override this to provide their own<a name="line.2122"></a>
+<span class="sourceLineNo">2123</span>   * Connection implementations.<a name="line.2123"></a>
+<span class="sourceLineNo">2124</span>   */<a name="line.2124"></a>
+<span class="sourceLineNo">2125</span>  protected Connection getConnection(SocketChannel channel, long time) {<a name="line.2125"></a>
+<span class="sourceLineNo">2126</span>    return new Connection(channel, time);<a name="line.2126"></a>
+<span class="sourceLineNo">2127</span>  }<a name="line.2127"></a>
+<span class="sourceLineNo">2128</span><a name="line.2128"></a>
+<span class="sourceLineNo">2129</span>  /**<a name="line.2129"></a>
+<span class="sourceLineNo">2130</span>   * Setup response for the RPC Call.<a name="line.2130"></a>
+<span class="sourceLineNo">2131</span>   *<a name="line.2131"></a>
+<span class="sourceLineNo">2132</span>   * @param response buffer to serialize the response into<a name="line.2132"></a>
+<span class="sourceLineNo">2133</span>   * @param call {@link Call} to which we are setting up the response<a name="line.2133"></a>
+<span class="sourceLineNo">2134</span>   * @param error error message, if the call failed<a name="line.2134"></a>
+<span class="sourceLineNo">2135</span>   * @throws IOException<a name="line.2135"></a>
+<span class="sourceLineNo">2136</span>   */<a name="line.2136"></a>
+<span class="sourceLineNo">2137</span>  private void setupResponse(ByteArrayOutputStream response, Call call, Throwable t, String error)<a name="line.2137"></a>
+<span class="sourceLineNo">2138</span>  throws IOException {<a name="line.2138"></a>
+<span class="sourceLineNo">2139</span>    if (response != null) response.reset();<a name="line.2139"></a>
+<span class="sourceLineNo">2140</span>    call.setResponse(null, null, t, error);<a name="line.2140"></a>
+<span class="sourceLineNo">2141</span>  }<a name="line.2141"></a>
+<span class="sourceLineNo">2142</span><a name="line.2142"></a>
+<span class="sourceLineNo">2143</span>  protected void closeConnection(Connection connection) {<a name="line.2143"></a>
+<span class="sourceLineNo">2144</span>    synchronized (connectionList) {<a name="line.2144"></a>
+<span class="sourceLineNo">2145</span>      if (connectionList.remove(connection)) {<a name="line.2145"></a>
+<span class="sourceLineNo">2146</span>        numConnections--;<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>    connection.close();<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>  Configuration getConf() {<a name="line.2152"></a>
+<span class="sourceLineNo">2153</span>    return conf;<a name="line.2153"></a>
+<span class="sourceLineNo">2154</span>  }<a name="line.2154"></a>
+<span class="sourceLineNo">2155</span><a name="line.2155"></a>
+<span class="sourceLineNo">2156</span>  /** Sets the socket buffer size used for responding to RPCs.<a name="line.2156"></a>
+<span class="sourceLineNo">2157</span>   * @param size send size<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 boolean isStarted() {<a name="line.2160"></a>
-<span class="sourceLineNo">2161</span>    return this.started;<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>  /** Starts the service.  Must be called before any calls will be handled. */<a name="line.2164"></a>
-<span class="sourceLineNo">2165</span>  @Override<a name="line.2165"></a>
-<span class="sourceLineNo">2166</span>  public synchronized void start() {<a name="line.2166"></a>
-<span class="sourceLineNo">2167</span>    if (started) return;<a name="line.2167"></a>
-<span class="sourceLineNo">2168</span>    authTokenSecretMgr = createSecretManager();<a name="line.2168"></a>
-<span class="sourceLineNo">2169</span>    if (authTokenSecretMgr != null) {<a name="line.2169"></a>
-<span class="sourceLineNo">2170</span>      setSecretManager(authTokenSecretMgr);<a name="line.2170"></a>
-<span class="sourceLineNo">2171</span>      authTokenSecretMgr.start();<a name="line.2171"></a>
-<span class="sourceLineNo">2172</span>    }<a name="line.2172"></a>
-<span class="sourceLineNo">2173</span>    this.authManager = new ServiceAuthorizationManager();<a name="line.2173"></a>
-<span class="sourceLineNo">2174</span>    HBasePolicyProvider.init(conf, authManager);<a name="line.2174"></a>
-<span class="sourceLineNo">2175</span>    responder.start();<a name="line.2175"></a>
-<span class="sourceLineNo">2176</span>    listener.start();<a name="line.2176"></a>
-<span class="sourceLineNo">2177</span>    scheduler.start();<a name="line.2177"></a>
-<span class="sourceLineNo">2178</span>    started = true;<a name="line.2178"></a>
-<span class="sourceLineNo">2179</span>  }<a name="line.2179"></a>
-<span class="sourceLineNo">2180</span><a name="line.2180"></a>
-<span class="sourceLineNo">2181</span>  @Override<a name="line.2181"></a>
-<span class="sourceLineNo">2182</span>  public synchronized void refreshAuthManager(PolicyProvider pp) {<a name="line.2182"></a>
-<span class="sourceLineNo">2183</span>    // Ignore warnings that this should be accessed in a static way instead of via an instance;<a name="line.2183"></a>
-<span class="sourceLineNo">2184</span>    // it'll break if you go via static route.<a name="line.2184"></a>
-<span class="sourceLineNo">2185</span>    this.authManager.refresh(this.conf, pp);<a name="line.2185"></a>
-<span class="sourceLineNo">2186</span>  }<a name="line.2186"></a>
-<span class="sourceLineNo">2187</span><a name="line.2187"></a>
-<span class="sourceLineNo">2188</span>  private AuthenticationTokenSecretManager createSecretManager() {<a name="line.2188"></a>
-<span class="sourceLineNo">2189</span>    if (!isSecurityEnabled) return null;<a name="line.2189"></a>
-<span class="sourceLineNo">2190</span>    if (server == null) return null;<a name="line.2190"></a>
-<span class="sourceLineNo">2191</span>    Configuration conf = server.getConfiguration();<a name="line.2191"></a>
-<span class="sourceLineNo">2192</span>    long keyUpdateInterval =<a name="line.2192"></a>
-<span class="sourceLineNo">2193</span>        conf.getLong("hbase.auth.key.update.interval", 24*60*60*1000);<a name="line.2193"></a>
-<span class="sourceLineNo">2194</span>    long maxAge =<a name="line.2194"></a>
-<span class="sourceLineNo">2195</span>        conf.getLong("hbase.auth.token.max.lifetime", 7*24*60*60*1000);<a name="line.2195"></a>
-<span class="sourceLineNo">2196</span>    return new AuthenticationTokenSecretManager(conf, server.getZooKeeper(),<a name="line.2196"></a>
-<span class="sourceLineNo">2197</span>        server.getServerName().toString(), keyUpdateInterval, maxAge);<a name="line.2197"></a>
-<span class="sourceLineNo">2198</span>  }<a name="line.2198"></a>
-<span class="sourceLineNo">2199</span><a name="line.2199"></a>
-<span class="sourceLineNo">2200</span>  public SecretManager&lt;? extends TokenIdentifier&gt; getSecretManager() {<a name="line.2200"></a>
-<span class="sourceLineNo">2201</span>    return this.secretManager;<a name="line.2201"></a>
-<span class="sourceLineNo">2202</span>  }<a name="line.2202"></a>
-<span class="sourceLineNo">2203</span><a name="line.2203"></a>
-<span class="sourceLineNo">2204</span>  @SuppressWarnings("unchecked")<a name="line.2204"></a>
-<span class="sourceLineNo">2205</span>  public void setSecretManager(SecretManager&lt;? extends TokenIdentifier&gt; secretManager) {<a name="line.2205"></a>
-<span class="sourceLineNo">2206</span>    this.secretManager = (SecretManager&lt;TokenIdentifier&gt;) secretManager;<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>   * This is a server side method, which is invoked over RPC. On success<a name="line.2210"></a>
-<span class="sourceLineNo">2211</span>   * the return response has protobuf response payload. On failure, the<a name="line.2211"></a>
-<span class="sourceLineNo">2212</span>   * exception name and the stack trace are returned in the protobuf response.<a name="line.2212"></a>
-<span class="sourceLineNo">2213</span>   */<a name="line.2213"></a>
-<span class="sourceLineNo">2214</span>  @Override<a name="line.2214"></a>
-<span class="sourceLineNo">2215</span>  public Pair&lt;Message, CellScanner&gt; call(BlockingService service, MethodDescriptor md,<a name="line.2215"></a>
-<span class="sourceLineNo">2216</span>      Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)<a name="line.2216"></a>
-<span class="sourceLineNo">2217</span>  throws IOException {<a name="line.2217"></a>
-<span class="sourceLineNo">2218</span>    try {<a name="line.2218"></a>
-<span class="sourceLineNo">2219</span>      status.setRPC(md.getName(), new Object[]{param}, receiveTime);<a name="line.2219"></a>
-<span class="sourceLineNo">2220</span>      // TODO: Review after we add in encoded data blocks.<a name="line.2220"></a>
-<span class="sourceLineNo">2221</span>      status.setRPCPacket(param);<a name="line.2221"></a>
-<span class="sourceLineNo">2222</span>      status.resume("Servicing call");<a name="line.2222"></a>
-<span class="sourceLineNo">2223</span>      //get an instance of the method arg type<a name="line.2223"></a>
-<span class="sourceLineNo">2224</span>      long startTime = System.currentTimeMillis();<a name="line.2224"></a>
-<span class="sourceLineNo">2225</span>      PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);<a name="line.2225"></a>
-<span class="sourceLineNo">2226</span>      Message result = service.callBlockingMethod(md, controller, param);<a name="line.2226"></a>
-<span class="sourceLineNo">2227</span>      long endTime = System.currentTimeMillis();<a name="line.2227"></a>
-<span class="sourceLineNo">2228</span>      int processingTime = (int) (endTime - startTime);<a name="line.2228"></a>
-<span class="sourceLineNo">2229</span>      int qTime = (int) (startTime - receiveTime);<a name="line.2229"></a>
-<span class="sourceLineNo">2230</span>      int totalTime = (int) (endTime - receiveTime);<a name="line.2230"></a>
-<span class="sourceLineNo">2231</span>      if (LOG.isTraceEnabled()) {<a name="line.2231"></a>
-<span class="sourceLineNo">2232</span>        LOG.trace(CurCall.get().toString() +<a name="line.2232"></a>
-<span class="sourceLineNo">2233</span>            ", response " + TextFormat.shortDebugString(result) +<a name="line.2233"></a>
-<span class="sourceLineNo">2234</span>            " queueTime: " + qTime +<a name="line.2234"></a>
-<span class="sourceLineNo">2235</span>            " processingTime: " + processingTime +<a name="line.2235"></a>
-<span class="sourceLineNo">2236</span>            " totalTime: " + totalTime);<a name="line.2236"></a>
-<span class="sourceLineNo">2237</span>      }<a name="line.2237"></a>
-<span class="sourceLineNo">2238</span>      long requestSize = param.getSerializedSize();<a name="line.2238"></a>
-<span class="sourceLineNo">2239</span>      long responseSize = result.getSerializedSize();<a name="line.2239"></a>
-<span class="sourceLineNo">2240</span>      metrics.dequeuedCall(qTime);<a name="line.2240"></a>
-<span class="sourceLineNo">2241</span>      metrics.processedCall(processingTime);<a name="line.2241"></a>
-<span class="sourceLineNo">2242</span>      metrics.totalCall(totalTime);<a name="line.2242"></a>
-<span class="sourceLineNo">2243</span>      metrics.receivedRequest(requestSize);<a name="line.2243"></a>
-<span class="sourceLineNo">2244</span>      metrics.sentResponse(responseSize);<a name="line.2244"></a>
-<span class="sourceLineNo">2245</span>      // log any RPC responses that are slower than the configured warn<a name="line.2245"></a>
-<span class="sourceLineNo">2246</span>      // response time or larger than configured warning size<a name="line.2246"></a>
-<span class="sourceLineNo">2247</span>      boolean tooSlow = (processingTime &gt; warnResponseTime &amp;&amp; warnResponseTime &gt; -1);<a name="line.2247"></a>
-<span class="sourceLineNo">2248</span>      boolean tooLarge = (responseSize &gt; warnResponseSize &amp;&amp; warnResponseSize &gt; -1);<a name="line.2248"></a>
-<span class="sourceLineNo">2249</span>      if (tooSlow || tooLarge) {<a name="line.2249"></a>
-<span class="sourceLineNo">2250</span>        // when tagging, we let TooLarge trump TooSmall to keep output simple<a name="line.2250"></a>
-<span class="sourceLineNo">2251</span>        // note that large responses will often also be slow.<a name="line.2251"></a>
-<span class="sourceLineNo">2252</span>        logResponse(new Object[]{param},<a name="line.2252"></a>
-<span class="sourceLineNo">2253</span>            md.getName(), md.getName() + "(" + param.getClass().getName() + ")",<a name="line.2253"></a>
-<span class="sourceLineNo">2254</span>            (tooLarge ? "TooLarge" : "TooSlow"),<a name="line.2254"></a>
-<span class="sourceLineNo">2255</span>            status.getClient(), startTime, processingTime, qTime,<a name="line.2255"></a>
-<span class="sourceLineNo">2256</span>            responseSize);<a name="line.2256"></a>
-<span class="sourceLineNo">2257</span>      }<a name="line.2257"></a>
-<span class="sourceLineNo">2258</span>      return new Pair&lt;Message, CellScanner&gt;(result, controller.cellScanner());<a name="line.2258"></a>
-<span class="sourceLineNo">2259</span>    } catch (Throwable e) {<a name="line.2259"></a>
-<span class="sourceLineNo">2260</span>      // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before<a name="line.2260"></a>
-<span class="sourceLineNo">2261</span>      // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't<a name="line.2261"></a>
-<span class="sourceLineNo">2262</span>      // need to pass it over the wire.<a name="line.2262"></a>
-<span class="sourceLineNo">2263</span>      if (e instanceof ServiceException) e = e.getCause();<a name="line.2263"></a>
-<span class="sourceLineNo">2264</span><a name="line.2264"></a>
-<span class="sourceLineNo">2265</span>      // increment the number of requests that were exceptions.<a name="line.2265"></a>
-<span class="sourceLineNo">2266</span>      metrics.exception(e);<a name="line.2266"></a>
+<span class="sourceLineNo">2160</span>  public void setSocketSendBufSize(int size) { this.socketSendBufferSize = size; }<a name="line.2160"></a>
+<span class="sourceLineNo">2161</span><a name="line.2161"></a>
+<span class="sourceLineNo">2162</span>  @Override<a name="line.2162"></a>
+<span class="sourceLineNo">2163</span>  public boolean isStarted() {<a name="line.2163"></a>
+<span class="sourceLineNo">2164</span>    return this.started;<a name="line.2164"></a>
+<span class="sourceLineNo">2165</span>  }<a name="line.2165"></a>
+<span class="sourceLineNo">2166</span><a name="line.2166"></a>
+<span class="sourceLineNo">2167</span>  /** Starts the service.  Must be called before any calls will be handled. */<a name="line.2167"></a>
+<span class="sourceLineNo">2168</span>  @Override<a name="line.2168"></a>
+<span class="sourceLineNo">2169</span>  public synchronized void start() {<a name="line.2169"></a>
+<span class="sourceLineNo">2170</span>    if (started) return;<a name="line.2170"></a>
+<span class="sourceLineNo">2171</span>    authTokenSecretMgr = createSecretManager();<a name="line.2171"></a>
+<span class="sourceLineNo">2172</span>    if (authTokenSecretMgr != null) {<a name="line.2172"></a>
+<span class="sourceLineNo">2173</span>      setSecretManager(authTokenSecretMgr);<a name="line.2173"></a>
+<span class="sourceLineNo">2174</span>      authTokenSecretMgr.start();<a name="line.2174"></a>
+<span class="sourceLineNo">2175</span>    }<a name="line.2175"></a>
+<span class="sourceLineNo">2176</span>    this.authManager = new ServiceAuthorizationManager();<a name="line.2176"></a>
+<span class="sourceLineNo">2177</span>    HBasePolicyProvider.init(conf, authManager);<a name="line.2177"></a>
+<span class="sourceLineNo">2178</span>    responder.start();<a name="line.2178"></a>
+<span class="sourceLineNo">2179</span>    listener.start();<a name="line.2179"></a>
+<span class="sourceLineNo">2180</span>    scheduler.start();<a name="line.2180"></a>
+<span class="sourceLineNo">2181</span>    started = true;<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>  @Override<a name="line.2184"></a>
+<span class="sourceLineNo">2185</span>  public synchronized void refreshAuthManager(PolicyProvider pp) {<a name="line.2185"></a>
+<span class="sourceLineNo">2186</span>    // Ignore warnings that this should be accessed in a static way instead of via an instance;<a name="line.2186"></a>
+<span class="sourceLineNo">2187</span>    // it'll break if you go via static route.<a name="line.2187"></a>
+<span class="sourceLineNo">2188</span>    this.authManager.refresh(this.conf, pp);<a name="line.2188"></a>
+<span class="sourceLineNo">2189</span>  }<a name="line.2189"></a>
+<span class="sourceLineNo">2190</span><a name="line.2190"></a>
+<span class="sourceLineNo">2191</span>  private AuthenticationTokenSecretManager createSecretManager() {<a name="line.2191"></a>
+<span class="sourceLineNo">2192</span>    if (!isSecurityEnabled) return null;<a name="line.2192"></a>
+<span class="sourceLineNo">2193</span>    if (server == null) return null;<a name="line.2193"></a>
+<span class="sourceLineNo">2194</span>    Configuration conf = server.getConfiguration();<a name="line.2194"></a>
+<span class="sourceLineNo">2195</span>    long keyUpdateInterval =<a name="line.2195"></a>
+<span class="sourceLineNo">2196</span>        conf.getLong("hbase.auth.key.update.interval", 24*60*60*1000);<a name="line.2196"></a>
+<span class="sourceLineNo">2197</span>    long maxAge =<a name="line.2197"></a>
+<span class="sourceLineNo">2198</span>        conf.getLong("hbase.auth.token.max.lifetime", 7*24*60*60*1000);<a name="line.2198"></a>
+<span class="sourceLineNo">2199</span>    return new AuthenticationTokenSecretManager(conf, server.getZooKeeper(),<a name="line.2199"></a>
+<span class="sourceLineNo">2200</span>        server.getServerName().toString(), keyUpdateInterval, maxAge);<a name="line.2200"></a>
+<span class="sourceLineNo">2201</span>  }<a name="line.2201"></a>
+<span class="sourceLineNo">2202</span><a name="line.2202"></a>
+<span class="sourceLineNo">2203</span>  public SecretManager&lt;? extends TokenIdentifier&gt; getSecretManager() {<a name="line.2203"></a>
+<span class="sourceLineNo">2204</span>    return this.secretManager;<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>  @SuppressWarnings("unchecked")<a name="line.2207"></a>
+<span class="sourceLineNo">2208</span>  public void setSecretManager(SecretManager&lt;? extends TokenIdentifier&gt; secretManager) {<a name="line.2208"></a>
+<span class="sourceLineNo">2209</span>    this.secretManager = (SecretManager&lt;TokenIdentifier&gt;) secretManager;<a name="line.2209"></a>
+<span class="sourceLineNo">2210</span>  }<a name="line.2210"></a>
+<span class="sourceLineNo">2211</span><a name="line.2211"></a>
+<span class="sourceLineNo">2212</span>  /**<a name="line.2212"></a>
+<span class="sourceLineNo">2213</span>   * This is a server side method, which is invoked over RPC. On success<a name="line.2213"></a>
+<span class="sourceLineNo">2214</span>   * the return response has protobuf response payload. On failure, the<a name="line.2214"></a>
+<span class="sourceLineNo">2215</span>   * exception name and the stack trace are returned in the protobuf response.<a name="line.2215"></a>
+<span class="sourceLineNo">2216</span>   */<a name="line.2216"></a>
+<span class="sourceLineNo">2217</span>  @Override<a name="line.2217"></a>
+<span class="sourceLineNo">2218</span>  public Pair&lt;Message, CellScanner&gt; call(BlockingService service, MethodDescriptor md,<a name="line.2218"></a>
+<span class="sourceLineNo">2219</span>      Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)<a name="line.2219"></a>
+<span class="sourceLineNo">2220</span>  throws IOException {<a name="line.2220"></a>
+<span class="sourceLineNo">2221</span>    try {<a name="line.2221"></a>
+<span class="sourceLineNo">2222</span>      status.setRPC(md.getName(), new Object[]{param}, receiveTime);<a name="line.2222"></a>
+<span class="sourceLineNo">2223</span>      // TODO: Review after we add in encoded data blocks.<a name="line.2223"></a>
+<span class="sourceLineNo">2224</span>      status.setRPCPacket(param);<a name="line.2224"></a>
+<span class="sourceLineNo">2225</span>      status.resume("Servicing call");<a name="line.2225"></a>
+<span class="sourceLineNo">2226</span>      //get an instance of the method arg type<a name="line.2226"></a>
+<span class="sourceLineNo">2227</span>      long startTime = System.currentTimeMillis();<a name="line.2227"></a>
+<span class="sourceLineNo">2228</span>      PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);<a name="line.2228"></a>
+<span class="sourceLineNo">2229</span>      Message result = service.callBlockingMethod(md, controller, param);<a name="line.2229"></a>
+<span class="sourceLineNo">2230</span>      long endTime = System.currentTimeMillis();<a name="line.2230"></a>
+<span class="sourceLineNo">2231</span>      int processingTime = (int) (endTime - startTime);<a name="line.2231"></a>
+<span class="sourceLineNo">2232</span>      int qTime = (int) (startTime - receiveTime);<a name="line.2232"></a>
+<span class="sourceLineNo">2233</span>      int totalTime = (int) (endTime - receiveTime);<a name="line.2233"></a>
+<span class="sourceLineNo">2234</span>      if (LOG.isTraceEnabled()) {<a name="line.2234"></a>
+<span class="sourceLineNo">2235</span>        LOG.trace(CurCall.get().toString() +<a name="line.2235"></a>
+<span class="sourceLineNo">2236</span>            ", response " + TextFormat.shortDebugString(result) +<a name="line.2236"></a>
+<span class="sourceLineNo">2237</span>            " queueTime: " + qTime +<a name="line.2237"></a>
+<span class="sourceLineNo">2238</span>            " processingTime: " + processingTime +<a name="line.2238"></a>
+<span class="sourceLineNo">2239</span>            " totalTime: " + totalTime);<a name="line.2239"></a>
+<span class="sourceLineNo">2240</span>      }<a name="line.2240"></a>
+<span class="sourceLineNo">2241</span>      long requestSize = param.getSerializedSize();<a name="line.2241"></a>
+<span class="sourceLineNo">2242</span>      long responseSize = result.getSerializedSize();<a name="line.2242"></a>
+<span class="sourceLineNo">2243</span>      metrics.dequeuedCall(qTime);<a name="line.2243"></a>
+<span class="sourceLineNo">2244</span>      metrics.processedCall(processingTime);<a name="line.2244"></a>
+<span class="sourceLineNo">2245</span>      metrics.totalCall(totalTime);<a name="line.2245"></a>
+<span class="sourceLineNo">2246</span>      metrics.receivedRequest(requestSize);<a name="line.2246"></a>
+<span class="sourceLineNo">2247</span>      metrics.sentResponse(responseSize);<a name="line.2247"></a>
+<span class="sourceLineNo">2248</span>      // log any RPC responses that are slower than the configured warn<a name="line.2248"></a>
+<span class="sourceLineNo">2249</span>      // response time or larger than configured warning size<a name="line.2249"></a>
+<span class="sourceLineNo">2250</span>      boolean tooSlow = (processingTime &gt; warnResponseTime &amp;&amp; warnResponseTime &gt; -1);<a name="line.2250"></a>
+<span class="sourceLineNo">2251</span>      boolean tooLarge = (responseSize &gt; warnResponseSize &amp;&amp; warnResponseSize &gt; -1);<a name="line.2251"></a>
+<span class="sourceLineNo">2252</span>      if (tooSlow || tooLarge) {<a name="line.2252"></a>
+<span class="sourceLineNo">2253</span>        // when tagging, we let TooLarge trump TooSmall to keep output simple<a name="line.2253"></a>
+<span class="sourceLineNo">2254</span>        // note that large responses will often also be slow.<a name="line.2254"></a>
+<span class="sourceLineNo">2255</span>        logResponse(new Object[]{param},<a name="line.2255"></a>
+<span class="sourceLineNo">2256</span>            md.getName(), md.getName() + "(" + param.getClass().getName() + ")",<a name="line.2256"></a>
+<span class="sourceLineNo">2257</span>            (tooLarge ? "TooLarge" : "TooSlow"),<a name="line.2257"></a>
+<span class="sourceLineNo">2258</span>            status.getClient(), startTime, processingTime, qTime,<a name="line.2258"></a>
+<span class="sourceLineNo">2259</span>            responseSize);<a name="line.2259"></a>
+<span class="sourceLineNo">2260</span>      }<a name="line.2260"></a>
+<span class="sourceLineNo">2261</span>      return new Pair&lt;Message, CellScanner&gt;(result, controller.cellScanner());<a name="line.2261"></a>
+<span class="sourceLineNo">2262</span>    } catch (Throwable e) {<a name="line.2262"></a>
+<span class="sourceLineNo">2263</span>      // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before<a name="line.2263"></a>
+<span class="sourceLineNo">2264</span>      // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't<a name="line.2264"></a>
+<span class="sourceLineNo">2265</span>      // need to pass it over the wire.<a name="line.2265"></a>
+<span class="sourceLineNo">2266</span>      if (e instanceof ServiceException) e = e.getCause();<a name="line.2266"></a>
 <span class="sourceLineNo">2267</span><a name="line.2267"></a>
-<span class="sourceLineNo">2268</span>      if (e instanceof LinkageError) throw new DoNotRetryIOException(e);<a name="line.2268"></a>
-<span class="sourceLineNo">2269</span>      if (e instanceof IOException) throw (IOException)e;<a name="line.2269"></a>
-<span class="sourceLineNo">2270</span>      LOG.error("Unexpected throwable object ", e);<a name="line.2270"></a>
-<span class="sourceLineNo">2271</span>      throw new IOException(e.getMessage(), e);<a name="line.2271"></a>
-<span class="sourceLineNo">2272</span>    }<a name="line.2272"></a>
-<span class="sourceLineNo">2273</span>  }<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>   * Logs an RPC response to the LOG file, producing valid JSON objects for<a name="line.2276"></a>
-<span class="sourceLineNo">2277</span>   * client Operations.<a name="line.2277"></a>
-<span class="sourceLineNo">2278</span>   * @param params The parameters received in the call.<a name="line.2278"></a>
-<span class="sourceLineNo">2279</span>   * @param methodName The name of the method invoked<a name="line.2279"></a>
-<span class="sourceLineNo">2280</span>   * @param call The string representation of the call<a name="line.2280"></a>
-<span class="sourceLineNo">2281</span>   * @param tag  The tag that will be used to indicate this event in the log.<a name="line.2281"></a>
-<span class="sourceLineNo">2282</span>   * @param clientAddress   The address of the client who made this call.<a name="line.2282"></a>
-<span class="sourceLineNo">2283</span>   * @param startTime       The time that the call was initiated, in ms.<a name="line.2283"></a>
-<span class="sourceLineNo">2284</span>   * @param processingTime  The duration that the call took to run, in ms.<a name="line.2284"></a>
-<span class="sourceLineNo">2285</span>   * @param qTime           The duration that the call spent on the queue<a name="line.2285"></a>
-<span class="sourceLineNo">2286</span>   *                        prior to being initiated, in ms.<a name="line.2286"></a>
-<span class="sourceLineNo">2287</span>   * @param responseSize    The size in bytes of the response buffer.<a name="line.2287"></a>
-<span class="sourceLineNo">2288</span>   */<a name="line.2288"></a>
-<span class="sourceLineNo">2289</span>  void logResponse(Object[] params, String methodName, String call, String tag,<a name="line.2289"></a>
-<span class="sourceLineNo">2290</span>      String clientAddress, long startTime, int processingTime, int qTime,<a name="line.2290"></a>
-<span class="sourceLineNo">2291</span>      long responseSize)<a name="line.2291"></a>
-<span class="sourceLineNo">2292</span>          throws IOException {<a name="line.2292"></a>
-<span class="sourceLineNo">2293</span>    // base information that is reported regardless of type of call<a name="line.2293"></a>
-<span class="sourceLineNo">2294</span>    Map&lt;String, Object&gt; responseInfo = new HashMap&lt;String, Object&gt;();<a name="line.2294"></a>
-<span class="sourceLineNo">2295</span>    responseInfo.put("starttimems", startTime);<a name="line.2295"></a>
-<span class="sourceLineNo">2296</span>    responseInfo.put("processingtimems", processingTime);<a name="line.2296"></a>
-<span class="sourceLineNo">2297</span>    responseInfo.put("queuetimems", qTime);<a name="line.2297"></a>
-<span class="sourceLineNo">2298</span>    responseInfo.put("responsesize", responseSize);<a name="line.2298"></a>
-<span class="sourceLineNo">2299</span>    responseInfo.put("client", clientAddress);<a name="line.2299"></a>
-<span class="sourceLineNo">2300</span>    responseInfo.put("class", server == null? "": server.getClass().getSimpleName());<a name="line.2300"></a>
-<span class="sourceLineNo">2301</span>    responseInfo.put("method", methodName);<a name="line.2301"></a>
-<span class="sourceLineNo">2302</span>    if (params.length == 2 &amp;&amp; server instanceof HRegionServer &amp;&amp;<a name="line.2302"></a>
-<span class="sourceLineNo">2303</span>        params[0] instanceof byte[] &amp;&amp;<a name="line.2303"></a>
-<span class="sourceLineNo">2304</span>        params[1] instanceof Operation) {<a name="line.2304"></a>
-<span class="sourceLineNo">2305</span>      // if the slow process is a query, we want to log its table as well<a name="line.2305"></a>
-<span class="sourceLineNo">2306</span>      // as its own fingerprint<a name="line.2306"></a>
-<span class="sourceLineNo">2307</span>      TableName tableName = TableName.valueOf(<a name="line.2307"></a>
-<span class="sourceLineNo">2308</span>          HRegionInfo.parseRegionName((byte[]) params[0])[0]);<a name="line.2308"></a>
-<span class="sourceLineNo">2309</span>      responseInfo.put("table", tableName.getNameAsString());<a name="line.2309"></a>
-<span class="sourceLineNo">2310</span>      // annotate the response map with operation details<a name="line.2310"></a>
-<span class="sourceLineNo">2311</span>      responseInfo.putAll(((Operation) params[1]).toMap());<a name="line.2311"></a>
-<span class="sourceLineNo">2312</span>      // report to the log file<a name="line.2312"></a>
-<span class="sourceLineNo">2313</span>      LOG.warn("(operation" + tag + "): " +<a name="line.2313"></a>
-<span class="sourceLineNo">2314</span>               MAPPER.writeValueAsString(responseInfo));<a name="line.2314"></a>
-<span class="sourceLineNo">2315</span>    } else if (params.length == 1 &amp;&amp; server instanceof HRegionServer &amp;&amp;<a name="line.2315"></a>
-<span class="sourceLineNo">2316</span>        params[0] instanceof Operation) {<a name="line.2316"></a>
-<span class="sourceLineNo">2317</span>      // annotate the response map with operation details<a name="line.2317"></a>
-<span class="sourceLineNo">2318</span>      responseInfo.putAll(((Operation) params[0]).toMap());<a name="line.2318"></a>
-<span class="sourceLineNo">2319</span>      // report to the log file<a name="line.2319"></a>
-<span class="sourceLineNo">2320</span>      LOG.warn("(operation" + tag + "): " +<a name="line.2320"></a>
-<span class="sourceLineNo">2321</span>               MAPPER.writeValueAsString(responseInfo));<a name="line.2321"></a>
-<span class="sourceLineNo">2322</span>    } else {<a name="line.2322"></a>
-<span class="sourceLineNo">2323</span>      // can't get JSON details, so just report call.toString() along with<a name="line.2323"></a>
-<span class="sourceLineNo">2324</span>      // a more generic tag.<a name="line.2324"></a>
-<span class="sourceLineNo">2325</span>      responseInfo.put("call", call);<a name="line.2325"></a>
-<span class="sourceLineNo">2326</span>      LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo));<a name="line.2326"></a>
-<span class="sourceLineNo">2327</span>    }<a name="line.2327"></a>
-<span class="sourceLineNo">2328</span>  }<a name="line.2328"></a>
-<span class="sourceLineNo">2329</span><a name="line.2329"></a>
-<span class="sourceLineNo">2330</span>  /** Stops the service.  No new calls will be handled after this is called. */<a name="line.2330"></a>
-<span class="sourceLineNo">2331</span>  @Override<a name="line.2331"></a>
-<span class="sourceLineNo">2332</span>  public synchronized void stop() {<a name="line.2332"></a>
-<span class="sourceLineNo">2333</span>    LOG.info("Stopping server on " + port);<a name="line.2333"></a>
-<span class="sourceLineNo">2334</span>    running = false;<a name="line.2334"></a>
-<span class="sourceLineNo">2335</span>    if (authTokenSecretMgr != null) {<a name="line.2335"></a>
-<span class="sourceLineNo">2336</span>      authTokenSecretMgr.stop();<a name="line.2336"></a>
-<span class="sourceLineNo">2337</span>      authTokenSecretMgr = null;<a name="line.2337"></a>
-<span class="sourceLineNo">2338</span>    }<a name="line.2338"></a>
-<span class="sourceLineNo">2339</span>    listener.interrupt();<a name="line.2339"></a>
-<span class="sourceLineNo">2340</span>    listener.doStop();<a name="line.2340"></a>
-<span class="sourceLineNo">2341</span>    responder.interrupt();<a name="line.2341"></a>
-<span class="sourceLineNo">2342</span>    scheduler.stop();<a name="line.2342"></a>
-<span class="sourceLineNo">2343</span>    notifyAll();<a name="line.2343"></a>
-<span class="sourceLineNo">2344</span>  }<a name="line.2344"></a>
-<span class="sourceLineNo">2345</span><a name="line.2345"></a>
-<span class="sourceLineNo">2346</span>  /** Wait for the server to be stopped.<a name="line.2346"></a>
-<span class="sourceLineNo">2347</span>   * Does not wait for all subthreads to finish.<a name="line.2347"></a>
-<span class="sourceLineNo">2348</span>   *  See {@link #stop()}.<a name="line.2348"></a>
-<span class="sourceLineNo">2349</span>   * @throws InterruptedException e<a name="line.2349"></a>
-<span class="sourceLineNo">2350</span>   */<a name="line.2350"></a>
-<span class="sourceLineNo">2351</span>  @Override<a name="line.2351"></a>
-<span class="sourceLineNo">2352</span>  public synchronized void join() throws InterruptedException {<a name="line.2352"></a>
-<span class="sourceLineNo">2353</span>    while (running) {<a name="line.2353"></a>
-<span class="sourceLineNo">2354</span>      wait();<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><a name="line.2357"></a>
-<span class="sourceLineNo">2358</span>  /**<a name="line.2358"></a>
-<span class="sourceLineNo">2359</span>   * Return the socket (ip+port) on which the RPC server is listening to. May return null if<a name="line.2359"></a>
-<span class="sourceLineNo">2360</span>   * the listener channel is closed.<a name="line.2360"></a>
-<span class="sourceLineNo">2361</span>   * @return the socket (ip+port) on which the RPC server is listening to, or null if this<a name="line.2361"></a>
-<span class="sourceLineNo">2362</span>   * information cannot be determined<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 synchronized InetSocketAddress getListenerAddress() {<a name="line.2365"></a>
-<span class="sourceLineNo">2366</span>    if (listener == null) {<a name="line.2366"></a>
-<span class="sourceLineNo">2367</span>      return null;<a name="line.2367"></a>
-<span class="sourceLineNo">2368</span>    }<a name="line.2368"></a>
-<span class="sourceLineNo">2369</span>    return listener.getAddress();<a name="line.2369"></a>
-<span class="sourceLineNo">2370</span>  }<a name="line.2370"></a>
-<span class="sourceLineNo">2371</span><a name="line.2371"></a>
-<span class="sourceLineNo">2372</span>  /**<a name="line.2372"></a>
-<span class="sourceLineNo">2373</span>   * Set the handler for calling out of RPC for error conditions.<a name="line.2373"></a>
-<span class="sourceLineNo">2374</span>   * @param handler the handler implementation<a name="line.2374"></a>
-<span class="sourceLineNo">2375</span>   */<a name="line.2375"></a>
-<span class="sourceLineNo">2376</span>  @Override<a name="line.2376"></a>
-<span class="sourceLineNo">2377</span>  public void setErrorHandler(HBaseRPCErrorHandler handler) {<a name="line.2377"></a>
-<span class="sourceLineNo">2378</span>    this.errorHandler = handler;<a name="line.2378"></a>
-<span class="sourceLineNo">2379</span>  }<a name="line.2379"></a>
-<span class="sourceLineNo">2380</span><a name="line.2380"></a>
-<span class="sourceLineNo">2381</span>  @Override<a name="line.2381"></a>
-<span class="sourceLineNo">2382</span>  public HBaseRPCErrorHandler getErrorHandler() {<a name="line.2382"></a>
-<span class="sourceLineNo">2383</span>    return this.errorHandler;<a name="line.2383"></a>
-<span class="sourceLineNo">2384</span>  }<a name="line.2384"></a>
-<span class="sourceLineNo">2385</span><a name="line.2385"></a>
-<span class="sourceLineNo">2386</span>  /**<a name="line.2386"></a>
-<span class="sourceLineNo">2387</span>   * Returns the metrics instance for reporting RPC call statistics<a name="line.2387"></a>
-<span class="sourceLineNo">2388</span>   */<a name="line.2388"></a>
-<span class="sourceLineNo">2389</span>  @Override<a name="line.2389"></a>
-<span class="sourceLineNo">2390</span>  public MetricsHBaseServer getMetrics() {<a name="line.2390"></a>
-<span class="sourceLineNo">2391</span>    return metrics;<a name="line.2391"></a>
-<span class="sourceLineNo">2392</span>  }<a name="line.2392"></a>
-<span class="sourceLineNo">2393</span><a name="line.2393"></a>
-<span class="sourceLineNo">2394</span>  @Override<a name="line.2394"></a>
-<span class="sourceLineNo">2395</span>  public void addCallSize(final long diff) {<a name="line.2395"></a>
-<span class="sourceLineNo">2396</span>    this.callQueueSize.add(diff);<a name="line.2396"></a>
-<span class="sourceLineNo">2397</span>  }<a name="line.2397"></a>
-<span class="sourceLineNo">2398</span><a name="line.2398"></a>
-<span class="sourceLineNo">2399</span>  /**<a name="line.2399"></a>
-<span class="sourceLineNo">2400</span>   * Authorize the incoming client connection.<a name="line.2400"></a>
-<span class="sourceLineNo">2401</span>   *<a name="line.2401"></a>
-<span class="sourceLineNo">2402</span>   * @param user client user<a name="line.2402"></a>
-<span class="sourceLineNo">2403</span>   * @param connection incoming connection<a name="line.2403"></a>
-<span class="sourceLineNo">2404</span>   * @param addr InetAddress of incoming connection<a name="line.2404"></a>
-<span class="sourceLineNo">2405</span>   * @throws org.apache.hadoop.security.authorize.AuthorizationException<a name="line.2405"></a>
-<span class="sourceLineNo">2406</span>   *         when the client isn't authorized to talk the protocol<a name="line.2406"></a>
-<span class="sourceLineNo">2407</span>   */<a name="line.2407"></a>
-<span class="sourceLineNo">2408</span>  public synchronized void authorize(UserGroupInformation user, ConnectionHeader connection,<a name="line.2408"></a>
-<span class="sourceLineNo">2409</span>      InetAddress addr)<a name="line.2409"></a>
-<span class="sourceLineNo">2410</span>  throws AuthorizationException {<a name="line.2410"></a>
-<span class="sourceLineNo">2411</span>    if (authorize) {<a name="line.2411"></a>
-<span class="sourceLineNo">2412</span>      Class&lt;?&gt; c = getServiceInterface(services, connection.getServiceName());<a name="line.2412"></a>
-<span class="sourceLineNo">2413</span>      this.authManager.authorize(user != null ? user : null, c, getConf(), addr);<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><a name="line.2416"></a>
-<span class="sourceLineNo">2417</span>  /**<a name="line.2417"></a>
-<span class="sourceLineNo">2418</span>   * When the read or write buffer size is larger than this limit, i/o will be<a name="line.2418"></a>
-<span class="sourceLineNo">2419</span>   * done in chunks of this size. Most RPC requests and responses would be<a name="line.2419"></a>
-<span class="sourceLineNo">2420</span>   * be smaller.<a name="line.2420"></a>
-<span class="sourceLineNo">2421</span>   */<a name="line.2421"></a>
-<span class="sourceLineNo">2422</span>  private static int NIO_BUFFER_LIMIT = 64 * 1024; //should not be more than 64KB.<a name="line.2422"></a>
-<span class="sourceLineNo">2423</span><a name="line.2423"></a>
-<span class="sourceLineNo">2424</span>  /**<a name="line.2424"></a>
-<span class="sourceLineNo">2425</span>   * This is a wrapper around {@link java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)}.<a name="line.2425"></a>
-<span class="sourceLineNo">2426</span>   * If the amount of data is large, it writes to channel in smaller chunks.<a name="line.2426"></a>
-<span class="sourceLineNo">2427</span>   * This is to avoid jdk from creating many direct buffers as the size of<a name="line.2427"></a>
-<span class="sourceLineNo">2428</span>   * buffer increases. This also minimizes extra copies in NIO layer<a name="line.2428"></a>
-<span class="sourceLineNo">2429</span>   * as a result of multiple write operations required to write a large<a name="line.2429"></a>
-<span class="sourceLineNo">2430</span>   * buffer.<a name="line.2430"></a>
-<span class="sourceLineNo">2431</span>   *<a name="line.2431"></a>
-<span class="sourceLineNo">2432</span>   * @param channel writable byte channel to write to<a name="line.2432"></a>
-<span class="sourceLineNo">2433</span>   * @param bufferChain Chain of buffers to write<a name="line.2433"></a>
-<span class="sourceLineNo">2434</span>   * @return number of bytes written<a name="line.2434"></a>
-<span class="sourceLineNo">2435</span>   * @throws java.io.IOException e<a name="line.2435"></a>
-<span class="sourceLineNo">2436</span>   * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)<a name="line.2436"></a>
-<span class="sourceLineNo">2437</span>   */<a name="line.2437"></a>
-<span class="sourceLineNo">2438</span>  protected long channelWrite(GatheringByteChannel channel, BufferChain bufferChain)<a name="line.2438"></a>
-<span class="sourceLineNo">2439</span>  throws IOException {<a name="line.2439"></a>
-<span class="sourceLineNo">2440</span>    long count =  bufferChain.write(channel, NIO_BUFFER_LIMIT);<a name="line.2440"></a>
-<span class="sourceLineNo">2441</span>    if (count &gt; 0) this.metrics.sentBytes(count);<a name="line.2441"></a>
-<span class="sourceLineNo">2442</span>    return count;<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>  /**<a name="line.2445"></a>
-<span class="sourceLineNo">2446</span>   * This is a wrapper around {@link java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)}.<a name="line.2446"></a>
-<span class="sourceLineNo">2447</span>   * If the amount of data is large, it writes to channel in smaller chunks.<a name="line.2447"></a>
-<span class="sourceLineNo">2448</span>   * This is to avoid jdk from creating many direct buffers as the size of<a name="line.2448"></a>
-<span class="sourceLineNo">2449</span>   * ByteBuffer increases. There should not be any performance degredation.<a name="line.2449"></a>
-<span class="sourceLineNo">2450</span>   *<a name="line.2450"></a>
-<span class="sourceLineNo">2451</span>   * @param channel writable byte channel to write on<a name="line.2451"></a>
-<span class="sourceLineNo">2452</span>   * @param buffer buffer to write<a name="line.2452"></a>
-<span class="sourceLineNo">2453</span>   * @return number of bytes written<a name="line.2453"></a>
-<span class="sourceLineNo">2454</span>   * @throws java.io.IOException e<a name="line.2454"></a>
-<span class="sourceLineNo">2455</span>   * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)<a name="line.2455"></a>
-<span class="sourceLineNo">2456</span>   */<a name="line.2456"></a>
-<span class="sourceLineNo">2457</span>  protected int channelRead(ReadableByteChannel channel,<a name="line.2457"></a>
-<span class="sourceLineNo">2458</span>                                   ByteBuffer buffer) throws IOException {<a name="line.2458"></a>
-<span class="sourceLineNo">2459</span><a name="line.2459"></a>
-<span class="sourceLineNo">2460</span>    int count = (buffer.remaining() &lt;= NIO_BUFFER_LIMIT) ?<a name="line.2460"></a>
-<span class="sourceLineNo">2461</span>           channel.read(buffer) : channelIO(channel, null, buffer);<a name="line.2461"></a>
-<span class="sourceLineNo">2462</span>    if (count &gt; 0) {<a name="line.2462"></a>
-<span class="sourceLineNo">2463</span>      metrics.receivedBytes(count);<a name="line.2463"></a>
-<span class="sourceLineNo">2464</span>    }<a name="line.2464"></a>
-<span class="sourceLineNo">2465</span>    return count;<a name="line.2465"></a>
-<span class="sourceLineNo">2466</span>  }<a name="line.2466"></a>
-<span class="sourceLineNo">2467</span><a name="line.2467"></a>
-<span class="sourceLineNo">2468</span>  /**<a name="line.2468"></a>
-<span class="sourceLineNo">2469</span>   * Helper for {@link #channelRead(java.nio.channels.ReadableByteChannel, java.nio.ByteBuffer)}<a name="line.2469"></a>
-<span class="sourceLineNo">2470</span>   * and {@link #channelWrite(GatheringByteChannel, BufferChain)}. Only<a name="line.2470"></a>
-<span class="sourceLineNo">2471</span>   * one of readCh or writeCh should be non-null.<a name="line.2471"></a>
-<span class="sourceLineNo">2472</span>   *<a name="line.2472"></a>
-<span class="sourceLineNo">2473</span>   * @param readCh read channel<a name="line.2473"></a>
-<span class="sourceLineNo">2474</span>   * @param writeCh write channel<a name="line.2474"></a>
-<span class="sourceLineNo">2475</span>   * @param buf buffer to read or write into/out of<a name="line.2475"></a>
-<span class="sourceLineNo">2476</span>   * @return bytes written<a name="line.2476"></a>
-<span class="sourceLineNo">2477</span>   * @throws java.io.IOException e<a name="line.2477"></a>
-<span class="sourceLineNo">2478</span>   * @see #channelRead(java.nio.channels.ReadableByteChannel, java.nio.ByteBuffer)<a name="line.2478"></a>
-<span class="sourceLineNo">2479</span>   * @see #channelWrite(GatheringByteChannel, BufferChain)<a name="line.2479"></a>
-<span class="sourceLineNo">2480</span>   */<a name="line.2480"></a>
-<span class="sourceLineNo">2481</span>  private static int channelIO(ReadableByteChannel readCh,<a name="line.2481"></a>
-<span class="sourceLineNo">2482</span>                               WritableByteChannel writeCh,<a name="line.2482"></a>
-<span class="sourceLineNo">2483</span>                               ByteBuffer buf) throws IOException {<a name="line.2483"></a>
-<span class="sourceLineNo">2484</span><a name="line.2484"></a>
-<span class="sourceLineNo">2485</span>    int originalLimit = buf.limit();<a name="line.2485"></a>
-<span class="sourceLineNo">2486</span>    int initialRemaining = buf.remaining();<a name="line.2486"></a>
-<span class="sourceLineNo">2487</span>    int ret = 0;<a name="line.2487"></a>
-<span class="sourceLineNo">2488</span><a name="line.2488"></a>
-<span class="sourceLineNo">2489</span>    while (buf.remaining() &gt; 0) {<a name="line.2489"></a>
-<span class="sourceLineNo">2490</span>      try {<a name="line.2490"></a>
-<span class="sourceLineNo">2491</span>        int ioSize = Math.min(buf.remaining(), NIO_BUFFER_LIMIT);<a name="line.2491"></a>
-<span class="sourceLineNo">2492</span>        buf.limit(buf.position() + ioSize);<a name="line.2492"></a>
-<span class="sourceLineNo">2493</span><a name="line.2493"></a>
-<span class="sourceLineNo">2494</span>        ret = (readCh == null) ? writeCh.write(buf) : readCh.read(buf);<a name="line.2494"></a>
-<span class="sourceLineNo">2495</span><a name="line.2495"></a>
-<span class="sourceLineNo">2496</span>        if (ret &lt; ioSize) {<a name="line.2496"></a>
-<span class="sourceLineNo">2497</span>          break;<a name="line.2497"></a>
-<span class="sourceLineNo">2498</span>        }<a name="line.2498"></a>
-<span class="sourceLineNo">2499</span><a name="line.2499"></a>
-<span class="sourceLineNo">2500</span>      } finally {<a name="line.2500"></a>
-<span class="sourceLineNo">2501</span>        buf.limit(originalLimit);<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><a name="line.2504"></a>
-<span class="sourceLineNo">2505</span>    int nBytes = initialRemaining - buf.remaining();<a name="line.2505"></a>
-<span class="sourceLineNo">2506</span>    return (nBytes &gt; 0) ? nBytes : ret;<a name="line.2506"></a>
-<span class="sourceLineNo">2507</span>  }<a name="line.2507"></a>
-<span class="sourceLineNo">2508</span><a name="line.2508"></a>
-<span class="sourceLineNo">2509</span>  /**<a name="line.2509"></a>
-<span class="sourceLineNo">2510</span>   * Needed for features such as delayed calls.  We need to be able to store the current call<a name="line.2510"></a>
-<span class="sourceLineNo">2511</span>   * so that we can complete it later or ask questions of what is supported by the current ongoing<a name="line.2511"></a>
-<span class="sourceLineNo">2512</span>   * call.<a name="line.2512"></a>
-<span class="sourceLineNo">2513</span>   * @return An RpcCallContext backed by the currently ongoing call (gotten from a thread local)<a name="line.2513"></a>
-<span class="sourceLineNo">2514</span>   */<a name="line.2514"></a>
-<span class="sourceLineNo">2515</span>  public static RpcCallContext getCurrentCall() {<a name="line.2515"></a>
-<span class="sourceLineNo">2516</span>    return CurCall.get();<a name="line.2516"></a>
-<span class="sourceLineNo">2517</span>  }<a name="line.2517"></a>
-<span class="sourceLineNo">2518</span><a name="line.2518"></a>
-<span class="sourceLineNo">2519</span>  public static boolean isInRpcCallContext() {<a name="line.2519"></a>
-<span class="sourceLineNo">2520</span>    return CurCall.get() != null;<a name="line.2520"></a>
-<span class="sourceLineNo">2521</span>  }<a name="line.2521"></a>
-<span class="sourceLineNo">2522</span><a name="line.2522"></a>
-<span class="sourceLineNo">2523</span>  /**<a name="line.2523"></a>
-<span class="sourceLineNo">2524</span>   * Returns the user credentials associated with the current RPC request or<a name="line.2524"></a>
-<span class="sourceLineNo">2525</span>   * &lt;code&gt;null&lt;/code&gt; if no credentials were provided.<a name="line.2525"></a>
-<span class="sourceLineNo">2526</span>   * @return A User<a name="line.2526"></a>
-<span class="sourceLineNo">2527</span>   */<a name="line.2527"></a>
-<span class="sourceLineNo">2528</span>  public static User getRequestUser() {<a name="line.2528"></a>
-<span class="sourceLineNo">2529</span>    RpcCallContext ctx = getCurrentCall();<a name="line.2529"></a>
-<span class="sourceLineNo">2530</span>    return ctx == null? null: ctx.getRequestUser();<a name="line.2530"></a>
-<span class="sourceLineNo">2531</span>  }<a name="line.2531"></a>
-<span class="sourceLineNo">2532</span><a name="line.2532"></a>
-<span class="sourceLineNo">2533</span>  /**<a name="line.2533"></a>
-<span class="sourceLineNo">2534</span>   * Returns the username for any user associated with the current RPC<a name="line.2534"></a>
-<span class="sourceLineNo">2535</span>   * request or &lt;code&gt;null&lt;/code&gt; if no user is set.<a name="line.2535"></a>
-<span class="sourceLineNo">2536</span>   */<a name="line.2536"></a>
-<span class="sourceLineNo">2537</span>  public static String getRequestUserName() {<a name="line.2537"></a>
-<span class="sourceLineNo">2538</span>    User user = getRequestUser();<a name="line.2538"></a>
-<span class="sourceLineNo">2539</span>    return user == null? null: user.getShortName();<a name="line.2539"></a>
-<span class="sourceLineNo">2540</span>  }<a name="line.2540"></a>
-<span class="sourceLineNo">2541</span><a name="line.2541"></a>
-<span class="sourceLineNo">2542</span>  /**<a name="line.2542"></a>
-<span class="sourceLineNo">2543</span>   * @return Address of remote client if a request is ongoing, else null<a name="line.2543"></a>
-<span class="sourceLineNo">2544</span>   */<a name="line.2544"></a>
-<span class="sourceLineNo">2545</span>  public static InetAddress getRemoteAddress() {<a name="line.2545"></a>
-<span class="sourceLineNo">2546</span>    RpcCallContext ctx = getCurrentCall();<a name="line.2546"></a>
-<span class="sourceLineNo">2547</span>    return ctx == null? null: ctx.getRemoteAddress();<a name="line.2547"></a>
-<span class="sourceLineNo">2548</span>  }<a name="line.2548"></a>
-<span class="sourceLineNo">2549</span><a name="line.2549"></a>
-<span class="sourceLineNo">2550</span>  /**<a name="line.2550"></a>
-<span class="sourceLineNo">2551</span>   * @param serviceName Some arbitrary string that represents a 'service'.<a name="line.2551"></a>
-<span class="sourceLineNo">2552</span>   * @param services Available service instances<a name="line.2552"></a>
-<span class="sourceLineNo">2553</span>   * @return Matching BlockingServiceAndInterface pair<a name="line.2553"></a>
-<span class="sourceLineNo">2554</span>   */<a name="line.2554"></a>
-<span class="sourceLineNo">2555</span>  static BlockingServiceAndInterface getServiceAndInterface(<a name="line.2555"></a>
-<span class="sourceLineNo">2556</span>      final List&lt;BlockingServiceAndInterface&gt; services, final String serviceName) {<a name="line.2556"></a>
-<span class="sourceLineNo">2557</span>    for (BlockingServiceAndInterface bs : services) {<a name="line.2557"></a>
-<span class="sourceLineNo">2558</span>      if (bs.getBlockingService().getDescriptorForType().getName().equals(serviceName)) {<a name="line.2558"></a>
-<span class="sourceLineNo">2559</span>        return bs;<a name="line.2559"></a>
-<span class="sourceLineNo">2560</span>      }<a name="line.2560"></a>
-<span class="sourceLineNo">2561</span>    }<a name="line.2561"></a>
-<span class="sourceLineNo">2562</span>    return null;<a name="line.2562"></a>
-<span class="sourceLineNo">2563</span>  }<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>   * @param serviceName Some arbitrary string that represents a 'service'.<a name="line.2566"></a>
-<span class="sourceLineNo">2567</span>   * @param services Available services and their service interfaces.<a name="line.2567"></a>
-<span class="sourceLineNo">2568</span>   * @return Service interface class for &lt;code&gt;serviceName&lt;/code&gt;<a name="line.2568"></a>
-<span class="sourceLineNo">2569</span>   */<a name="line.2569"></a>
-<span class="sourceLineNo">2570</span>  static Class&lt;?&gt; getServiceInterface(<a name="line.2570"></a>
-<span class="sourceLineNo">2571</span>      final List&lt;BlockingServiceAndInterface&gt; services,<a name="line.2571"></a>
-<span class="sourceLineNo">2572</span>      final String serviceName) {<a name="line.2572"></a>
-<span class="sourceLineNo">2573</span>    BlockingServiceAndInterface bsasi =<a name="line.2573"></a>
-<span class="sourceLineNo">2574</span>        getServiceAndInterface(services, serviceName);<a name="line.2574"></a>
-<span class="sourceLineNo">2575</span>    return bsasi == null? null: bsasi.getServiceInterface();<a name="line.2575"></a>
-<span class="sourceLineNo">2576</span>  }<a name="line.2576"></a>
-<span class="sourceLineNo">2577</span><a name="line.2577"></a>
-<span class="sourceLineNo">2578</span>  /**<a name="line.2578"></a>
-<span class="sourceLineNo">2579</span>   * @param serviceName Some arbitrary string that represents a 'service'.<a name="line.2579"></a>
-<span class="sourceLineNo">2580</span>   * @param services Available services and their service interfaces.<a name="line.2580"></a>
-<span class="sourceLineNo">2581</span>   * @return BlockingService that goes with the passed &lt;code&gt;serviceName&lt;/code&gt;<a name="line.2581"></a>
-<span class="sourceLineNo">2582</span>   */<a name="line.2582"></a>
-<span class="sourceLineNo">2583</span>  static BlockingService getService(<a name="line.2583"></a>
-<span class="sourceLineNo">2584</span>      final List&lt;BlockingServiceAndInterface&gt; services,<a name="line.2584"></a>
-<span class="sourceLineNo">2585</span>      final String serviceName) {<a name="line.2585"></a>
-<span class="sourceLineNo">2586</span>    BlockingServiceAndInterface bsasi =<a name="line.2586"></a>
-<span class="sourceLineNo">2587</span>        getServiceAndInterface(services, serviceName);<a name="line.2587"></a>
-<span class="sourceLineNo">2588</span>    return bsasi == null? null: bsasi.getBlockingService();<a name="line.2588"></a>
-<span class="sourceLineNo">2589</span>  }<a name="line.2589"></a>
-<span class="sourceLineNo">2590</span><a name="line.2590"></a>
-<span class="sourceLineNo">2591</span>  static MonitoredRPCHandler getStatus() {<a name="line.2591"></a>
-<span class="sourceLineNo">2592</span>    // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.<a name="line.2592"></a>
-<span class="sourceLineNo">2593</span>    MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();<a name="line.2593"></a>
-<span class="sourceLineNo">2594</span>    if (status != null) {<a name="line.2594"></a>
-<span class="sourceLineNo">2595</span>      return status;<a name="line.2595"></a>
-<span class="sourceLineNo">2596</span>    }<a name="line.2596"></a>
-<span class="sourceLineNo">2597</span>    status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());<a name="line.2597"></a>
-<span class="sourceLineNo">2598</span>    status.pause("Waiting for a call");<a name="line.2598"></a>
-<span class="sourceLineNo">2599</span>    RpcServer.MONITORED_RPC.set(status);<a name="line.2599"></a>
-<span class="sourceLineNo">2600</span>    return status;<a name="line.2600"></a>
-<span class="sourceLineNo">2601</span>  }<a name="line.2601"></a>
-<span class="sourceLineNo">2602</span><a name="line.2602"></a>
-<span class="sourceLineNo">2603</span>  /** Returns the remote side ip address when invoked inside an RPC<a name="line.2603"></a>
-<span class="sourceLineNo">2604</span>   *  Returns null incase of an error.<a name="line.2604"></a>
-<span class="sourceLineNo">2605</span>   *  @return InetAddress<a name="line.2605"></a>
-<span class="sourceLineNo">2606</span>   */<a name="line.2606"></a>
-<span class="sourceLineNo">2607</span>  public static InetAddress getRemoteIp() {<a name="line.2607"></a>
-<span class="sourceLineNo">2608</span>    Call call = CurCall.get();<a name="line.2608"></a>
-<span class="sourceLineNo">2609</span>    if (call != null &amp;&amp; call.connection != null &amp;&amp; call.connection.socket != null) {<a name="line.2609"></a>
-<span class="sourceLineNo">2610</span>      return call.connection.socket.getInetAddress();<a name="line.2610"></a>
-<span class="sourceLineNo">2611</span>    }<a name="line.2611"></a>
-<span class="sourceLineNo">2612</span>    return null;<a name="line.2612"></a>
-<span class="sourceLineNo">2613</span>  }<a name="line.2613"></a>
-<span class="sourceLineNo">2614</span><a name="line.2614"></a>
-<span class="sourceLineNo">2615</span><a name="line.2615"></a>
-<span class="sourceLineNo">2616</span>  /**<a name="line.2616"></a>
-<span class="sourceLineNo">2617</span>   * A convenience method to bind to a given address and report<a name="line.2617"></a>
-<span class="sourceLineNo">2618</span>   * better exceptions if the address is not a valid host.<a name="line.2618"></a>
-<span class="sourceLineNo">2619</span>   * @param socket the socket to bind<a name="line.2619"></a>
-<span class="sourceLineNo">2620</span>   * @param address the address to bind to<a name="line.2620"></a>
-<span class="sourceLineNo">2621</span>   * @param backlog the number of connections allowed in the queue<a name="line.2621"></a>
-<span class="sourceLineNo">2622</span>   * @throws BindException if the address can't be bound<a name="line.2622"></a>
-<span class="sourceLineNo">2623</span>   * @throws UnknownHostException if the address isn't a valid host name<a name="line.2623"></a>
-<span class="sourceLineNo">2624</span>   * @throws IOException other random errors from bind<a name="line.2624"></a>
-<span class="sourceLineNo">2625</span>   */<a name="line.2625"></a>
-<span class="sourceLineNo">2626</span>  public static void bind(ServerSocket socket, InetSocketAddress address,<a name="line.2626"></a>
-<span class="sourceLineNo">2627</span>                          int backlog) throws IOException {<a name="line.2627"></a>
-<span class="sourceLineNo">2628</span>    try {<a name="line.2628"></a>
-<span class="sourceLineNo">2629</span>      socket.bind(address, backlog);<a name="line.2629"></a>
-<span class="sourceLineNo">2630</span>    } catch (BindException e) {<a name="line.2630"></a>
-<span class="sourceLineNo">2631</span>      BindException bindException =<a name="line.2631"></a>
-<span class="sourceLineNo">2632</span>        new BindException("Problem binding to " + address + " : " +<a name="line.2632"></a>
-<span class="sourceLineNo">2633</span>            e.getMessage());<a name="line.2633"></a>
-<span class="sourceLineNo">2634</span>      bindException.initCause(e);<a name="line.2634"></a>
-<span class="sourceLineNo">2635</span>      throw bindException;<a name="line.2635"></a>
-<span class="sourceLineNo">2636</span>    } catch (SocketException e) {<a name="line.2636"></a>
-<span class="sourceLineNo">2637</span>      // If they try to bind to a different host's address, give a better<a name="line.2637"></a>
-<span class="sourceLineNo">2638</span>      // error message.<a name="line.2638"></a>
-<span class="sourceLineNo">2639</span>      if ("Unresolved address".equals(e.getMessage())) {<a name="line.2639"></a>
-<span class="sourceLineNo">2640</span>        throw new UnknownHostException("Invalid hostname for server: " +<a name="line.2640"></a>
-<span class="sourceLineNo">2641</span>                                       address.getHostName());<a name="line.2641"></a>
-<span class="sourceLineNo">2642</span>      }<a name="line.2642"></a>
-<span class="sourceLineNo">2643</span>      throw e;<a name="line.2643"></a>
-<span class="sourceLineNo">2644</span>    }<a name="line.2644"></a>
-<span class="sourceLineNo">2645</span>  }<a name="line.2645"></a>
-<span class="sourceLineNo">2646</span><a name="line.2646"></a>
-<span class="sourceLineNo">2647</span>  @Override<a name="line.2647"></a>
-<span class="sourceLineNo">2648</span>  public RpcScheduler getScheduler() {<a name="line.2648"></a>
-<span class="sourceLineNo">2649</span>    return scheduler;<a name="line.2649"></a>
-<span class="sourceLineNo">2650</span>  }<a name="line.2650"></a>
-<span class="sourceLineNo">2651</span>}<a name="line.2651"></a>
+<span class="sourceLineNo">2268</span>      // increment the number of requests that were exceptions.<a name="line.2268"></a>
+<span class="sourceLineNo">2269</span>      metrics.exception(e);<a name="line.2269"></a>
+<span class="sourceLineNo">2270</span><a name="line.2270"></a>
+<span class="sourceLineNo">2271</span>      if (e instanceof LinkageError) throw new DoNotRetryIOException(e);<a name="line.2271"></a>
+<span class="sourceLineNo">2272</span>      if (e instanceof IOException) throw (IOException)e;<a name="line.2272"></a>
+<span class="sourceLineNo">2273</span>      LOG.error("Unexpected throwable object ", e);<a name="line.2273"></a>
+<span class="sourceLineNo">2274</span>      throw new IOException(e.getMessage(), e);<a name="line.2274"></a>
+<span class="sourceLineNo">2275</span>    }<a name="line.2275"></a>
+<span class="sourceLineNo">2276</span>  }<a name="line.2276"></a>
+<span class="sourceLineNo">2277</span><a name="line.2277"></a>
+<span class="sourceLineNo">2278</span>  /**<a name="line.2278"></a>
+<span class="sourceLineNo">2279</span>   * Logs an RPC response to the LOG file, producing valid JSON objects for<a name="line.2279"></a>
+<span class="sourceLineNo">2280</span>   * client Operations.<a name="line.2280"></a>
+<span class="sourceLineNo">2281</span>   * @param params The parameters received in the call.<a name="line.2281"></a>
+<span class="sourceLineNo">2282</span>   * @param methodName The name of the method invoked<a name="line.2282"></a>
+<span class="sourceLineNo">2283</span>   * @param call The string representation of the call<a name="line.2283"></a>
+<span class="sourceLineNo">2284</span>   * @param tag  The tag that will be used to indicate this event in the log.<a name="line.2284"></a>
+<span class="sourceLineNo">2285</span>   * @param clientAddress   The address of the client who made this call.<a name="line.2285"></a>
+<span class="sourceLineNo">2286</span>   * @param startTime       The time that the call was initiated, in ms.<a name="line.2286"></a>
+<span class="sourceLineNo">2287</span>   * @param processingTime  The duration that the call took to run, in ms.<a name="line.2287"></a>
+<span class="sourceLineNo">2288</span>   * @param qTime           The duration that the call spent on the queue<a name="line.2288"></a>
+<span class="sourceLineNo">2289</span>   *                        prior to being initiated, in ms.<a name="line.2289"></a>
+<span class="sourceLineNo">2290</span>   * @param responseSize    The size in bytes of the response buffer.<a name="line.2290"></a>
+<span class="sourceLineNo">2291</span>   */<a name="line.2291"></a>
+<span class="sourceLineNo">2292</span>  void logResponse(Object[] params, String methodName, String call, String tag,<a name="line.2292"></a>
+<span class="sourceLineNo">2293</span>      String clientAddress, long startTime, int processingTime, int qTime,<a name="line.2293"></a>
+<span class="sourceLineNo">2294</span>      long responseSize)<a name="line.2294"></a>
+<span class="sourceLineNo">2295</span>          throws IOException {<a name="line.2295"></a>
+<span class="sourceLineNo">2296</span>    // base information that is reported regardless of type of call<a name="line.2296"></a>
+<span class="sourceLineNo">2297</span>    Map&lt;String, Object&gt; responseInfo = new HashMap&lt;String, Object&gt;();<a name="line.2297"></a>
+<span class="sourceLineNo">2298</span>    responseInfo.put("starttimems", startTime);<a name="line.2298"></a>
+<span class="sourceLineNo">2299</span>    responseInfo.put("processingtimems", processingTime);<a name="line.2299"></a>
+<span class="sourceLineNo">2300</span>    responseInfo.put("queuetimems", qTime);<a name="line.2300"></a>
+<span class="sourceLineNo">2301</span>    responseInfo.put("responsesize", responseSize);<a name="line.2301"></a>
+<span class="sourceLineNo">2302</span>    responseInfo.put("client", clientAddress);<a name="line.2302"></a>
+<span class="sourceLineNo">2303</span>    responseInfo.put("class", server == null? "": server.getClass().getSimpleName());<a name="line.2303"></a>
+<span class="sourceLineNo">2304</span>    responseInfo.put("method", methodName);<a name="line.2304"></a>
+<span class="sourceLineNo">2305</span>    if (params.length == 2 &amp;&amp; server instanceof HRegionServer &amp;&amp;<a name="line.2305"></a>
+<span class="sourceLineNo">2306</span>        params[0] instanceof byte[] &amp;&amp;<a name="line.2306"></a>
+<span class="sourceLineNo">2307</span>        params[1] instanceof Operation) {<a name="line.2307"></a>
+<span class="sourceLineNo">2308</span>      // if the slow process is a query, we want to log its table as well<a name="line.2308"></a>
+<span class="sourceLineNo">2309</span>      // as its own fingerprint<a name="line.2309"></a>
+<span class="sourceLineNo">2310</span>      TableName tableName = TableName.valueOf(<a name="line.2310"></a>
+<span class="sourceLineNo">2311</span>          HRegionInfo.parseRegionName((byte[]) params[0])[0]);<a name="line.2311"></a>
+<span class="sourceLineNo">2312</span>      responseInfo.put("table", tableName.getNameAsString());<a name="line.2312"></a>
+<span class="sourceLineNo">2313</span>      // annotate the response map with operation details<a name="line.2313"></a>
+<span class="sourceLineNo">2314</span>      responseInfo.putAll(((Operation) params[1]).toMap());<a name="line.2314"></a>
+<span class="sourceLineNo">2315</span>      // report to the log file<a name="line.2315"></a>
+<span class="sourceLineNo">2316</span>      LOG.warn("(operation" + tag + "): " +<a name="line.2316"></a>
+<span class="sourceLineNo">2317</span>               MAPPER.writeValueAsString(responseInfo));<a name="line.2317"></a>
+<span class="sourceLineNo">2318</span>    } else if (params.length == 1 &amp;&amp; server instanceof HRegionServer &amp;&amp;<a name="line.2318"></a>
+<span class="sourceLineNo">2319</span>        params[0] instanceof Operation) {<a name="line.2319"></a>
+<span class="sourceLineNo">2320</span>      // annotate the response map with operation details<a name="line.2320"></a>
+<span class="sourceLineNo">2321</span>      responseInfo.putAll(((Operation) params[0]).toMap());<a name="line.2321"></a>
+<span class="sourceLineNo">2322</span>      // report to the log file<a name="line.2322"></a>
+<span class="sourceLineNo">2323</span>      LOG.warn("(operation" + tag + "): " +<a name="line.2323"></a>
+<span class="sourceLineNo">2324</span>               MAPPER.writeValueAsString(responseInfo));<a name="line.2324"></a>
+<span class="sourceLineNo">2325</span>    } else {<a name="line.2325"></a>
+<span class="sourceLineNo">2326</span>      // can't get JSON details, so just report call.toString() along with<a name="line.2326"></a>
+<span class="sourceLineNo">2327</span>      // a more generic tag.<a name="line.2327"></a>
+<span class="sourceLineNo">2328</span>      responseInfo.put("call", call);<a name="line.2328"></a>
+<span class="sourceLineNo">2329</span>      LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo));<a name="line.2329"></a>
+<span class="sourceLineNo">2330</span>    }<a name="line.2330"></a>
+<span class="sourceLineNo">2331</span>  }<a name="line.2331"></a>
+<span class="sourceLineNo">2332</span><a name="line.2332"></a>
+<span class="sourceLineNo">2333</span>  /** Stops the service.  No new calls will be handled after this is called. */<a name="line.2333"></a>
+<span class="sourceLineNo">2334</span>  @Override<a name="line.2334"></a>
+<span class="sourceLineNo">2335</span>  public synchronized void stop() {<a name="line.2335"></a>
+<span class="sourceLineNo">2336</span>    LOG.info("Stopping server on " + port);<a name="line.2336"></a>
+<span class="sourceLineNo">2337</span>    running = false;<a name="line.2337"></a>
+<span class="sourceLineNo">2338</span>    if (authTokenSecretMgr != null) {<a name="line.2338"></a>
+<span class="sourceLineNo">2339</span>      authTokenSecretMgr.stop();<a name="line.2339"></a>
+<span class="sourceLineNo">2340</span>      authTokenSecretMgr = null;<a name="line.2340"></a>
+<span class="sourceLineNo">2341</span>    }<a name="line.2341"></a>
+<span class="sourceLineNo">2342</span>    listener.interrupt();<a name="line.2342"></a>
+<span class="sourceLineNo">2343</span>    listener.doStop();<a name="line.2343"></a>
+<span class="sourceLineNo">2344</span>    responder.interrupt();<a name="line.2344"></a>
+<span class="sourceLineNo">2345</span>    scheduler.stop();<a name="line.2345"></a>
+<span class="sourceLineNo">2346</span>    notifyAll();<a name="line.2346"></a>
+<span class="sourceLineNo">2347</span>  }<a name="line.2347"></a>
+<span class="sourceLineNo">2348</span><a name="line.2348"></a>
+<span class="sourceLineNo">2349</span>  /** Wait for the server to be stopped.<a name="line.2349"></a>
+<span class="sourceLineNo">2350</span>   * Does not wait for all subthreads to finish.<a name="line.2350"></a>
+<span class="sourceLineNo">2351</span>   *  See {@link #stop()}.<a name="line.2351"></a>
+<span class="sourceLineNo">2352</span>   * @throws InterruptedException e<a name="line.2352"></a>
+<span class="sourceLineNo">2353</span>   */<a name="line.2353"></a>
+<span class="sourceLineNo">2354</span>  @Override<a name="line.2354"></a>
+<span class="sourceLineNo">2355</span>  public synchronized void join() throws InterruptedException {<a name="line.2355"></a>
+<span class="sourceLineNo">2356</span>    while (running) {<a name="line.2356"></a>
+<span class="sourceLineNo">2357</span>      wait();<a name="line.2357"></a>
+<span class="sourceLineNo">2358</span>    }<a name="line.2358"></a>
+<span class="sourceLineNo">2359</span>  }<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>   * Return the socket (ip+port) on which the RPC server is listening to. May return null if<a name="line.2362"></a>
+<span class="sourceLineNo">2363</span>   * the listener channel is closed.<a name="line.2363"></a>
+<span class="sourceLineNo">2364</span>   * @return the socket (ip+port) on which the RPC server is listening to, or null if this<a name="line.2364"></a>
+<span class="sourceLineNo">2365</span>   * information cannot be determined<a name="line.2365"></a>
+<span class="sourceLineNo">2366</span>   */<a name="line.2366"></a>
+<span class="sourceLineNo">2367</span>  @Override<a name="line.2367"></a>
+<span class="sourceLineNo">2368</span>  public synchronized InetSocketAddress getListenerAddress() {<a name="line.2368"></a>
+<span class="sourceLineNo">2369</span>    if (listener == null) {<a name="line.2369"></a>
+<span class="sourceLineNo">2370</span>      return null;<a name="line.2370"></a>
+<span class="sourceLineNo">2371</span>    }<a name="line.2371"></a>
+<span class="sourceLineNo">2372</span>    return listener.getAddress();<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>  /**<a name="line.2375"></a>
+<span class="sourceLineNo">2376</span>   * Set the handler for calling out of RPC for error conditions.<a name="line.2376"></a>
+<span class="sourceLineNo">2377</span>   * @param handler the handler implementation<a name="line.2377"></a>
+<span class="sourceLineNo">2378</span>   */<a name="line.2378"></a>
+<span class="sourceLineNo">2379</span>  @Override<a name="line.2379"></a>
+<span class="sourceLineNo">2380</span>  public void setErrorHandler(HBaseRPCErrorHandler handler) {<a name="line.2380"></a>
+<span class="sourceLineNo">2381</span>    this.errorHandler = handler;<a name="line.2381"></a>
+<span class="sourceLineNo">2382</span>  }<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 HBaseRPCErrorHandler getErrorHandler() {<a name="line.2385"></a>
+<span class="sourceLineNo">2386</span>    return this.errorHandler;<a name="line.2386"></a>
+<span class="sourceLineNo">2387</span>  }<a name="line.2387"></a>
+<span class="sourceLineNo">2388</span><a name="line.2388"></a>
+<span class="sourceLineNo">2389</span>  /**<a name="line.2389"></a>
+<span class="sourceLineNo">2390</span>   * Returns the metrics instance for reporting RPC call statistics<a name="line.2390"></a>
+<span class="sourceLineNo">2391</span>   */<a name="line.2391"></a>
+<span class="sourceLineNo">2392</span>  @Override<a name="line.2392"></a>
+<span class="sourceLineNo">2393</span>  public MetricsHBaseServer getMetrics() {<a name="line.2393"></a>
+<span class="sourceLineNo">2394</span>    return metrics;<a name="line.2394"></a>
+<span class="sourceLineNo">2395</span>  }<a name="line.2395"></a>
+<span class="sourceLineNo">2396</span><a name="line.2396"></a>
+<span class="sourceLineNo">2397</span>  @Override<a name="line.2397"></a>
+<span class="sourceLineNo">2398</span>  public void addCallSize(final long diff) {<a name="line.2398"></a>
+<span class="sourceLineNo">2399</span>    this.callQueueSize.add(diff);<a name="line.2399"></a>
+<span class="sourceLineNo">2400</span>  }<a name="line.2400"></a>
+<span class="sourceLineNo">2401</span><a name="line.2401"></a>
+<span class="sourceLineNo">2402</span>  /**<a name="line.2402"></a>
+<span class="sourceLineNo">2403</span>   * Authorize the incoming client connection.<a name="line.2403"></a>
+<span class="sourceLineNo">2404</span>   *<a name="line.2404"></a>
+<span class="sourceLineNo">2405</span>   * @param user client user<a name="line.2405"></a>
+<span class="sourceLineNo">2406</span>   * @param connection incoming connection<a name="line.2406"></a>
+<span class="sourceLineNo">2407</span>   * @param addr InetAddress of incoming connection<a name="line.2407"></a>
+<span class="sourceLineNo">2408</span>   * @throws org.apache.hadoop.security.authorize.AuthorizationException<a name="line.2408"></a>
+<span class="sourceLineNo">2409</span>   *         when the client isn't authorized to talk the protocol<a name="line.2409"></a>
+<span class="sourceLineNo">2410</span>   */<a name="line.2410"></a>
+<span class="sourceLineNo">2411</span>  public synchronized void authorize(UserGroupInformation user, ConnectionHeader connection,<a name="line.2411"></a>
+<span class="sourceLineNo">2412</span>      InetAddress addr)<a name="line.2412"></a>
+<span class="sourceLineNo">2413</span>  throws AuthorizationException {<a name="line.2413"></a>
+<span class="sourceLineNo">2414</span>    if (authorize) {<a name="line.2414"></a>
+<span class="sourceLineNo">2415</span>      Class&lt;?&gt; c = getServiceInterface(services, connection.getServiceName());<a name="line.2415"></a>
+<span class="sourceLineNo">2416</span>      this.authManager.authorize(user != null ? user : null, c, getConf(), addr);<a name="line.2416"></a>
+<span class="sourceLineNo">2417</span>    }<a name="line.2417"></a>
+<span class="sourceLineNo">2418</span>  }<a name="line.2418"></a>
+<span class="sourceLineNo">2419</span><a name="line.2419"></a>
+<span class="sourceLineNo">2420</span>  /**<a name="line.2420"></a>
+<span class="sourceLineNo">2421</span>   * When the read or write buffer size is larger than this limit, i/o will be<a name="line.2421"></a>
+<span class="sourceLineNo">2422</span>   * done in chunks of this size. Most RPC requests and responses would be<a name="line.2422"></a>
+<span class="sourceLineNo">2423</span>   * be smaller.<a name="line.2423"></a>
+<span class="sourceLineNo">2424</span>   */<a name="line.2424"></a>
+<span class="sourceLineNo">2425</span>  private static int NIO_BUFFER_LIMIT = 64 * 1024; //should not be more than 64KB.<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>   * This is a wrapper around {@link java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)}.<a name="line.2428"></a>
+<span class=

<TRUNCATED>

Mime
View raw message