hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [21/51] [partial] hbase-site git commit: Published site at .
Date Thu, 30 Nov 2017 15:19:00 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/713d773f/devapidocs/src-html/org/apache/hadoop/hbase/client/ConnectionUtils.ShortCircuitingClusterConnection.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/ConnectionUtils.ShortCircuitingClusterConnection.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/ConnectionUtils.ShortCircuitingClusterConnection.html
index 1bddf29..f667b93 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/ConnectionUtils.ShortCircuitingClusterConnection.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/ConnectionUtils.ShortCircuitingClusterConnection.html
@@ -124,380 +124,381 @@
 <span class="sourceLineNo">116</span>      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);<a name="line.116"></a>
 <span class="sourceLineNo">117</span>    // Go big. Multiply by 10. If we can't get to meta after this many retries<a name="line.117"></a>
 <span class="sourceLineNo">118</span>    // then something seriously wrong.<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    int serversideMultiplier = c.getInt("hbase.client.serverside.retries.multiplier", 10);<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    int retries = hcRetries * serversideMultiplier;<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, retries);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    log.info(sn + " server-side Connection retries=" + retries);<a name="line.122"></a>
-<span class="sourceLineNo">123</span>  }<a name="line.123"></a>
-<span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>  /**<a name="line.125"></a>
-<span class="sourceLineNo">126</span>   * A ClusterConnection that will short-circuit RPC making direct invocations against the<a name="line.126"></a>
-<span class="sourceLineNo">127</span>   * localhost if the invocation target is 'this' server; save on network and protobuf<a name="line.127"></a>
-<span class="sourceLineNo">128</span>   * invocations.<a name="line.128"></a>
-<span class="sourceLineNo">129</span>   */<a name="line.129"></a>
-<span class="sourceLineNo">130</span>  // TODO This has to still do PB marshalling/unmarshalling stuff. Check how/whether we can avoid.<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  @VisibleForTesting // Class is visible so can assert we are short-circuiting when expected.<a name="line.131"></a>
-<span class="sourceLineNo">132</span>  public static class ShortCircuitingClusterConnection extends ConnectionImplementation {<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    private final ServerName serverName;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    private final AdminService.BlockingInterface localHostAdmin;<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    private final ClientService.BlockingInterface localHostClient;<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>    private ShortCircuitingClusterConnection(Configuration conf, ExecutorService pool, User user,<a name="line.137"></a>
-<span class="sourceLineNo">138</span>        ServerName serverName, AdminService.BlockingInterface admin,<a name="line.138"></a>
-<span class="sourceLineNo">139</span>        ClientService.BlockingInterface client)<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    throws IOException {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      super(conf, pool, user);<a name="line.141"></a>
-<span class="sourceLineNo">142</span>      this.serverName = serverName;<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      this.localHostAdmin = admin;<a name="line.143"></a>
-<span class="sourceLineNo">144</span>      this.localHostClient = client;<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
-<span class="sourceLineNo">146</span><a name="line.146"></a>
-<span class="sourceLineNo">147</span>    @Override<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    public AdminService.BlockingInterface getAdmin(ServerName sn) throws IOException {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      return serverName.equals(sn) ? this.localHostAdmin : super.getAdmin(sn);<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    }<a name="line.150"></a>
-<span class="sourceLineNo">151</span><a name="line.151"></a>
-<span class="sourceLineNo">152</span>    @Override<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    public ClientService.BlockingInterface getClient(ServerName sn) throws IOException {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      return serverName.equals(sn) ? this.localHostClient : super.getClient(sn);<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    }<a name="line.155"></a>
-<span class="sourceLineNo">156</span><a name="line.156"></a>
-<span class="sourceLineNo">157</span>    @Override<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    public MasterKeepAliveConnection getKeepAliveMasterService() throws MasterNotRunningException {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>      if (this.localHostClient instanceof MasterService.BlockingInterface) {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>        return new ShortCircuitMasterConnection((MasterService.BlockingInterface)this.localHostClient);<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      }<a name="line.161"></a>
-<span class="sourceLineNo">162</span>      return super.getKeepAliveMasterService();<a name="line.162"></a>
-<span class="sourceLineNo">163</span>    }<a name="line.163"></a>
-<span class="sourceLineNo">164</span>  }<a name="line.164"></a>
-<span class="sourceLineNo">165</span><a name="line.165"></a>
-<span class="sourceLineNo">166</span>  /**<a name="line.166"></a>
-<span class="sourceLineNo">167</span>   * Creates a short-circuit connection that can bypass the RPC layer (serialization,<a name="line.167"></a>
-<span class="sourceLineNo">168</span>   * deserialization, networking, etc..) when talking to a local server.<a name="line.168"></a>
-<span class="sourceLineNo">169</span>   * @param conf the current configuration<a name="line.169"></a>
-<span class="sourceLineNo">170</span>   * @param pool the thread pool to use for batch operations<a name="line.170"></a>
-<span class="sourceLineNo">171</span>   * @param user the user the connection is for<a name="line.171"></a>
-<span class="sourceLineNo">172</span>   * @param serverName the local server name<a name="line.172"></a>
-<span class="sourceLineNo">173</span>   * @param admin the admin interface of the local server<a name="line.173"></a>
-<span class="sourceLineNo">174</span>   * @param client the client interface of the local server<a name="line.174"></a>
-<span class="sourceLineNo">175</span>   * @return an short-circuit connection.<a name="line.175"></a>
-<span class="sourceLineNo">176</span>   * @throws IOException if IO failure occurred<a name="line.176"></a>
-<span class="sourceLineNo">177</span>   */<a name="line.177"></a>
-<span class="sourceLineNo">178</span>  public static ClusterConnection createShortCircuitConnection(final Configuration conf,<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      ExecutorService pool, User user, final ServerName serverName,<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      final AdminService.BlockingInterface admin, final ClientService.BlockingInterface client)<a name="line.180"></a>
-<span class="sourceLineNo">181</span>      throws IOException {<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    if (user == null) {<a name="line.182"></a>
-<span class="sourceLineNo">183</span>      user = UserProvider.instantiate(conf).getCurrent();<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    }<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    return new ShortCircuitingClusterConnection(conf, pool, user, serverName, admin, client);<a name="line.185"></a>
-<span class="sourceLineNo">186</span>  }<a name="line.186"></a>
-<span class="sourceLineNo">187</span><a name="line.187"></a>
-<span class="sourceLineNo">188</span>  /**<a name="line.188"></a>
-<span class="sourceLineNo">189</span>   * Setup the connection class, so that it will not depend on master being online. Used for testing<a name="line.189"></a>
-<span class="sourceLineNo">190</span>   * @param conf configuration to set<a name="line.190"></a>
-<span class="sourceLineNo">191</span>   */<a name="line.191"></a>
-<span class="sourceLineNo">192</span>  @VisibleForTesting<a name="line.192"></a>
-<span class="sourceLineNo">193</span>  public static void setupMasterlessConnection(Configuration conf) {<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    conf.set(ClusterConnection.HBASE_CLIENT_CONNECTION_IMPL, MasterlessConnection.class.getName());<a name="line.194"></a>
-<span class="sourceLineNo">195</span>  }<a name="line.195"></a>
-<span class="sourceLineNo">196</span><a name="line.196"></a>
-<span class="sourceLineNo">197</span>  /**<a name="line.197"></a>
-<span class="sourceLineNo">198</span>   * Some tests shut down the master. But table availability is a master RPC which is performed on<a name="line.198"></a>
-<span class="sourceLineNo">199</span>   * region re-lookups.<a name="line.199"></a>
-<span class="sourceLineNo">200</span>   */<a name="line.200"></a>
-<span class="sourceLineNo">201</span>  static class MasterlessConnection extends ConnectionImplementation {<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    MasterlessConnection(Configuration conf, ExecutorService pool, User user) throws IOException {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      super(conf, pool, user);<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
-<span class="sourceLineNo">205</span><a name="line.205"></a>
-<span class="sourceLineNo">206</span>    @Override<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    public boolean isTableDisabled(TableName tableName) throws IOException {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>      // treat all tables as enabled<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      return false;<a name="line.209"></a>
-<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
-<span class="sourceLineNo">211</span>  }<a name="line.211"></a>
-<span class="sourceLineNo">212</span><a name="line.212"></a>
-<span class="sourceLineNo">213</span>  /**<a name="line.213"></a>
-<span class="sourceLineNo">214</span>   * Return retires + 1. The returned value will be in range [1, Integer.MAX_VALUE].<a name="line.214"></a>
-<span class="sourceLineNo">215</span>   */<a name="line.215"></a>
-<span class="sourceLineNo">216</span>  static int retries2Attempts(int retries) {<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    return Math.max(1, retries == Integer.MAX_VALUE ? Integer.MAX_VALUE : retries + 1);<a name="line.217"></a>
-<span class="sourceLineNo">218</span>  }<a name="line.218"></a>
-<span class="sourceLineNo">219</span><a name="line.219"></a>
-<span class="sourceLineNo">220</span>  /**<a name="line.220"></a>
-<span class="sourceLineNo">221</span>   * Get a unique key for the rpc stub to the given server.<a name="line.221"></a>
-<span class="sourceLineNo">222</span>   */<a name="line.222"></a>
-<span class="sourceLineNo">223</span>  static String getStubKey(String serviceName, ServerName serverName, boolean hostnameCanChange) {<a name="line.223"></a>
-<span class="sourceLineNo">224</span>    // Sometimes, servers go down and they come back up with the same hostname but a different<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    // IP address. Force a resolution of the rsHostname by trying to instantiate an<a name="line.225"></a>
-<span class="sourceLineNo">226</span>    // InetSocketAddress, and this way we will rightfully get a new stubKey.<a name="line.226"></a>
-<span class="sourceLineNo">227</span>    // Also, include the hostname in the key so as to take care of those cases where the<a name="line.227"></a>
-<span class="sourceLineNo">228</span>    // DNS name is different but IP address remains the same.<a name="line.228"></a>
-<span class="sourceLineNo">229</span>    String hostname = serverName.getHostname();<a name="line.229"></a>
-<span class="sourceLineNo">230</span>    int port = serverName.getPort();<a name="line.230"></a>
-<span class="sourceLineNo">231</span>    if (hostnameCanChange) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>      try {<a name="line.232"></a>
-<span class="sourceLineNo">233</span>        InetAddress ip = InetAddress.getByName(hostname);<a name="line.233"></a>
-<span class="sourceLineNo">234</span>        return serviceName + "@" + hostname + "-" + ip.getHostAddress() + ":" + port;<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      } catch (UnknownHostException e) {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>        LOG.warn("Can not resolve " + hostname + ", please check your network", e);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>      }<a name="line.237"></a>
-<span class="sourceLineNo">238</span>    }<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    return serviceName + "@" + hostname + ":" + port;<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>  static void checkHasFamilies(Mutation mutation) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    Preconditions.checkArgument(mutation.numFamilies() &gt; 0,<a name="line.243"></a>
-<span class="sourceLineNo">244</span>      "Invalid arguments to %s, zero columns specified", mutation.toString());<a name="line.244"></a>
-<span class="sourceLineNo">245</span>  }<a name="line.245"></a>
-<span class="sourceLineNo">246</span><a name="line.246"></a>
-<span class="sourceLineNo">247</span>  /** Dummy nonce generator for disabled nonces. */<a name="line.247"></a>
-<span class="sourceLineNo">248</span>  static final NonceGenerator NO_NONCE_GENERATOR = new NonceGenerator() {<a name="line.248"></a>
-<span class="sourceLineNo">249</span><a name="line.249"></a>
-<span class="sourceLineNo">250</span>    @Override<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    public long newNonce() {<a name="line.251"></a>
-<span class="sourceLineNo">252</span>      return HConstants.NO_NONCE;<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">255</span>    @Override<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    public long getNonceGroup() {<a name="line.256"></a>
-<span class="sourceLineNo">257</span>      return HConstants.NO_NONCE;<a name="line.257"></a>
-<span class="sourceLineNo">258</span>    }<a name="line.258"></a>
-<span class="sourceLineNo">259</span>  };<a name="line.259"></a>
-<span class="sourceLineNo">260</span><a name="line.260"></a>
-<span class="sourceLineNo">261</span>  // A byte array in which all elements are the max byte, and it is used to<a name="line.261"></a>
-<span class="sourceLineNo">262</span>  // construct closest front row<a name="line.262"></a>
-<span class="sourceLineNo">263</span>  static final byte[] MAX_BYTE_ARRAY = Bytes.createMaxByteArray(9);<a name="line.263"></a>
-<span class="sourceLineNo">264</span><a name="line.264"></a>
-<span class="sourceLineNo">265</span>  /**<a name="line.265"></a>
-<span class="sourceLineNo">266</span>   * Create the closest row after the specified row<a name="line.266"></a>
-<span class="sourceLineNo">267</span>   */<a name="line.267"></a>
-<span class="sourceLineNo">268</span>  static byte[] createClosestRowAfter(byte[] row) {<a name="line.268"></a>
-<span class="sourceLineNo">269</span>    return Arrays.copyOf(row, row.length + 1);<a name="line.269"></a>
-<span class="sourceLineNo">270</span>  }<a name="line.270"></a>
-<span class="sourceLineNo">271</span><a name="line.271"></a>
-<span class="sourceLineNo">272</span>  /**<a name="line.272"></a>
-<span class="sourceLineNo">273</span>   * Create a row before the specified row and very close to the specified row.<a name="line.273"></a>
-<span class="sourceLineNo">274</span>   */<a name="line.274"></a>
-<span class="sourceLineNo">275</span>  static byte[] createCloseRowBefore(byte[] row) {<a name="line.275"></a>
-<span class="sourceLineNo">276</span>    if (row.length == 0) {<a name="line.276"></a>
-<span class="sourceLineNo">277</span>      return MAX_BYTE_ARRAY;<a name="line.277"></a>
-<span class="sourceLineNo">278</span>    }<a name="line.278"></a>
-<span class="sourceLineNo">279</span>    if (row[row.length - 1] == 0) {<a name="line.279"></a>
-<span class="sourceLineNo">280</span>      return Arrays.copyOf(row, row.length - 1);<a name="line.280"></a>
-<span class="sourceLineNo">281</span>    } else {<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      byte[] nextRow = new byte[row.length + MAX_BYTE_ARRAY.length];<a name="line.282"></a>
-<span class="sourceLineNo">283</span>      System.arraycopy(row, 0, nextRow, 0, row.length - 1);<a name="line.283"></a>
-<span class="sourceLineNo">284</span>      nextRow[row.length - 1] = (byte) ((row[row.length - 1] &amp; 0xFF) - 1);<a name="line.284"></a>
-<span class="sourceLineNo">285</span>      System.arraycopy(MAX_BYTE_ARRAY, 0, nextRow, row.length, MAX_BYTE_ARRAY.length);<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      return nextRow;<a name="line.286"></a>
-<span class="sourceLineNo">287</span>    }<a name="line.287"></a>
-<span class="sourceLineNo">288</span>  }<a name="line.288"></a>
-<span class="sourceLineNo">289</span><a name="line.289"></a>
-<span class="sourceLineNo">290</span>  static boolean isEmptyStartRow(byte[] row) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>    return Bytes.equals(row, EMPTY_START_ROW);<a name="line.291"></a>
-<span class="sourceLineNo">292</span>  }<a name="line.292"></a>
-<span class="sourceLineNo">293</span><a name="line.293"></a>
-<span class="sourceLineNo">294</span>  static boolean isEmptyStopRow(byte[] row) {<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    return Bytes.equals(row, EMPTY_END_ROW);<a name="line.295"></a>
-<span class="sourceLineNo">296</span>  }<a name="line.296"></a>
-<span class="sourceLineNo">297</span><a name="line.297"></a>
-<span class="sourceLineNo">298</span>  static void resetController(HBaseRpcController controller, long timeoutNs) {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>    controller.reset();<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    if (timeoutNs &gt;= 0) {<a name="line.300"></a>
-<span class="sourceLineNo">301</span>      controller.setCallTimeout(<a name="line.301"></a>
-<span class="sourceLineNo">302</span>        (int) Math.min(Integer.MAX_VALUE, TimeUnit.NANOSECONDS.toMillis(timeoutNs)));<a name="line.302"></a>
-<span class="sourceLineNo">303</span>    }<a name="line.303"></a>
-<span class="sourceLineNo">304</span>  }<a name="line.304"></a>
-<span class="sourceLineNo">305</span><a name="line.305"></a>
-<span class="sourceLineNo">306</span>  static Throwable translateException(Throwable t) {<a name="line.306"></a>
-<span class="sourceLineNo">307</span>    if (t instanceof UndeclaredThrowableException &amp;&amp; t.getCause() != null) {<a name="line.307"></a>
-<span class="sourceLineNo">308</span>      t = t.getCause();<a name="line.308"></a>
-<span class="sourceLineNo">309</span>    }<a name="line.309"></a>
-<span class="sourceLineNo">310</span>    if (t instanceof RemoteException) {<a name="line.310"></a>
-<span class="sourceLineNo">311</span>      t = ((RemoteException) t).unwrapRemoteException();<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    }<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    if (t instanceof ServiceException &amp;&amp; t.getCause() != null) {<a name="line.313"></a>
-<span class="sourceLineNo">314</span>      t = translateException(t.getCause());<a name="line.314"></a>
-<span class="sourceLineNo">315</span>    }<a name="line.315"></a>
-<span class="sourceLineNo">316</span>    return t;<a name="line.316"></a>
-<span class="sourceLineNo">317</span>  }<a name="line.317"></a>
-<span class="sourceLineNo">318</span><a name="line.318"></a>
-<span class="sourceLineNo">319</span>  static long calcEstimatedSize(Result rs) {<a name="line.319"></a>
-<span class="sourceLineNo">320</span>    long estimatedHeapSizeOfResult = 0;<a name="line.320"></a>
-<span class="sourceLineNo">321</span>    // We don't make Iterator here<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    for (Cell cell : rs.rawCells()) {<a name="line.322"></a>
-<span class="sourceLineNo">323</span>      estimatedHeapSizeOfResult += PrivateCellUtil.estimatedHeapSizeOf(cell);<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    }<a name="line.324"></a>
-<span class="sourceLineNo">325</span>    return estimatedHeapSizeOfResult;<a name="line.325"></a>
-<span class="sourceLineNo">326</span>  }<a name="line.326"></a>
-<span class="sourceLineNo">327</span><a name="line.327"></a>
-<span class="sourceLineNo">328</span>  static Result filterCells(Result result, Cell keepCellsAfter) {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>    if (keepCellsAfter == null) {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>      // do not need to filter<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      return result;<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span>    // not the same row<a name="line.333"></a>
-<span class="sourceLineNo">334</span>    if (!PrivateCellUtil.matchingRows(keepCellsAfter, result.getRow(), 0, result.getRow().length)) {<a name="line.334"></a>
-<span class="sourceLineNo">335</span>      return result;<a name="line.335"></a>
-<span class="sourceLineNo">336</span>    }<a name="line.336"></a>
-<span class="sourceLineNo">337</span>    Cell[] rawCells = result.rawCells();<a name="line.337"></a>
-<span class="sourceLineNo">338</span>    int index =<a name="line.338"></a>
-<span class="sourceLineNo">339</span>        Arrays.binarySearch(rawCells, keepCellsAfter, CellComparator.getInstance()::compareWithoutRow);<a name="line.339"></a>
-<span class="sourceLineNo">340</span>    if (index &lt; 0) {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>      index = -index - 1;<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    } else {<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      index++;<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    }<a name="line.344"></a>
-<span class="sourceLineNo">345</span>    if (index == 0) {<a name="line.345"></a>
-<span class="sourceLineNo">346</span>      return result;<a name="line.346"></a>
-<span class="sourceLineNo">347</span>    }<a name="line.347"></a>
-<span class="sourceLineNo">348</span>    if (index == rawCells.length) {<a name="line.348"></a>
-<span class="sourceLineNo">349</span>      return null;<a name="line.349"></a>
-<span class="sourceLineNo">350</span>    }<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    return Result.create(Arrays.copyOfRange(rawCells, index, rawCells.length), null,<a name="line.351"></a>
-<span class="sourceLineNo">352</span>      result.isStale(), result.mayHaveMoreCellsInRow());<a name="line.352"></a>
-<span class="sourceLineNo">353</span>  }<a name="line.353"></a>
-<span class="sourceLineNo">354</span><a name="line.354"></a>
-<span class="sourceLineNo">355</span>  // Add a delta to avoid timeout immediately after a retry sleeping.<a name="line.355"></a>
-<span class="sourceLineNo">356</span>  static final long SLEEP_DELTA_NS = TimeUnit.MILLISECONDS.toNanos(1);<a name="line.356"></a>
-<span class="sourceLineNo">357</span><a name="line.357"></a>
-<span class="sourceLineNo">358</span>  static Get toCheckExistenceOnly(Get get) {<a name="line.358"></a>
-<span class="sourceLineNo">359</span>    if (get.isCheckExistenceOnly()) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>      return get;<a name="line.360"></a>
-<span class="sourceLineNo">361</span>    }<a name="line.361"></a>
-<span class="sourceLineNo">362</span>    return ReflectionUtils.newInstance(get.getClass(), get).setCheckExistenceOnly(true);<a name="line.362"></a>
-<span class="sourceLineNo">363</span>  }<a name="line.363"></a>
-<span class="sourceLineNo">364</span><a name="line.364"></a>
-<span class="sourceLineNo">365</span>  static List&lt;Get&gt; toCheckExistenceOnly(List&lt;Get&gt; gets) {<a name="line.365"></a>
-<span class="sourceLineNo">366</span>    return gets.stream().map(ConnectionUtils::toCheckExistenceOnly).collect(toList());<a name="line.366"></a>
-<span class="sourceLineNo">367</span>  }<a name="line.367"></a>
-<span class="sourceLineNo">368</span><a name="line.368"></a>
-<span class="sourceLineNo">369</span>  static RegionLocateType getLocateType(Scan scan) {<a name="line.369"></a>
-<span class="sourceLineNo">370</span>    if (scan.isReversed()) {<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      if (isEmptyStartRow(scan.getStartRow())) {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>        return RegionLocateType.BEFORE;<a name="line.372"></a>
-<span class="sourceLineNo">373</span>      } else {<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        return scan.includeStartRow() ? RegionLocateType.CURRENT : RegionLocateType.BEFORE;<a name="line.374"></a>
-<span class="sourceLineNo">375</span>      }<a name="line.375"></a>
-<span class="sourceLineNo">376</span>    } else {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>      return scan.includeStartRow() ? RegionLocateType.CURRENT : RegionLocateType.AFTER;<a name="line.377"></a>
-<span class="sourceLineNo">378</span>    }<a name="line.378"></a>
-<span class="sourceLineNo">379</span>  }<a name="line.379"></a>
-<span class="sourceLineNo">380</span><a name="line.380"></a>
-<span class="sourceLineNo">381</span>  static boolean noMoreResultsForScan(Scan scan, RegionInfo info) {<a name="line.381"></a>
-<span class="sourceLineNo">382</span>    if (isEmptyStopRow(info.getEndKey())) {<a name="line.382"></a>
-<span class="sourceLineNo">383</span>      return true;<a name="line.383"></a>
-<span class="sourceLineNo">384</span>    }<a name="line.384"></a>
-<span class="sourceLineNo">385</span>    if (isEmptyStopRow(scan.getStopRow())) {<a name="line.385"></a>
-<span class="sourceLineNo">386</span>      return false;<a name="line.386"></a>
-<span class="sourceLineNo">387</span>    }<a name="line.387"></a>
-<span class="sourceLineNo">388</span>    int c = Bytes.compareTo(info.getEndKey(), scan.getStopRow());<a name="line.388"></a>
-<span class="sourceLineNo">389</span>    // 1. if our stop row is less than the endKey of the region<a name="line.389"></a>
-<span class="sourceLineNo">390</span>    // 2. if our stop row is equal to the endKey of the region and we do not include the stop row<a name="line.390"></a>
-<span class="sourceLineNo">391</span>    // for scan.<a name="line.391"></a>
-<span class="sourceLineNo">392</span>    return c &gt; 0 || (c == 0 &amp;&amp; !scan.includeStopRow());<a name="line.392"></a>
-<span class="sourceLineNo">393</span>  }<a name="line.393"></a>
-<span class="sourceLineNo">394</span><a name="line.394"></a>
-<span class="sourceLineNo">395</span>  static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info) {<a name="line.395"></a>
-<span class="sourceLineNo">396</span>    if (isEmptyStartRow(info.getStartKey())) {<a name="line.396"></a>
-<span class="sourceLineNo">397</span>      return true;<a name="line.397"></a>
-<span class="sourceLineNo">398</span>    }<a name="line.398"></a>
-<span class="sourceLineNo">399</span>    if (isEmptyStopRow(scan.getStopRow())) {<a name="line.399"></a>
-<span class="sourceLineNo">400</span>      return false;<a name="line.400"></a>
-<span class="sourceLineNo">401</span>    }<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    // no need to test the inclusive of the stop row as the start key of a region is included in<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    // the region.<a name="line.403"></a>
-<span class="sourceLineNo">404</span>    return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) &lt;= 0;<a name="line.404"></a>
-<span class="sourceLineNo">405</span>  }<a name="line.405"></a>
-<span class="sourceLineNo">406</span><a name="line.406"></a>
-<span class="sourceLineNo">407</span>  static &lt;T&gt; CompletableFuture&lt;List&lt;T&gt;&gt; allOf(List&lt;CompletableFuture&lt;T&gt;&gt; futures) {<a name="line.407"></a>
-<span class="sourceLineNo">408</span>    return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))<a name="line.408"></a>
-<span class="sourceLineNo">409</span>        .thenApply(v -&gt; futures.stream().map(f -&gt; f.getNow(null)).collect(toList()));<a name="line.409"></a>
-<span class="sourceLineNo">410</span>  }<a name="line.410"></a>
-<span class="sourceLineNo">411</span><a name="line.411"></a>
-<span class="sourceLineNo">412</span>  public static ScanResultCache createScanResultCache(Scan scan) {<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    if (scan.getAllowPartialResults()) {<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      return new AllowPartialScanResultCache();<a name="line.414"></a>
-<span class="sourceLineNo">415</span>    } else if (scan.getBatch() &gt; 0) {<a name="line.415"></a>
-<span class="sourceLineNo">416</span>      return new BatchScanResultCache(scan.getBatch());<a name="line.416"></a>
-<span class="sourceLineNo">417</span>    } else {<a name="line.417"></a>
-<span class="sourceLineNo">418</span>      return new CompleteScanResultCache();<a name="line.418"></a>
-<span class="sourceLineNo">419</span>    }<a name="line.419"></a>
-<span class="sourceLineNo">420</span>  }<a name="line.420"></a>
-<span class="sourceLineNo">421</span><a name="line.421"></a>
-<span class="sourceLineNo">422</span>  private static final String MY_ADDRESS = getMyAddress();<a name="line.422"></a>
-<span class="sourceLineNo">423</span><a name="line.423"></a>
-<span class="sourceLineNo">424</span>  private static String getMyAddress() {<a name="line.424"></a>
-<span class="sourceLineNo">425</span>    try {<a name="line.425"></a>
-<span class="sourceLineNo">426</span>      return DNS.getDefaultHost("default", "default");<a name="line.426"></a>
-<span class="sourceLineNo">427</span>    } catch (UnknownHostException uhe) {<a name="line.427"></a>
-<span class="sourceLineNo">428</span>      LOG.error("cannot determine my address", uhe);<a name="line.428"></a>
-<span class="sourceLineNo">429</span>      return null;<a name="line.429"></a>
-<span class="sourceLineNo">430</span>    }<a name="line.430"></a>
-<span class="sourceLineNo">431</span>  }<a name="line.431"></a>
-<span class="sourceLineNo">432</span><a name="line.432"></a>
-<span class="sourceLineNo">433</span>  static boolean isRemote(String host) {<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    return !host.equalsIgnoreCase(MY_ADDRESS);<a name="line.434"></a>
-<span class="sourceLineNo">435</span>  }<a name="line.435"></a>
-<span class="sourceLineNo">436</span><a name="line.436"></a>
-<span class="sourceLineNo">437</span>  static void incRPCCallsMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) {<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    if (scanMetrics == null) {<a name="line.438"></a>
-<span class="sourceLineNo">439</span>      return;<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    }<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    scanMetrics.countOfRPCcalls.incrementAndGet();<a name="line.441"></a>
-<span class="sourceLineNo">442</span>    if (isRegionServerRemote) {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>      scanMetrics.countOfRemoteRPCcalls.incrementAndGet();<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    }<a name="line.444"></a>
-<span class="sourceLineNo">445</span>  }<a name="line.445"></a>
-<span class="sourceLineNo">446</span><a name="line.446"></a>
-<span class="sourceLineNo">447</span>  static void incRPCRetriesMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) {<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    if (scanMetrics == null) {<a name="line.448"></a>
-<span class="sourceLineNo">449</span>      return;<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    }<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    scanMetrics.countOfRPCRetries.incrementAndGet();<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    if (isRegionServerRemote) {<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      scanMetrics.countOfRemoteRPCRetries.incrementAndGet();<a name="line.453"></a>
-<span class="sourceLineNo">454</span>    }<a name="line.454"></a>
-<span class="sourceLineNo">455</span>  }<a name="line.455"></a>
-<span class="sourceLineNo">456</span><a name="line.456"></a>
-<span class="sourceLineNo">457</span>  static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs,<a name="line.457"></a>
-<span class="sourceLineNo">458</span>      boolean isRegionServerRemote) {<a name="line.458"></a>
-<span class="sourceLineNo">459</span>    if (scanMetrics == null || rrs == null || rrs.length == 0) {<a name="line.459"></a>
-<span class="sourceLineNo">460</span>      return;<a name="line.460"></a>
-<span class="sourceLineNo">461</span>    }<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    long resultSize = 0;<a name="line.462"></a>
-<span class="sourceLineNo">463</span>    for (Result rr : rrs) {<a name="line.463"></a>
-<span class="sourceLineNo">464</span>      for (Cell cell : rr.rawCells()) {<a name="line.464"></a>
-<span class="sourceLineNo">465</span>        resultSize += PrivateCellUtil.estimatedSerializedSizeOf(cell);<a name="line.465"></a>
-<span class="sourceLineNo">466</span>      }<a name="line.466"></a>
-<span class="sourceLineNo">467</span>    }<a name="line.467"></a>
-<span class="sourceLineNo">468</span>    scanMetrics.countOfBytesInResults.addAndGet(resultSize);<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    if (isRegionServerRemote) {<a name="line.469"></a>
-<span class="sourceLineNo">470</span>      scanMetrics.countOfBytesInRemoteResults.addAndGet(resultSize);<a name="line.470"></a>
-<span class="sourceLineNo">471</span>    }<a name="line.471"></a>
-<span class="sourceLineNo">472</span>  }<a name="line.472"></a>
-<span class="sourceLineNo">473</span><a name="line.473"></a>
-<span class="sourceLineNo">474</span>  /**<a name="line.474"></a>
-<span class="sourceLineNo">475</span>   * Use the scan metrics returned by the server to add to the identically named counters in the<a name="line.475"></a>
-<span class="sourceLineNo">476</span>   * client side metrics. If a counter does not exist with the same name as the server side metric,<a name="line.476"></a>
-<span class="sourceLineNo">477</span>   * the attempt to increase the counter will fail.<a name="line.477"></a>
-<span class="sourceLineNo">478</span>   */<a name="line.478"></a>
-<span class="sourceLineNo">479</span>  static void updateServerSideMetrics(ScanMetrics scanMetrics, ScanResponse response) {<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    if (scanMetrics == null || response == null || !response.hasScanMetrics()) {<a name="line.480"></a>
-<span class="sourceLineNo">481</span>      return;<a name="line.481"></a>
-<span class="sourceLineNo">482</span>    }<a name="line.482"></a>
-<span class="sourceLineNo">483</span>    ResponseConverter.getScanMetrics(response).forEach(scanMetrics::addToCounter);<a name="line.483"></a>
-<span class="sourceLineNo">484</span>  }<a name="line.484"></a>
-<span class="sourceLineNo">485</span><a name="line.485"></a>
-<span class="sourceLineNo">486</span>  static void incRegionCountMetrics(ScanMetrics scanMetrics) {<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    if (scanMetrics == null) {<a name="line.487"></a>
-<span class="sourceLineNo">488</span>      return;<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    }<a name="line.489"></a>
-<span class="sourceLineNo">490</span>    scanMetrics.countOfRegions.incrementAndGet();<a name="line.490"></a>
-<span class="sourceLineNo">491</span>  }<a name="line.491"></a>
-<span class="sourceLineNo">492</span>}<a name="line.492"></a>
+<span class="sourceLineNo">119</span>    int serversideMultiplier = c.getInt(HConstants.HBASE_CLIENT_SERVERSIDE_RETRIES_MULTIPLIER,<a name="line.119"></a>
+<span class="sourceLineNo">120</span>      HConstants.DEFAULT_HBASE_CLIENT_SERVERSIDE_RETRIES_MULTIPLIER);<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    int retries = hcRetries * serversideMultiplier;<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, retries);<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    log.info(sn + " server-side Connection retries=" + retries);<a name="line.123"></a>
+<span class="sourceLineNo">124</span>  }<a name="line.124"></a>
+<span class="sourceLineNo">125</span><a name="line.125"></a>
+<span class="sourceLineNo">126</span>  /**<a name="line.126"></a>
+<span class="sourceLineNo">127</span>   * A ClusterConnection that will short-circuit RPC making direct invocations against the<a name="line.127"></a>
+<span class="sourceLineNo">128</span>   * localhost if the invocation target is 'this' server; save on network and protobuf<a name="line.128"></a>
+<span class="sourceLineNo">129</span>   * invocations.<a name="line.129"></a>
+<span class="sourceLineNo">130</span>   */<a name="line.130"></a>
+<span class="sourceLineNo">131</span>  // TODO This has to still do PB marshalling/unmarshalling stuff. Check how/whether we can avoid.<a name="line.131"></a>
+<span class="sourceLineNo">132</span>  @VisibleForTesting // Class is visible so can assert we are short-circuiting when expected.<a name="line.132"></a>
+<span class="sourceLineNo">133</span>  public static class ShortCircuitingClusterConnection extends ConnectionImplementation {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    private final ServerName serverName;<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    private final AdminService.BlockingInterface localHostAdmin;<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    private final ClientService.BlockingInterface localHostClient;<a name="line.136"></a>
+<span class="sourceLineNo">137</span><a name="line.137"></a>
+<span class="sourceLineNo">138</span>    private ShortCircuitingClusterConnection(Configuration conf, ExecutorService pool, User user,<a name="line.138"></a>
+<span class="sourceLineNo">139</span>        ServerName serverName, AdminService.BlockingInterface admin,<a name="line.139"></a>
+<span class="sourceLineNo">140</span>        ClientService.BlockingInterface client)<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    throws IOException {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      super(conf, pool, user);<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      this.serverName = serverName;<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      this.localHostAdmin = admin;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      this.localHostClient = client;<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    }<a name="line.146"></a>
+<span class="sourceLineNo">147</span><a name="line.147"></a>
+<span class="sourceLineNo">148</span>    @Override<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    public AdminService.BlockingInterface getAdmin(ServerName sn) throws IOException {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>      return serverName.equals(sn) ? this.localHostAdmin : super.getAdmin(sn);<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    }<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    @Override<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    public ClientService.BlockingInterface getClient(ServerName sn) throws IOException {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>      return serverName.equals(sn) ? this.localHostClient : super.getClient(sn);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    }<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>    @Override<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    public MasterKeepAliveConnection getKeepAliveMasterService() throws MasterNotRunningException {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>      if (this.localHostClient instanceof MasterService.BlockingInterface) {<a name="line.160"></a>
+<span class="sourceLineNo">161</span>        return new ShortCircuitMasterConnection((MasterService.BlockingInterface)this.localHostClient);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>      }<a name="line.162"></a>
+<span class="sourceLineNo">163</span>      return super.getKeepAliveMasterService();<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    }<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  }<a name="line.165"></a>
+<span class="sourceLineNo">166</span><a name="line.166"></a>
+<span class="sourceLineNo">167</span>  /**<a name="line.167"></a>
+<span class="sourceLineNo">168</span>   * Creates a short-circuit connection that can bypass the RPC layer (serialization,<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * deserialization, networking, etc..) when talking to a local server.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   * @param conf the current configuration<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * @param pool the thread pool to use for batch operations<a name="line.171"></a>
+<span class="sourceLineNo">172</span>   * @param user the user the connection is for<a name="line.172"></a>
+<span class="sourceLineNo">173</span>   * @param serverName the local server name<a name="line.173"></a>
+<span class="sourceLineNo">174</span>   * @param admin the admin interface of the local server<a name="line.174"></a>
+<span class="sourceLineNo">175</span>   * @param client the client interface of the local server<a name="line.175"></a>
+<span class="sourceLineNo">176</span>   * @return an short-circuit connection.<a name="line.176"></a>
+<span class="sourceLineNo">177</span>   * @throws IOException if IO failure occurred<a name="line.177"></a>
+<span class="sourceLineNo">178</span>   */<a name="line.178"></a>
+<span class="sourceLineNo">179</span>  public static ClusterConnection createShortCircuitConnection(final Configuration conf,<a name="line.179"></a>
+<span class="sourceLineNo">180</span>      ExecutorService pool, User user, final ServerName serverName,<a name="line.180"></a>
+<span class="sourceLineNo">181</span>      final AdminService.BlockingInterface admin, final ClientService.BlockingInterface client)<a name="line.181"></a>
+<span class="sourceLineNo">182</span>      throws IOException {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    if (user == null) {<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      user = UserProvider.instantiate(conf).getCurrent();<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    return new ShortCircuitingClusterConnection(conf, pool, user, serverName, admin, client);<a name="line.186"></a>
+<span class="sourceLineNo">187</span>  }<a name="line.187"></a>
+<span class="sourceLineNo">188</span><a name="line.188"></a>
+<span class="sourceLineNo">189</span>  /**<a name="line.189"></a>
+<span class="sourceLineNo">190</span>   * Setup the connection class, so that it will not depend on master being online. Used for testing<a name="line.190"></a>
+<span class="sourceLineNo">191</span>   * @param conf configuration to set<a name="line.191"></a>
+<span class="sourceLineNo">192</span>   */<a name="line.192"></a>
+<span class="sourceLineNo">193</span>  @VisibleForTesting<a name="line.193"></a>
+<span class="sourceLineNo">194</span>  public static void setupMasterlessConnection(Configuration conf) {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    conf.set(ClusterConnection.HBASE_CLIENT_CONNECTION_IMPL, MasterlessConnection.class.getName());<a name="line.195"></a>
+<span class="sourceLineNo">196</span>  }<a name="line.196"></a>
+<span class="sourceLineNo">197</span><a name="line.197"></a>
+<span class="sourceLineNo">198</span>  /**<a name="line.198"></a>
+<span class="sourceLineNo">199</span>   * Some tests shut down the master. But table availability is a master RPC which is performed on<a name="line.199"></a>
+<span class="sourceLineNo">200</span>   * region re-lookups.<a name="line.200"></a>
+<span class="sourceLineNo">201</span>   */<a name="line.201"></a>
+<span class="sourceLineNo">202</span>  static class MasterlessConnection extends ConnectionImplementation {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    MasterlessConnection(Configuration conf, ExecutorService pool, User user) throws IOException {<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      super(conf, pool, user);<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    }<a name="line.205"></a>
+<span class="sourceLineNo">206</span><a name="line.206"></a>
+<span class="sourceLineNo">207</span>    @Override<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    public boolean isTableDisabled(TableName tableName) throws IOException {<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      // treat all tables as enabled<a name="line.209"></a>
+<span class="sourceLineNo">210</span>      return false;<a name="line.210"></a>
+<span class="sourceLineNo">211</span>    }<a name="line.211"></a>
+<span class="sourceLineNo">212</span>  }<a name="line.212"></a>
+<span class="sourceLineNo">213</span><a name="line.213"></a>
+<span class="sourceLineNo">214</span>  /**<a name="line.214"></a>
+<span class="sourceLineNo">215</span>   * Return retires + 1. The returned value will be in range [1, Integer.MAX_VALUE].<a name="line.215"></a>
+<span class="sourceLineNo">216</span>   */<a name="line.216"></a>
+<span class="sourceLineNo">217</span>  static int retries2Attempts(int retries) {<a name="line.217"></a>
+<span class="sourceLineNo">218</span>    return Math.max(1, retries == Integer.MAX_VALUE ? Integer.MAX_VALUE : retries + 1);<a name="line.218"></a>
+<span class="sourceLineNo">219</span>  }<a name="line.219"></a>
+<span class="sourceLineNo">220</span><a name="line.220"></a>
+<span class="sourceLineNo">221</span>  /**<a name="line.221"></a>
+<span class="sourceLineNo">222</span>   * Get a unique key for the rpc stub to the given server.<a name="line.222"></a>
+<span class="sourceLineNo">223</span>   */<a name="line.223"></a>
+<span class="sourceLineNo">224</span>  static String getStubKey(String serviceName, ServerName serverName, boolean hostnameCanChange) {<a name="line.224"></a>
+<span class="sourceLineNo">225</span>    // Sometimes, servers go down and they come back up with the same hostname but a different<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    // IP address. Force a resolution of the rsHostname by trying to instantiate an<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    // InetSocketAddress, and this way we will rightfully get a new stubKey.<a name="line.227"></a>
+<span class="sourceLineNo">228</span>    // Also, include the hostname in the key so as to take care of those cases where the<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    // DNS name is different but IP address remains the same.<a name="line.229"></a>
+<span class="sourceLineNo">230</span>    String hostname = serverName.getHostname();<a name="line.230"></a>
+<span class="sourceLineNo">231</span>    int port = serverName.getPort();<a name="line.231"></a>
+<span class="sourceLineNo">232</span>    if (hostnameCanChange) {<a name="line.232"></a>
+<span class="sourceLineNo">233</span>      try {<a name="line.233"></a>
+<span class="sourceLineNo">234</span>        InetAddress ip = InetAddress.getByName(hostname);<a name="line.234"></a>
+<span class="sourceLineNo">235</span>        return serviceName + "@" + hostname + "-" + ip.getHostAddress() + ":" + port;<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      } catch (UnknownHostException e) {<a name="line.236"></a>
+<span class="sourceLineNo">237</span>        LOG.warn("Can not resolve " + hostname + ", please check your network", e);<a name="line.237"></a>
+<span class="sourceLineNo">238</span>      }<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    return serviceName + "@" + hostname + ":" + port;<a name="line.240"></a>
+<span class="sourceLineNo">241</span>  }<a name="line.241"></a>
+<span class="sourceLineNo">242</span><a name="line.242"></a>
+<span class="sourceLineNo">243</span>  static void checkHasFamilies(Mutation mutation) {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>    Preconditions.checkArgument(mutation.numFamilies() &gt; 0,<a name="line.244"></a>
+<span class="sourceLineNo">245</span>      "Invalid arguments to %s, zero columns specified", mutation.toString());<a name="line.245"></a>
+<span class="sourceLineNo">246</span>  }<a name="line.246"></a>
+<span class="sourceLineNo">247</span><a name="line.247"></a>
+<span class="sourceLineNo">248</span>  /** Dummy nonce generator for disabled nonces. */<a name="line.248"></a>
+<span class="sourceLineNo">249</span>  static final NonceGenerator NO_NONCE_GENERATOR = new NonceGenerator() {<a name="line.249"></a>
+<span class="sourceLineNo">250</span><a name="line.250"></a>
+<span class="sourceLineNo">251</span>    @Override<a name="line.251"></a>
+<span class="sourceLineNo">252</span>    public long newNonce() {<a name="line.252"></a>
+<span class="sourceLineNo">253</span>      return HConstants.NO_NONCE;<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    }<a name="line.254"></a>
+<span class="sourceLineNo">255</span><a name="line.255"></a>
+<span class="sourceLineNo">256</span>    @Override<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    public long getNonceGroup() {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>      return HConstants.NO_NONCE;<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    }<a name="line.259"></a>
+<span class="sourceLineNo">260</span>  };<a name="line.260"></a>
+<span class="sourceLineNo">261</span><a name="line.261"></a>
+<span class="sourceLineNo">262</span>  // A byte array in which all elements are the max byte, and it is used to<a name="line.262"></a>
+<span class="sourceLineNo">263</span>  // construct closest front row<a name="line.263"></a>
+<span class="sourceLineNo">264</span>  static final byte[] MAX_BYTE_ARRAY = Bytes.createMaxByteArray(9);<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>   * Create the closest row after the specified row<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   */<a name="line.268"></a>
+<span class="sourceLineNo">269</span>  static byte[] createClosestRowAfter(byte[] row) {<a name="line.269"></a>
+<span class="sourceLineNo">270</span>    return Arrays.copyOf(row, row.length + 1);<a name="line.270"></a>
+<span class="sourceLineNo">271</span>  }<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>   * Create a row before the specified row and very close to the specified row.<a name="line.274"></a>
+<span class="sourceLineNo">275</span>   */<a name="line.275"></a>
+<span class="sourceLineNo">276</span>  static byte[] createCloseRowBefore(byte[] row) {<a name="line.276"></a>
+<span class="sourceLineNo">277</span>    if (row.length == 0) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      return MAX_BYTE_ARRAY;<a name="line.278"></a>
+<span class="sourceLineNo">279</span>    }<a name="line.279"></a>
+<span class="sourceLineNo">280</span>    if (row[row.length - 1] == 0) {<a name="line.280"></a>
+<span class="sourceLineNo">281</span>      return Arrays.copyOf(row, row.length - 1);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>    } else {<a name="line.282"></a>
+<span class="sourceLineNo">283</span>      byte[] nextRow = new byte[row.length + MAX_BYTE_ARRAY.length];<a name="line.283"></a>
+<span class="sourceLineNo">284</span>      System.arraycopy(row, 0, nextRow, 0, row.length - 1);<a name="line.284"></a>
+<span class="sourceLineNo">285</span>      nextRow[row.length - 1] = (byte) ((row[row.length - 1] &amp; 0xFF) - 1);<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      System.arraycopy(MAX_BYTE_ARRAY, 0, nextRow, row.length, MAX_BYTE_ARRAY.length);<a name="line.286"></a>
+<span class="sourceLineNo">287</span>      return nextRow;<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    }<a name="line.288"></a>
+<span class="sourceLineNo">289</span>  }<a name="line.289"></a>
+<span class="sourceLineNo">290</span><a name="line.290"></a>
+<span class="sourceLineNo">291</span>  static boolean isEmptyStartRow(byte[] row) {<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    return Bytes.equals(row, EMPTY_START_ROW);<a name="line.292"></a>
+<span class="sourceLineNo">293</span>  }<a name="line.293"></a>
+<span class="sourceLineNo">294</span><a name="line.294"></a>
+<span class="sourceLineNo">295</span>  static boolean isEmptyStopRow(byte[] row) {<a name="line.295"></a>
+<span class="sourceLineNo">296</span>    return Bytes.equals(row, EMPTY_END_ROW);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>  }<a name="line.297"></a>
+<span class="sourceLineNo">298</span><a name="line.298"></a>
+<span class="sourceLineNo">299</span>  static void resetController(HBaseRpcController controller, long timeoutNs) {<a name="line.299"></a>
+<span class="sourceLineNo">300</span>    controller.reset();<a name="line.300"></a>
+<span class="sourceLineNo">301</span>    if (timeoutNs &gt;= 0) {<a name="line.301"></a>
+<span class="sourceLineNo">302</span>      controller.setCallTimeout(<a name="line.302"></a>
+<span class="sourceLineNo">303</span>        (int) Math.min(Integer.MAX_VALUE, TimeUnit.NANOSECONDS.toMillis(timeoutNs)));<a name="line.303"></a>
+<span class="sourceLineNo">304</span>    }<a name="line.304"></a>
+<span class="sourceLineNo">305</span>  }<a name="line.305"></a>
+<span class="sourceLineNo">306</span><a name="line.306"></a>
+<span class="sourceLineNo">307</span>  static Throwable translateException(Throwable t) {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    if (t instanceof UndeclaredThrowableException &amp;&amp; t.getCause() != null) {<a name="line.308"></a>
+<span class="sourceLineNo">309</span>      t = t.getCause();<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    }<a name="line.310"></a>
+<span class="sourceLineNo">311</span>    if (t instanceof RemoteException) {<a name="line.311"></a>
+<span class="sourceLineNo">312</span>      t = ((RemoteException) t).unwrapRemoteException();<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    }<a name="line.313"></a>
+<span class="sourceLineNo">314</span>    if (t instanceof ServiceException &amp;&amp; t.getCause() != null) {<a name="line.314"></a>
+<span class="sourceLineNo">315</span>      t = translateException(t.getCause());<a name="line.315"></a>
+<span class="sourceLineNo">316</span>    }<a name="line.316"></a>
+<span class="sourceLineNo">317</span>    return t;<a name="line.317"></a>
+<span class="sourceLineNo">318</span>  }<a name="line.318"></a>
+<span class="sourceLineNo">319</span><a name="line.319"></a>
+<span class="sourceLineNo">320</span>  static long calcEstimatedSize(Result rs) {<a name="line.320"></a>
+<span class="sourceLineNo">321</span>    long estimatedHeapSizeOfResult = 0;<a name="line.321"></a>
+<span class="sourceLineNo">322</span>    // We don't make Iterator here<a name="line.322"></a>
+<span class="sourceLineNo">323</span>    for (Cell cell : rs.rawCells()) {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>      estimatedHeapSizeOfResult += PrivateCellUtil.estimatedHeapSizeOf(cell);<a name="line.324"></a>
+<span class="sourceLineNo">325</span>    }<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    return estimatedHeapSizeOfResult;<a name="line.326"></a>
+<span class="sourceLineNo">327</span>  }<a name="line.327"></a>
+<span class="sourceLineNo">328</span><a name="line.328"></a>
+<span class="sourceLineNo">329</span>  static Result filterCells(Result result, Cell keepCellsAfter) {<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    if (keepCellsAfter == null) {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>      // do not need to filter<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      return result;<a name="line.332"></a>
+<span class="sourceLineNo">333</span>    }<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    // not the same row<a name="line.334"></a>
+<span class="sourceLineNo">335</span>    if (!PrivateCellUtil.matchingRows(keepCellsAfter, result.getRow(), 0, result.getRow().length)) {<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      return result;<a name="line.336"></a>
+<span class="sourceLineNo">337</span>    }<a name="line.337"></a>
+<span class="sourceLineNo">338</span>    Cell[] rawCells = result.rawCells();<a name="line.338"></a>
+<span class="sourceLineNo">339</span>    int index =<a name="line.339"></a>
+<span class="sourceLineNo">340</span>        Arrays.binarySearch(rawCells, keepCellsAfter, CellComparator.getInstance()::compareWithoutRow);<a name="line.340"></a>
+<span class="sourceLineNo">341</span>    if (index &lt; 0) {<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      index = -index - 1;<a name="line.342"></a>
+<span class="sourceLineNo">343</span>    } else {<a name="line.343"></a>
+<span class="sourceLineNo">344</span>      index++;<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    }<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    if (index == 0) {<a name="line.346"></a>
+<span class="sourceLineNo">347</span>      return result;<a name="line.347"></a>
+<span class="sourceLineNo">348</span>    }<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    if (index == rawCells.length) {<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      return null;<a name="line.350"></a>
+<span class="sourceLineNo">351</span>    }<a name="line.351"></a>
+<span class="sourceLineNo">352</span>    return Result.create(Arrays.copyOfRange(rawCells, index, rawCells.length), null,<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      result.isStale(), result.mayHaveMoreCellsInRow());<a name="line.353"></a>
+<span class="sourceLineNo">354</span>  }<a name="line.354"></a>
+<span class="sourceLineNo">355</span><a name="line.355"></a>
+<span class="sourceLineNo">356</span>  // Add a delta to avoid timeout immediately after a retry sleeping.<a name="line.356"></a>
+<span class="sourceLineNo">357</span>  static final long SLEEP_DELTA_NS = TimeUnit.MILLISECONDS.toNanos(1);<a name="line.357"></a>
+<span class="sourceLineNo">358</span><a name="line.358"></a>
+<span class="sourceLineNo">359</span>  static Get toCheckExistenceOnly(Get get) {<a name="line.359"></a>
+<span class="sourceLineNo">360</span>    if (get.isCheckExistenceOnly()) {<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      return get;<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    }<a name="line.362"></a>
+<span class="sourceLineNo">363</span>    return ReflectionUtils.newInstance(get.getClass(), get).setCheckExistenceOnly(true);<a name="line.363"></a>
+<span class="sourceLineNo">364</span>  }<a name="line.364"></a>
+<span class="sourceLineNo">365</span><a name="line.365"></a>
+<span class="sourceLineNo">366</span>  static List&lt;Get&gt; toCheckExistenceOnly(List&lt;Get&gt; gets) {<a name="line.366"></a>
+<span class="sourceLineNo">367</span>    return gets.stream().map(ConnectionUtils::toCheckExistenceOnly).collect(toList());<a name="line.367"></a>
+<span class="sourceLineNo">368</span>  }<a name="line.368"></a>
+<span class="sourceLineNo">369</span><a name="line.369"></a>
+<span class="sourceLineNo">370</span>  static RegionLocateType getLocateType(Scan scan) {<a name="line.370"></a>
+<span class="sourceLineNo">371</span>    if (scan.isReversed()) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>      if (isEmptyStartRow(scan.getStartRow())) {<a name="line.372"></a>
+<span class="sourceLineNo">373</span>        return RegionLocateType.BEFORE;<a name="line.373"></a>
+<span class="sourceLineNo">374</span>      } else {<a name="line.374"></a>
+<span class="sourceLineNo">375</span>        return scan.includeStartRow() ? RegionLocateType.CURRENT : RegionLocateType.BEFORE;<a name="line.375"></a>
+<span class="sourceLineNo">376</span>      }<a name="line.376"></a>
+<span class="sourceLineNo">377</span>    } else {<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      return scan.includeStartRow() ? RegionLocateType.CURRENT : RegionLocateType.AFTER;<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
+<span class="sourceLineNo">380</span>  }<a name="line.380"></a>
+<span class="sourceLineNo">381</span><a name="line.381"></a>
+<span class="sourceLineNo">382</span>  static boolean noMoreResultsForScan(Scan scan, RegionInfo info) {<a name="line.382"></a>
+<span class="sourceLineNo">383</span>    if (isEmptyStopRow(info.getEndKey())) {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>      return true;<a name="line.384"></a>
+<span class="sourceLineNo">385</span>    }<a name="line.385"></a>
+<span class="sourceLineNo">386</span>    if (isEmptyStopRow(scan.getStopRow())) {<a name="line.386"></a>
+<span class="sourceLineNo">387</span>      return false;<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    }<a name="line.388"></a>
+<span class="sourceLineNo">389</span>    int c = Bytes.compareTo(info.getEndKey(), scan.getStopRow());<a name="line.389"></a>
+<span class="sourceLineNo">390</span>    // 1. if our stop row is less than the endKey of the region<a name="line.390"></a>
+<span class="sourceLineNo">391</span>    // 2. if our stop row is equal to the endKey of the region and we do not include the stop row<a name="line.391"></a>
+<span class="sourceLineNo">392</span>    // for scan.<a name="line.392"></a>
+<span class="sourceLineNo">393</span>    return c &gt; 0 || (c == 0 &amp;&amp; !scan.includeStopRow());<a name="line.393"></a>
+<span class="sourceLineNo">394</span>  }<a name="line.394"></a>
+<span class="sourceLineNo">395</span><a name="line.395"></a>
+<span class="sourceLineNo">396</span>  static boolean noMoreResultsForReverseScan(Scan scan, RegionInfo info) {<a name="line.396"></a>
+<span class="sourceLineNo">397</span>    if (isEmptyStartRow(info.getStartKey())) {<a name="line.397"></a>
+<span class="sourceLineNo">398</span>      return true;<a name="line.398"></a>
+<span class="sourceLineNo">399</span>    }<a name="line.399"></a>
+<span class="sourceLineNo">400</span>    if (isEmptyStopRow(scan.getStopRow())) {<a name="line.400"></a>
+<span class="sourceLineNo">401</span>      return false;<a name="line.401"></a>
+<span class="sourceLineNo">402</span>    }<a name="line.402"></a>
+<span class="sourceLineNo">403</span>    // no need to test the inclusive of the stop row as the start key of a region is included in<a name="line.403"></a>
+<span class="sourceLineNo">404</span>    // the region.<a name="line.404"></a>
+<span class="sourceLineNo">405</span>    return Bytes.compareTo(info.getStartKey(), scan.getStopRow()) &lt;= 0;<a name="line.405"></a>
+<span class="sourceLineNo">406</span>  }<a name="line.406"></a>
+<span class="sourceLineNo">407</span><a name="line.407"></a>
+<span class="sourceLineNo">408</span>  static &lt;T&gt; CompletableFuture&lt;List&lt;T&gt;&gt; allOf(List&lt;CompletableFuture&lt;T&gt;&gt; futures) {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>    return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))<a name="line.409"></a>
+<span class="sourceLineNo">410</span>        .thenApply(v -&gt; futures.stream().map(f -&gt; f.getNow(null)).collect(toList()));<a name="line.410"></a>
+<span class="sourceLineNo">411</span>  }<a name="line.411"></a>
+<span class="sourceLineNo">412</span><a name="line.412"></a>
+<span class="sourceLineNo">413</span>  public static ScanResultCache createScanResultCache(Scan scan) {<a name="line.413"></a>
+<span class="sourceLineNo">414</span>    if (scan.getAllowPartialResults()) {<a name="line.414"></a>
+<span class="sourceLineNo">415</span>      return new AllowPartialScanResultCache();<a name="line.415"></a>
+<span class="sourceLineNo">416</span>    } else if (scan.getBatch() &gt; 0) {<a name="line.416"></a>
+<span class="sourceLineNo">417</span>      return new BatchScanResultCache(scan.getBatch());<a name="line.417"></a>
+<span class="sourceLineNo">418</span>    } else {<a name="line.418"></a>
+<span class="sourceLineNo">419</span>      return new CompleteScanResultCache();<a name="line.419"></a>
+<span class="sourceLineNo">420</span>    }<a name="line.420"></a>
+<span class="sourceLineNo">421</span>  }<a name="line.421"></a>
+<span class="sourceLineNo">422</span><a name="line.422"></a>
+<span class="sourceLineNo">423</span>  private static final String MY_ADDRESS = getMyAddress();<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>  private static String getMyAddress() {<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    try {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      return DNS.getDefaultHost("default", "default");<a name="line.427"></a>
+<span class="sourceLineNo">428</span>    } catch (UnknownHostException uhe) {<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      LOG.error("cannot determine my address", uhe);<a name="line.429"></a>
+<span class="sourceLineNo">430</span>      return null;<a name="line.430"></a>
+<span class="sourceLineNo">431</span>    }<a name="line.431"></a>
+<span class="sourceLineNo">432</span>  }<a name="line.432"></a>
+<span class="sourceLineNo">433</span><a name="line.433"></a>
+<span class="sourceLineNo">434</span>  static boolean isRemote(String host) {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>    return !host.equalsIgnoreCase(MY_ADDRESS);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
+<span class="sourceLineNo">437</span><a name="line.437"></a>
+<span class="sourceLineNo">438</span>  static void incRPCCallsMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) {<a name="line.438"></a>
+<span class="sourceLineNo">439</span>    if (scanMetrics == null) {<a name="line.439"></a>
+<span class="sourceLineNo">440</span>      return;<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    }<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    scanMetrics.countOfRPCcalls.incrementAndGet();<a name="line.442"></a>
+<span class="sourceLineNo">443</span>    if (isRegionServerRemote) {<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      scanMetrics.countOfRemoteRPCcalls.incrementAndGet();<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    }<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  }<a name="line.446"></a>
+<span class="sourceLineNo">447</span><a name="line.447"></a>
+<span class="sourceLineNo">448</span>  static void incRPCRetriesMetrics(ScanMetrics scanMetrics, boolean isRegionServerRemote) {<a name="line.448"></a>
+<span class="sourceLineNo">449</span>    if (scanMetrics == null) {<a name="line.449"></a>
+<span class="sourceLineNo">450</span>      return;<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    }<a name="line.451"></a>
+<span class="sourceLineNo">452</span>    scanMetrics.countOfRPCRetries.incrementAndGet();<a name="line.452"></a>
+<span class="sourceLineNo">453</span>    if (isRegionServerRemote) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      scanMetrics.countOfRemoteRPCRetries.incrementAndGet();<a name="line.454"></a>
+<span class="sourceLineNo">455</span>    }<a name="line.455"></a>
+<span class="sourceLineNo">456</span>  }<a name="line.456"></a>
+<span class="sourceLineNo">457</span><a name="line.457"></a>
+<span class="sourceLineNo">458</span>  static void updateResultsMetrics(ScanMetrics scanMetrics, Result[] rrs,<a name="line.458"></a>
+<span class="sourceLineNo">459</span>      boolean isRegionServerRemote) {<a name="line.459"></a>
+<span class="sourceLineNo">460</span>    if (scanMetrics == null || rrs == null || rrs.length == 0) {<a name="line.460"></a>
+<span class="sourceLineNo">461</span>      return;<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    }<a name="line.462"></a>
+<span class="sourceLineNo">463</span>    long resultSize = 0;<a name="line.463"></a>
+<span class="sourceLineNo">464</span>    for (Result rr : rrs) {<a name="line.464"></a>
+<span class="sourceLineNo">465</span>      for (Cell cell : rr.rawCells()) {<a name="line.465"></a>
+<span class="sourceLineNo">466</span>        resultSize += PrivateCellUtil.estimatedSerializedSizeOf(cell);<a name="line.466"></a>
+<span class="sourceLineNo">467</span>      }<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    }<a name="line.468"></a>
+<span class="sourceLineNo">469</span>    scanMetrics.countOfBytesInResults.addAndGet(resultSize);<a name="line.469"></a>
+<span class="sourceLineNo">470</span>    if (isRegionServerRemote) {<a name="line.470"></a>
+<span class="sourceLineNo">471</span>      scanMetrics.countOfBytesInRemoteResults.addAndGet(resultSize);<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    }<a name="line.472"></a>
+<span class="sourceLineNo">473</span>  }<a name="line.473"></a>
+<span class="sourceLineNo">474</span><a name="line.474"></a>
+<span class="sourceLineNo">475</span>  /**<a name="line.475"></a>
+<span class="sourceLineNo">476</span>   * Use the scan metrics returned by the server to add to the identically named counters in the<a name="line.476"></a>
+<span class="sourceLineNo">477</span>   * client side metrics. If a counter does not exist with the same name as the server side metric,<a name="line.477"></a>
+<span class="sourceLineNo">478</span>   * the attempt to increase the counter will fail.<a name="line.478"></a>
+<span class="sourceLineNo">479</span>   */<a name="line.479"></a>
+<span class="sourceLineNo">480</span>  static void updateServerSideMetrics(ScanMetrics scanMetrics, ScanResponse response) {<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    if (scanMetrics == null || response == null || !response.hasScanMetrics()) {<a name="line.481"></a>
+<span class="sourceLineNo">482</span>      return;<a name="line.482"></a>
+<span class="sourceLineNo">483</span>    }<a name="line.483"></a>
+<span class="sourceLineNo">484</span>    ResponseConverter.getScanMetrics(response).forEach(scanMetrics::addToCounter);<a name="line.484"></a>
+<span class="sourceLineNo">485</span>  }<a name="line.485"></a>
+<span class="sourceLineNo">486</span><a name="line.486"></a>
+<span class="sourceLineNo">487</span>  static void incRegionCountMetrics(ScanMetrics scanMetrics) {<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    if (scanMetrics == null) {<a name="line.488"></a>
+<span class="sourceLineNo">489</span>      return;<a name="line.489"></a>
+<span class="sourceLineNo">490</span>    }<a name="line.490"></a>
+<span class="sourceLineNo">491</span>    scanMetrics.countOfRegions.incrementAndGet();<a name="line.491"></a>
+<span class="sourceLineNo">492</span>  }<a name="line.492"></a>
+<span class="sourceLineNo">493</span>}<a name="line.493"></a>
 
 
 


Mime
View raw message