hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [05/51] [partial] hbase-site git commit: Published site at .
Date Wed, 16 Aug 2017 15:06:26 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/1ada5f22/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.html
index e7cd47c..d61d346 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncScanSingleRegionRpcRetryingCaller.html
@@ -43,132 +43,132 @@
 <span class="sourceLineNo">035</span><a name="line.35"></a>
 <span class="sourceLineNo">036</span>import java.io.IOException;<a name="line.36"></a>
 <span class="sourceLineNo">037</span>import java.util.ArrayList;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import java.util.List;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import java.util.Optional;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import java.util.concurrent.CompletableFuture;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import java.util.concurrent.TimeUnit;<a name="line.41"></a>
-<span class="sourceLineNo">042</span><a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.apache.commons.logging.Log;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.commons.logging.LogFactory;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.DoNotRetryIOException;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.46"></a>
-<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.UnknownScannerException;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.client.RawScanResultConsumer.ScanResumer;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.apache.hadoop.hbase.client.metrics.ScanMetrics;<a name="line.51"></a>
-<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.exceptions.ScannerResetException;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.ipc.HBaseRpcController;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;<a name="line.55"></a>
-<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.56"></a>
-<span class="sourceLineNo">057</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.57"></a>
-<span class="sourceLineNo">058</span>import org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter;<a name="line.58"></a>
-<span class="sourceLineNo">059</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService;<a name="line.59"></a>
-<span class="sourceLineNo">060</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.Interface;<a name="line.60"></a>
-<span class="sourceLineNo">061</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest;<a name="line.61"></a>
-<span class="sourceLineNo">062</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.63"></a>
-<span class="sourceLineNo">064</span><a name="line.64"></a>
-<span class="sourceLineNo">065</span>/**<a name="line.65"></a>
-<span class="sourceLineNo">066</span> * Retry caller for scanning a region.<a name="line.66"></a>
-<span class="sourceLineNo">067</span> * &lt;p&gt;<a name="line.67"></a>
-<span class="sourceLineNo">068</span> * We will modify the {@link Scan} object passed in directly. The upper layer should store the<a name="line.68"></a>
-<span class="sourceLineNo">069</span> * reference of this object and use it to open new single region scanners.<a name="line.69"></a>
-<span class="sourceLineNo">070</span> */<a name="line.70"></a>
-<span class="sourceLineNo">071</span>@InterfaceAudience.Private<a name="line.71"></a>
-<span class="sourceLineNo">072</span>class AsyncScanSingleRegionRpcRetryingCaller {<a name="line.72"></a>
-<span class="sourceLineNo">073</span><a name="line.73"></a>
-<span class="sourceLineNo">074</span>  private static final Log LOG = LogFactory.getLog(AsyncScanSingleRegionRpcRetryingCaller.class);<a name="line.74"></a>
-<span class="sourceLineNo">075</span><a name="line.75"></a>
-<span class="sourceLineNo">076</span>  private final HashedWheelTimer retryTimer;<a name="line.76"></a>
-<span class="sourceLineNo">077</span><a name="line.77"></a>
-<span class="sourceLineNo">078</span>  private final Scan scan;<a name="line.78"></a>
-<span class="sourceLineNo">079</span><a name="line.79"></a>
-<span class="sourceLineNo">080</span>  private final ScanMetrics scanMetrics;<a name="line.80"></a>
-<span class="sourceLineNo">081</span><a name="line.81"></a>
-<span class="sourceLineNo">082</span>  private final long scannerId;<a name="line.82"></a>
-<span class="sourceLineNo">083</span><a name="line.83"></a>
-<span class="sourceLineNo">084</span>  private final ScanResultCache resultCache;<a name="line.84"></a>
-<span class="sourceLineNo">085</span><a name="line.85"></a>
-<span class="sourceLineNo">086</span>  private final RawScanResultConsumer consumer;<a name="line.86"></a>
-<span class="sourceLineNo">087</span><a name="line.87"></a>
-<span class="sourceLineNo">088</span>  private final ClientService.Interface stub;<a name="line.88"></a>
-<span class="sourceLineNo">089</span><a name="line.89"></a>
-<span class="sourceLineNo">090</span>  private final HRegionLocation loc;<a name="line.90"></a>
-<span class="sourceLineNo">091</span><a name="line.91"></a>
-<span class="sourceLineNo">092</span>  private final boolean regionServerRemote;<a name="line.92"></a>
-<span class="sourceLineNo">093</span><a name="line.93"></a>
-<span class="sourceLineNo">094</span>  private final long scannerLeaseTimeoutPeriodNs;<a name="line.94"></a>
-<span class="sourceLineNo">095</span><a name="line.95"></a>
-<span class="sourceLineNo">096</span>  private final long pauseNs;<a name="line.96"></a>
-<span class="sourceLineNo">097</span><a name="line.97"></a>
-<span class="sourceLineNo">098</span>  private final int maxAttempts;<a name="line.98"></a>
-<span class="sourceLineNo">099</span><a name="line.99"></a>
-<span class="sourceLineNo">100</span>  private final long scanTimeoutNs;<a name="line.100"></a>
-<span class="sourceLineNo">101</span><a name="line.101"></a>
-<span class="sourceLineNo">102</span>  private final long rpcTimeoutNs;<a name="line.102"></a>
-<span class="sourceLineNo">103</span><a name="line.103"></a>
-<span class="sourceLineNo">104</span>  private final int startLogErrorsCnt;<a name="line.104"></a>
-<span class="sourceLineNo">105</span><a name="line.105"></a>
-<span class="sourceLineNo">106</span>  private final Runnable completeWhenNoMoreResultsInRegion;<a name="line.106"></a>
-<span class="sourceLineNo">107</span><a name="line.107"></a>
-<span class="sourceLineNo">108</span>  private final CompletableFuture&lt;Boolean&gt; future;<a name="line.108"></a>
-<span class="sourceLineNo">109</span><a name="line.109"></a>
-<span class="sourceLineNo">110</span>  private final HBaseRpcController controller;<a name="line.110"></a>
-<span class="sourceLineNo">111</span><a name="line.111"></a>
-<span class="sourceLineNo">112</span>  private byte[] nextStartRowWhenError;<a name="line.112"></a>
-<span class="sourceLineNo">113</span><a name="line.113"></a>
-<span class="sourceLineNo">114</span>  private boolean includeNextStartRowWhenError;<a name="line.114"></a>
-<span class="sourceLineNo">115</span><a name="line.115"></a>
-<span class="sourceLineNo">116</span>  private long nextCallStartNs;<a name="line.116"></a>
-<span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>  private int tries;<a name="line.118"></a>
-<span class="sourceLineNo">119</span><a name="line.119"></a>
-<span class="sourceLineNo">120</span>  private final List&lt;RetriesExhaustedException.ThrowableWithExtraContext&gt; exceptions;<a name="line.120"></a>
-<span class="sourceLineNo">121</span><a name="line.121"></a>
-<span class="sourceLineNo">122</span>  private long nextCallSeq = -1L;<a name="line.122"></a>
-<span class="sourceLineNo">123</span><a name="line.123"></a>
-<span class="sourceLineNo">124</span>  private enum ScanControllerState {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    INITIALIZED, SUSPENDED, TERMINATED, DESTROYED<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  }<a name="line.126"></a>
-<span class="sourceLineNo">127</span><a name="line.127"></a>
-<span class="sourceLineNo">128</span>  // Since suspend and terminate should only be called within onNext or onHeartbeat(see the comments<a name="line.128"></a>
-<span class="sourceLineNo">129</span>  // of RawScanResultConsumer.onNext and onHeartbeat), we need to add some check to prevent invalid<a name="line.129"></a>
-<span class="sourceLineNo">130</span>  // usage. We use two things to prevent invalid usage:<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  // 1. Record the thread that construct the ScanControllerImpl instance. We will throw an<a name="line.131"></a>
-<span class="sourceLineNo">132</span>  // IllegalStateException if the caller thread is not this thread.<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  // 2. The ControllerState. The initial state is INITIALIZED, if you call suspend, the state will<a name="line.133"></a>
-<span class="sourceLineNo">134</span>  // be transformed to SUSPENDED, and if you call terminate, the state will be transformed to<a name="line.134"></a>
-<span class="sourceLineNo">135</span>  // TERMINATED. And when we are back from onNext or onHeartbeat in the onComplete method, we will<a name="line.135"></a>
-<span class="sourceLineNo">136</span>  // call destroy to get the current state and set the state to DESTROYED. And when user calls<a name="line.136"></a>
-<span class="sourceLineNo">137</span>  // suspend or terminate, we will check if the current state is INITIALIZED, if not we will throw<a name="line.137"></a>
-<span class="sourceLineNo">138</span>  // an IllegalStateException. Notice that the DESTROYED state is necessary as you may not call<a name="line.138"></a>
-<span class="sourceLineNo">139</span>  // suspend or terminate so the state will still be INITIALIZED when back from onNext or<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  // onHeartbeat. We need another state to replace the INITIALIZED state to prevent the controller<a name="line.140"></a>
-<span class="sourceLineNo">141</span>  // to be used in the future.<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  // Notice that, the public methods of this class is supposed to be called by upper layer only, and<a name="line.142"></a>
-<span class="sourceLineNo">143</span>  // package private methods can only be called within the implementation of<a name="line.143"></a>
-<span class="sourceLineNo">144</span>  // AsyncScanSingleRegionRpcRetryingCaller.<a name="line.144"></a>
-<span class="sourceLineNo">145</span>  private final class ScanControllerImpl implements RawScanResultConsumer.ScanController {<a name="line.145"></a>
-<span class="sourceLineNo">146</span><a name="line.146"></a>
-<span class="sourceLineNo">147</span>    // Make sure the methods are only called in this thread.<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    private final Thread callerThread;<a name="line.148"></a>
-<span class="sourceLineNo">149</span><a name="line.149"></a>
-<span class="sourceLineNo">150</span>    private final Optional&lt;Cursor&gt; cursor;<a name="line.150"></a>
-<span class="sourceLineNo">151</span><a name="line.151"></a>
-<span class="sourceLineNo">152</span>    // INITIALIZED -&gt; SUSPENDED -&gt; DESTROYED<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    // INITIALIZED -&gt; TERMINATED -&gt; DESTROYED<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    // INITIALIZED -&gt; DESTROYED<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    // If the state is incorrect we will throw IllegalStateException.<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    private ScanControllerState state = ScanControllerState.INITIALIZED;<a name="line.156"></a>
-<span class="sourceLineNo">157</span><a name="line.157"></a>
-<span class="sourceLineNo">158</span>    private ScanResumerImpl resumer;<a name="line.158"></a>
-<span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    public ScanControllerImpl(ScanResponse resp) {<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      callerThread = Thread.currentThread();<a name="line.161"></a>
-<span class="sourceLineNo">162</span>      cursor = resp.hasCursor() ? Optional.of(ProtobufUtil.toCursor(resp.getCursor()))<a name="line.162"></a>
-<span class="sourceLineNo">163</span>          : Optional.empty();<a name="line.163"></a>
+<span class="sourceLineNo">038</span>import java.util.Arrays;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import java.util.List;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import java.util.Optional;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import java.util.concurrent.CompletableFuture;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import java.util.concurrent.TimeUnit;<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.apache.commons.logging.Log;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.commons.logging.LogFactory;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.DoNotRetryIOException;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.NotServingRegionException;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.UnknownScannerException;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>import org.apache.hadoop.hbase.client.RawScanResultConsumer.ScanResumer;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.client.metrics.ScanMetrics;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.exceptions.ScannerResetException;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.ipc.HBaseRpcController;<a name="line.55"></a>
+<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;<a name="line.56"></a>
+<span class="sourceLineNo">057</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;<a name="line.58"></a>
+<span class="sourceLineNo">059</span>import org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter;<a name="line.59"></a>
+<span class="sourceLineNo">060</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService;<a name="line.60"></a>
+<span class="sourceLineNo">061</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.Interface;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest;<a name="line.62"></a>
+<span class="sourceLineNo">063</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.64"></a>
+<span class="sourceLineNo">065</span><a name="line.65"></a>
+<span class="sourceLineNo">066</span>/**<a name="line.66"></a>
+<span class="sourceLineNo">067</span> * Retry caller for scanning a region.<a name="line.67"></a>
+<span class="sourceLineNo">068</span> * &lt;p&gt;<a name="line.68"></a>
+<span class="sourceLineNo">069</span> * We will modify the {@link Scan} object passed in directly. The upper layer should store the<a name="line.69"></a>
+<span class="sourceLineNo">070</span> * reference of this object and use it to open new single region scanners.<a name="line.70"></a>
+<span class="sourceLineNo">071</span> */<a name="line.71"></a>
+<span class="sourceLineNo">072</span>@InterfaceAudience.Private<a name="line.72"></a>
+<span class="sourceLineNo">073</span>class AsyncScanSingleRegionRpcRetryingCaller {<a name="line.73"></a>
+<span class="sourceLineNo">074</span><a name="line.74"></a>
+<span class="sourceLineNo">075</span>  private static final Log LOG = LogFactory.getLog(AsyncScanSingleRegionRpcRetryingCaller.class);<a name="line.75"></a>
+<span class="sourceLineNo">076</span><a name="line.76"></a>
+<span class="sourceLineNo">077</span>  private final HashedWheelTimer retryTimer;<a name="line.77"></a>
+<span class="sourceLineNo">078</span><a name="line.78"></a>
+<span class="sourceLineNo">079</span>  private final Scan scan;<a name="line.79"></a>
+<span class="sourceLineNo">080</span><a name="line.80"></a>
+<span class="sourceLineNo">081</span>  private final ScanMetrics scanMetrics;<a name="line.81"></a>
+<span class="sourceLineNo">082</span><a name="line.82"></a>
+<span class="sourceLineNo">083</span>  private final long scannerId;<a name="line.83"></a>
+<span class="sourceLineNo">084</span><a name="line.84"></a>
+<span class="sourceLineNo">085</span>  private final ScanResultCache resultCache;<a name="line.85"></a>
+<span class="sourceLineNo">086</span><a name="line.86"></a>
+<span class="sourceLineNo">087</span>  private final RawScanResultConsumer consumer;<a name="line.87"></a>
+<span class="sourceLineNo">088</span><a name="line.88"></a>
+<span class="sourceLineNo">089</span>  private final ClientService.Interface stub;<a name="line.89"></a>
+<span class="sourceLineNo">090</span><a name="line.90"></a>
+<span class="sourceLineNo">091</span>  private final HRegionLocation loc;<a name="line.91"></a>
+<span class="sourceLineNo">092</span><a name="line.92"></a>
+<span class="sourceLineNo">093</span>  private final boolean regionServerRemote;<a name="line.93"></a>
+<span class="sourceLineNo">094</span><a name="line.94"></a>
+<span class="sourceLineNo">095</span>  private final long scannerLeaseTimeoutPeriodNs;<a name="line.95"></a>
+<span class="sourceLineNo">096</span><a name="line.96"></a>
+<span class="sourceLineNo">097</span>  private final long pauseNs;<a name="line.97"></a>
+<span class="sourceLineNo">098</span><a name="line.98"></a>
+<span class="sourceLineNo">099</span>  private final int maxAttempts;<a name="line.99"></a>
+<span class="sourceLineNo">100</span><a name="line.100"></a>
+<span class="sourceLineNo">101</span>  private final long scanTimeoutNs;<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>  private final long rpcTimeoutNs;<a name="line.103"></a>
+<span class="sourceLineNo">104</span><a name="line.104"></a>
+<span class="sourceLineNo">105</span>  private final int startLogErrorsCnt;<a name="line.105"></a>
+<span class="sourceLineNo">106</span><a name="line.106"></a>
+<span class="sourceLineNo">107</span>  private final Runnable completeWhenNoMoreResultsInRegion;<a name="line.107"></a>
+<span class="sourceLineNo">108</span><a name="line.108"></a>
+<span class="sourceLineNo">109</span>  private final CompletableFuture&lt;Boolean&gt; future;<a name="line.109"></a>
+<span class="sourceLineNo">110</span><a name="line.110"></a>
+<span class="sourceLineNo">111</span>  private final HBaseRpcController controller;<a name="line.111"></a>
+<span class="sourceLineNo">112</span><a name="line.112"></a>
+<span class="sourceLineNo">113</span>  private byte[] nextStartRowWhenError;<a name="line.113"></a>
+<span class="sourceLineNo">114</span><a name="line.114"></a>
+<span class="sourceLineNo">115</span>  private boolean includeNextStartRowWhenError;<a name="line.115"></a>
+<span class="sourceLineNo">116</span><a name="line.116"></a>
+<span class="sourceLineNo">117</span>  private long nextCallStartNs;<a name="line.117"></a>
+<span class="sourceLineNo">118</span><a name="line.118"></a>
+<span class="sourceLineNo">119</span>  private int tries;<a name="line.119"></a>
+<span class="sourceLineNo">120</span><a name="line.120"></a>
+<span class="sourceLineNo">121</span>  private final List&lt;RetriesExhaustedException.ThrowableWithExtraContext&gt; exceptions;<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>  private long nextCallSeq = -1L;<a name="line.123"></a>
+<span class="sourceLineNo">124</span><a name="line.124"></a>
+<span class="sourceLineNo">125</span>  private enum ScanControllerState {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    INITIALIZED, SUSPENDED, TERMINATED, DESTROYED<a name="line.126"></a>
+<span class="sourceLineNo">127</span>  }<a name="line.127"></a>
+<span class="sourceLineNo">128</span><a name="line.128"></a>
+<span class="sourceLineNo">129</span>  // Since suspend and terminate should only be called within onNext or onHeartbeat(see the comments<a name="line.129"></a>
+<span class="sourceLineNo">130</span>  // of RawScanResultConsumer.onNext and onHeartbeat), we need to add some check to prevent invalid<a name="line.130"></a>
+<span class="sourceLineNo">131</span>  // usage. We use two things to prevent invalid usage:<a name="line.131"></a>
+<span class="sourceLineNo">132</span>  // 1. Record the thread that construct the ScanControllerImpl instance. We will throw an<a name="line.132"></a>
+<span class="sourceLineNo">133</span>  // IllegalStateException if the caller thread is not this thread.<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  // 2. The ControllerState. The initial state is INITIALIZED, if you call suspend, the state will<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  // be transformed to SUSPENDED, and if you call terminate, the state will be transformed to<a name="line.135"></a>
+<span class="sourceLineNo">136</span>  // TERMINATED. And when we are back from onNext or onHeartbeat in the onComplete method, we will<a name="line.136"></a>
+<span class="sourceLineNo">137</span>  // call destroy to get the current state and set the state to DESTROYED. And when user calls<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  // suspend or terminate, we will check if the current state is INITIALIZED, if not we will throw<a name="line.138"></a>
+<span class="sourceLineNo">139</span>  // an IllegalStateException. Notice that the DESTROYED state is necessary as you may not call<a name="line.139"></a>
+<span class="sourceLineNo">140</span>  // suspend or terminate so the state will still be INITIALIZED when back from onNext or<a name="line.140"></a>
+<span class="sourceLineNo">141</span>  // onHeartbeat. We need another state to replace the INITIALIZED state to prevent the controller<a name="line.141"></a>
+<span class="sourceLineNo">142</span>  // to be used in the future.<a name="line.142"></a>
+<span class="sourceLineNo">143</span>  // Notice that, the public methods of this class is supposed to be called by upper layer only, and<a name="line.143"></a>
+<span class="sourceLineNo">144</span>  // package private methods can only be called within the implementation of<a name="line.144"></a>
+<span class="sourceLineNo">145</span>  // AsyncScanSingleRegionRpcRetryingCaller.<a name="line.145"></a>
+<span class="sourceLineNo">146</span>  private final class ScanControllerImpl implements RawScanResultConsumer.ScanController {<a name="line.146"></a>
+<span class="sourceLineNo">147</span><a name="line.147"></a>
+<span class="sourceLineNo">148</span>    // Make sure the methods are only called in this thread.<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    private final Thread callerThread;<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>    private final Optional&lt;Cursor&gt; cursor;<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    // INITIALIZED -&gt; SUSPENDED -&gt; DESTROYED<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    // INITIALIZED -&gt; TERMINATED -&gt; DESTROYED<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    // INITIALIZED -&gt; DESTROYED<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    // If the state is incorrect we will throw IllegalStateException.<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    private ScanControllerState state = ScanControllerState.INITIALIZED;<a name="line.157"></a>
+<span class="sourceLineNo">158</span><a name="line.158"></a>
+<span class="sourceLineNo">159</span>    private ScanResumerImpl resumer;<a name="line.159"></a>
+<span class="sourceLineNo">160</span><a name="line.160"></a>
+<span class="sourceLineNo">161</span>    public ScanControllerImpl(Optional&lt;Cursor&gt; cursor) {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>      this.callerThread = Thread.currentThread();<a name="line.162"></a>
+<span class="sourceLineNo">163</span>      this.cursor = cursor;<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>    private void preCheck() {<a name="line.166"></a>
@@ -484,107 +484,126 @@
 <span class="sourceLineNo">476</span>    }<a name="line.476"></a>
 <span class="sourceLineNo">477</span>    updateServerSideMetrics(scanMetrics, resp);<a name="line.477"></a>
 <span class="sourceLineNo">478</span>    boolean isHeartbeatMessage = resp.hasHeartbeatMessage() &amp;&amp; resp.getHeartbeatMessage();<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    Result[] results;<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    int numberOfCompleteRowsBefore = resultCache.numberOfCompleteRows();<a name="line.480"></a>
-<span class="sourceLineNo">481</span>    try {<a name="line.481"></a>
-<span class="sourceLineNo">482</span>      Result[] rawResults = ResponseConverter.getResults(controller.cellScanner(), resp);<a name="line.482"></a>
-<span class="sourceLineNo">483</span>      updateResultsMetrics(scanMetrics, rawResults, isHeartbeatMessage);<a name="line.483"></a>
-<span class="sourceLineNo">484</span>      results = resultCache.addAndGet(<a name="line.484"></a>
-<span class="sourceLineNo">485</span>        Optional.ofNullable(rawResults).orElse(ScanResultCache.EMPTY_RESULT_ARRAY),<a name="line.485"></a>
-<span class="sourceLineNo">486</span>        isHeartbeatMessage);<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    } catch (IOException e) {<a name="line.487"></a>
-<span class="sourceLineNo">488</span>      // We can not retry here. The server has responded normally and the call sequence has been<a name="line.488"></a>
-<span class="sourceLineNo">489</span>      // increased so a new scan with the same call sequence will cause an<a name="line.489"></a>
-<span class="sourceLineNo">490</span>      // OutOfOrderScannerNextException. Let the upper layer open a new scanner.<a name="line.490"></a>
-<span class="sourceLineNo">491</span>      LOG.warn("decode scan response failed", e);<a name="line.491"></a>
-<span class="sourceLineNo">492</span>      completeWhenError(true);<a name="line.492"></a>
-<span class="sourceLineNo">493</span>      return;<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    }<a name="line.494"></a>
-<span class="sourceLineNo">495</span><a name="line.495"></a>
-<span class="sourceLineNo">496</span>    ScanControllerImpl scanController = new ScanControllerImpl(resp);<a name="line.496"></a>
-<span class="sourceLineNo">497</span>    if (results.length &gt; 0) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>      updateNextStartRowWhenError(results[results.length - 1]);<a name="line.498"></a>
-<span class="sourceLineNo">499</span>      consumer.onNext(results, scanController);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    } else if (resp.hasHeartbeatMessage() &amp;&amp; resp.getHeartbeatMessage()) {<a name="line.500"></a>
-<span class="sourceLineNo">501</span>      consumer.onHeartbeat(scanController);<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    }<a name="line.502"></a>
-<span class="sourceLineNo">503</span>    ScanControllerState state = scanController.destroy();<a name="line.503"></a>
-<span class="sourceLineNo">504</span>    if (state == ScanControllerState.TERMINATED) {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>      if (resp.getMoreResultsInRegion()) {<a name="line.505"></a>
-<span class="sourceLineNo">506</span>        // we have more results in region but user request to stop the scan, so we need to close the<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        // scanner explicitly.<a name="line.507"></a>
-<span class="sourceLineNo">508</span>        closeScanner();<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      completeNoMoreResults();<a name="line.510"></a>
-<span class="sourceLineNo">511</span>      return;<a name="line.511"></a>
-<span class="sourceLineNo">512</span>    }<a name="line.512"></a>
-<span class="sourceLineNo">513</span>    int numberOfCompleteRows = resultCache.numberOfCompleteRows() - numberOfCompleteRowsBefore;<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    if (state == ScanControllerState.SUSPENDED) {<a name="line.514"></a>
-<span class="sourceLineNo">515</span>      if (scanController.resumer.prepare(resp, numberOfCompleteRows)) {<a name="line.515"></a>
-<span class="sourceLineNo">516</span>        return;<a name="line.516"></a>
-<span class="sourceLineNo">517</span>      }<a name="line.517"></a>
-<span class="sourceLineNo">518</span>    }<a name="line.518"></a>
-<span class="sourceLineNo">519</span>    completeOrNext(resp, numberOfCompleteRows);<a name="line.519"></a>
-<span class="sourceLineNo">520</span>  }<a name="line.520"></a>
-<span class="sourceLineNo">521</span><a name="line.521"></a>
-<span class="sourceLineNo">522</span>  private void call() {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>    // As we have a call sequence for scan, it is useless to have a different rpc timeout which is<a name="line.523"></a>
-<span class="sourceLineNo">524</span>    // less than the scan timeout. If the server does not respond in time(usually this will not<a name="line.524"></a>
-<span class="sourceLineNo">525</span>    // happen as we have heartbeat now), we will get an OutOfOrderScannerNextException when<a name="line.525"></a>
-<span class="sourceLineNo">526</span>    // resending the next request and the only way to fix this is to close the scanner and open a<a name="line.526"></a>
-<span class="sourceLineNo">527</span>    // new one.<a name="line.527"></a>
-<span class="sourceLineNo">528</span>    long callTimeoutNs;<a name="line.528"></a>
-<span class="sourceLineNo">529</span>    if (scanTimeoutNs &gt; 0) {<a name="line.529"></a>
-<span class="sourceLineNo">530</span>      long remainingNs = scanTimeoutNs - (System.nanoTime() - nextCallStartNs);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>      if (remainingNs &lt;= 0) {<a name="line.531"></a>
-<span class="sourceLineNo">532</span>        completeExceptionally(true);<a name="line.532"></a>
-<span class="sourceLineNo">533</span>        return;<a name="line.533"></a>
-<span class="sourceLineNo">534</span>      }<a name="line.534"></a>
-<span class="sourceLineNo">535</span>      callTimeoutNs = remainingNs;<a name="line.535"></a>
-<span class="sourceLineNo">536</span>    } else {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>      callTimeoutNs = 0L;<a name="line.537"></a>
-<span class="sourceLineNo">538</span>    }<a name="line.538"></a>
-<span class="sourceLineNo">539</span>    incRPCCallsMetrics(scanMetrics, regionServerRemote);<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    if (tries &gt; 1) {<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      incRPCRetriesMetrics(scanMetrics, regionServerRemote);<a name="line.541"></a>
-<span class="sourceLineNo">542</span>    }<a name="line.542"></a>
-<span class="sourceLineNo">543</span>    resetController(controller, callTimeoutNs);<a name="line.543"></a>
-<span class="sourceLineNo">544</span>    ScanRequest req = RequestConverter.buildScanRequest(scannerId, scan.getCaching(), false,<a name="line.544"></a>
-<span class="sourceLineNo">545</span>      nextCallSeq, false, false, scan.getLimit());<a name="line.545"></a>
-<span class="sourceLineNo">546</span>    stub.scan(controller, req, resp -&gt; onComplete(controller, resp));<a name="line.546"></a>
-<span class="sourceLineNo">547</span>  }<a name="line.547"></a>
-<span class="sourceLineNo">548</span><a name="line.548"></a>
-<span class="sourceLineNo">549</span>  private void next() {<a name="line.549"></a>
-<span class="sourceLineNo">550</span>    nextCallSeq++;<a name="line.550"></a>
-<span class="sourceLineNo">551</span>    tries = 1;<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    exceptions.clear();<a name="line.552"></a>
-<span class="sourceLineNo">553</span>    nextCallStartNs = System.nanoTime();<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    call();<a name="line.554"></a>
-<span class="sourceLineNo">555</span>  }<a name="line.555"></a>
-<span class="sourceLineNo">556</span><a name="line.556"></a>
-<span class="sourceLineNo">557</span>  private void renewLease() {<a name="line.557"></a>
+<span class="sourceLineNo">479</span>    Result[] rawResults;<a name="line.479"></a>
+<span class="sourceLineNo">480</span>    Result[] results;<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    int numberOfCompleteRowsBefore = resultCache.numberOfCompleteRows();<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    try {<a name="line.482"></a>
+<span class="sourceLineNo">483</span>      rawResults = ResponseConverter.getResults(controller.cellScanner(), resp);<a name="line.483"></a>
+<span class="sourceLineNo">484</span>      updateResultsMetrics(scanMetrics, rawResults, isHeartbeatMessage);<a name="line.484"></a>
+<span class="sourceLineNo">485</span>      results = resultCache.addAndGet(<a name="line.485"></a>
+<span class="sourceLineNo">486</span>        Optional.ofNullable(rawResults).orElse(ScanResultCache.EMPTY_RESULT_ARRAY),<a name="line.486"></a>
+<span class="sourceLineNo">487</span>        isHeartbeatMessage);<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    } catch (IOException e) {<a name="line.488"></a>
+<span class="sourceLineNo">489</span>      // We can not retry here. The server has responded normally and the call sequence has been<a name="line.489"></a>
+<span class="sourceLineNo">490</span>      // increased so a new scan with the same call sequence will cause an<a name="line.490"></a>
+<span class="sourceLineNo">491</span>      // OutOfOrderScannerNextException. Let the upper layer open a new scanner.<a name="line.491"></a>
+<span class="sourceLineNo">492</span>      LOG.warn("decode scan response failed", e);<a name="line.492"></a>
+<span class="sourceLineNo">493</span>      completeWhenError(true);<a name="line.493"></a>
+<span class="sourceLineNo">494</span>      return;<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    }<a name="line.495"></a>
+<span class="sourceLineNo">496</span><a name="line.496"></a>
+<span class="sourceLineNo">497</span>    ScanControllerImpl scanController;<a name="line.497"></a>
+<span class="sourceLineNo">498</span>    if (results.length &gt; 0) {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>      scanController = new ScanControllerImpl(<a name="line.499"></a>
+<span class="sourceLineNo">500</span>          resp.hasCursor() ? Optional.of(ProtobufUtil.toCursor(resp.getCursor()))<a name="line.500"></a>
+<span class="sourceLineNo">501</span>              : Optional.empty());<a name="line.501"></a>
+<span class="sourceLineNo">502</span>      updateNextStartRowWhenError(results[results.length - 1]);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>      consumer.onNext(results, scanController);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>    } else {<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      Optional&lt;Cursor&gt; cursor = Optional.empty();<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      if (resp.hasCursor()) {<a name="line.506"></a>
+<span class="sourceLineNo">507</span>        cursor = Optional.of(ProtobufUtil.toCursor(resp.getCursor()));<a name="line.507"></a>
+<span class="sourceLineNo">508</span>      } else if (scan.isNeedCursorResult() &amp;&amp; rawResults.length &gt; 0) {<a name="line.508"></a>
+<span class="sourceLineNo">509</span>        // It is size limit exceed and we need to return the last Result's row.<a name="line.509"></a>
+<span class="sourceLineNo">510</span>        // When user setBatch and the scanner is reopened, the server may return Results that<a name="line.510"></a>
+<span class="sourceLineNo">511</span>        // user has seen and the last Result can not be seen because the number is not enough.<a name="line.511"></a>
+<span class="sourceLineNo">512</span>        // So the row keys of results may not be same, we must use the last one.<a name="line.512"></a>
+<span class="sourceLineNo">513</span>        cursor = Optional.of(new Cursor(rawResults[rawResults.length - 1].getRow()));<a name="line.513"></a>
+<span class="sourceLineNo">514</span>      }<a name="line.514"></a>
+<span class="sourceLineNo">515</span>      scanController = new ScanControllerImpl(cursor);<a name="line.515"></a>
+<span class="sourceLineNo">516</span>      if (isHeartbeatMessage || cursor.isPresent()) {<a name="line.516"></a>
+<span class="sourceLineNo">517</span>        // only call onHeartbeat if server tells us explicitly this is a heartbeat message, or we<a name="line.517"></a>
+<span class="sourceLineNo">518</span>        // want to pass a cursor to upper layer.<a name="line.518"></a>
+<span class="sourceLineNo">519</span>        consumer.onHeartbeat(scanController);<a name="line.519"></a>
+<span class="sourceLineNo">520</span>      }<a name="line.520"></a>
+<span class="sourceLineNo">521</span>    }<a name="line.521"></a>
+<span class="sourceLineNo">522</span>    ScanControllerState state = scanController.destroy();<a name="line.522"></a>
+<span class="sourceLineNo">523</span>    if (state == ScanControllerState.TERMINATED) {<a name="line.523"></a>
+<span class="sourceLineNo">524</span>      if (resp.getMoreResultsInRegion()) {<a name="line.524"></a>
+<span class="sourceLineNo">525</span>        // we have more results in region but user request to stop the scan, so we need to close the<a name="line.525"></a>
+<span class="sourceLineNo">526</span>        // scanner explicitly.<a name="line.526"></a>
+<span class="sourceLineNo">527</span>        closeScanner();<a name="line.527"></a>
+<span class="sourceLineNo">528</span>      }<a name="line.528"></a>
+<span class="sourceLineNo">529</span>      completeNoMoreResults();<a name="line.529"></a>
+<span class="sourceLineNo">530</span>      return;<a name="line.530"></a>
+<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
+<span class="sourceLineNo">532</span>    int numberOfCompleteRows = resultCache.numberOfCompleteRows() - numberOfCompleteRowsBefore;<a name="line.532"></a>
+<span class="sourceLineNo">533</span>    if (state == ScanControllerState.SUSPENDED) {<a name="line.533"></a>
+<span class="sourceLineNo">534</span>      if (scanController.resumer.prepare(resp, numberOfCompleteRows)) {<a name="line.534"></a>
+<span class="sourceLineNo">535</span>        return;<a name="line.535"></a>
+<span class="sourceLineNo">536</span>      }<a name="line.536"></a>
+<span class="sourceLineNo">537</span>    }<a name="line.537"></a>
+<span class="sourceLineNo">538</span>    completeOrNext(resp, numberOfCompleteRows);<a name="line.538"></a>
+<span class="sourceLineNo">539</span>  }<a name="line.539"></a>
+<span class="sourceLineNo">540</span><a name="line.540"></a>
+<span class="sourceLineNo">541</span>  private void call() {<a name="line.541"></a>
+<span class="sourceLineNo">542</span>    // As we have a call sequence for scan, it is useless to have a different rpc timeout which is<a name="line.542"></a>
+<span class="sourceLineNo">543</span>    // less than the scan timeout. If the server does not respond in time(usually this will not<a name="line.543"></a>
+<span class="sourceLineNo">544</span>    // happen as we have heartbeat now), we will get an OutOfOrderScannerNextException when<a name="line.544"></a>
+<span class="sourceLineNo">545</span>    // resending the next request and the only way to fix this is to close the scanner and open a<a name="line.545"></a>
+<span class="sourceLineNo">546</span>    // new one.<a name="line.546"></a>
+<span class="sourceLineNo">547</span>    long callTimeoutNs;<a name="line.547"></a>
+<span class="sourceLineNo">548</span>    if (scanTimeoutNs &gt; 0) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>      long remainingNs = scanTimeoutNs - (System.nanoTime() - nextCallStartNs);<a name="line.549"></a>
+<span class="sourceLineNo">550</span>      if (remainingNs &lt;= 0) {<a name="line.550"></a>
+<span class="sourceLineNo">551</span>        completeExceptionally(true);<a name="line.551"></a>
+<span class="sourceLineNo">552</span>        return;<a name="line.552"></a>
+<span class="sourceLineNo">553</span>      }<a name="line.553"></a>
+<span class="sourceLineNo">554</span>      callTimeoutNs = remainingNs;<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    } else {<a name="line.555"></a>
+<span class="sourceLineNo">556</span>      callTimeoutNs = 0L;<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    }<a name="line.557"></a>
 <span class="sourceLineNo">558</span>    incRPCCallsMetrics(scanMetrics, regionServerRemote);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    nextCallSeq++;<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    resetController(controller, rpcTimeoutNs);<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    ScanRequest req =<a name="line.561"></a>
-<span class="sourceLineNo">562</span>        RequestConverter.buildScanRequest(scannerId, 0, false, nextCallSeq, false, true, -1);<a name="line.562"></a>
-<span class="sourceLineNo">563</span>    stub.scan(controller, req, resp -&gt; {<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    });<a name="line.564"></a>
-<span class="sourceLineNo">565</span>  }<a name="line.565"></a>
-<span class="sourceLineNo">566</span><a name="line.566"></a>
-<span class="sourceLineNo">567</span>  /**<a name="line.567"></a>
-<span class="sourceLineNo">568</span>   * Now we will also fetch some cells along with the scanner id when opening a scanner, so we also<a name="line.568"></a>
-<span class="sourceLineNo">569</span>   * need to process the ScanResponse for the open scanner request. The HBaseRpcController for the<a name="line.569"></a>
-<span class="sourceLineNo">570</span>   * open scanner request is also needed because we may have some data in the CellScanner which is<a name="line.570"></a>
-<span class="sourceLineNo">571</span>   * contained in the controller.<a name="line.571"></a>
-<span class="sourceLineNo">572</span>   * @return {@code true} if we should continue, otherwise {@code false}.<a name="line.572"></a>
-<span class="sourceLineNo">573</span>   */<a name="line.573"></a>
-<span class="sourceLineNo">574</span>  public CompletableFuture&lt;Boolean&gt; start(HBaseRpcController controller,<a name="line.574"></a>
-<span class="sourceLineNo">575</span>      ScanResponse respWhenOpen) {<a name="line.575"></a>
-<span class="sourceLineNo">576</span>    onComplete(controller, respWhenOpen);<a name="line.576"></a>
-<span class="sourceLineNo">577</span>    return future;<a name="line.577"></a>
-<span class="sourceLineNo">578</span>  }<a name="line.578"></a>
-<span class="sourceLineNo">579</span>}<a name="line.579"></a>
+<span class="sourceLineNo">559</span>    if (tries &gt; 1) {<a name="line.559"></a>
+<span class="sourceLineNo">560</span>      incRPCRetriesMetrics(scanMetrics, regionServerRemote);<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    }<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    resetController(controller, callTimeoutNs);<a name="line.562"></a>
+<span class="sourceLineNo">563</span>    ScanRequest req = RequestConverter.buildScanRequest(scannerId, scan.getCaching(), false,<a name="line.563"></a>
+<span class="sourceLineNo">564</span>      nextCallSeq, false, false, scan.getLimit());<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    stub.scan(controller, req, resp -&gt; onComplete(controller, resp));<a name="line.565"></a>
+<span class="sourceLineNo">566</span>  }<a name="line.566"></a>
+<span class="sourceLineNo">567</span><a name="line.567"></a>
+<span class="sourceLineNo">568</span>  private void next() {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>    nextCallSeq++;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>    tries = 1;<a name="line.570"></a>
+<span class="sourceLineNo">571</span>    exceptions.clear();<a name="line.571"></a>
+<span class="sourceLineNo">572</span>    nextCallStartNs = System.nanoTime();<a name="line.572"></a>
+<span class="sourceLineNo">573</span>    call();<a name="line.573"></a>
+<span class="sourceLineNo">574</span>  }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>  private void renewLease() {<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    incRPCCallsMetrics(scanMetrics, regionServerRemote);<a name="line.577"></a>
+<span class="sourceLineNo">578</span>    nextCallSeq++;<a name="line.578"></a>
+<span class="sourceLineNo">579</span>    resetController(controller, rpcTimeoutNs);<a name="line.579"></a>
+<span class="sourceLineNo">580</span>    ScanRequest req =<a name="line.580"></a>
+<span class="sourceLineNo">581</span>        RequestConverter.buildScanRequest(scannerId, 0, false, nextCallSeq, false, true, -1);<a name="line.581"></a>
+<span class="sourceLineNo">582</span>    stub.scan(controller, req, resp -&gt; {<a name="line.582"></a>
+<span class="sourceLineNo">583</span>    });<a name="line.583"></a>
+<span class="sourceLineNo">584</span>  }<a name="line.584"></a>
+<span class="sourceLineNo">585</span><a name="line.585"></a>
+<span class="sourceLineNo">586</span>  /**<a name="line.586"></a>
+<span class="sourceLineNo">587</span>   * Now we will also fetch some cells along with the scanner id when opening a scanner, so we also<a name="line.587"></a>
+<span class="sourceLineNo">588</span>   * need to process the ScanResponse for the open scanner request. The HBaseRpcController for the<a name="line.588"></a>
+<span class="sourceLineNo">589</span>   * open scanner request is also needed because we may have some data in the CellScanner which is<a name="line.589"></a>
+<span class="sourceLineNo">590</span>   * contained in the controller.<a name="line.590"></a>
+<span class="sourceLineNo">591</span>   * @return {@code true} if we should continue, otherwise {@code false}.<a name="line.591"></a>
+<span class="sourceLineNo">592</span>   */<a name="line.592"></a>
+<span class="sourceLineNo">593</span>  public CompletableFuture&lt;Boolean&gt; start(HBaseRpcController controller,<a name="line.593"></a>
+<span class="sourceLineNo">594</span>      ScanResponse respWhenOpen) {<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    onComplete(controller, respWhenOpen);<a name="line.595"></a>
+<span class="sourceLineNo">596</span>    return future;<a name="line.596"></a>
+<span class="sourceLineNo">597</span>  }<a name="line.597"></a>
+<span class="sourceLineNo">598</span>}<a name="line.598"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/1ada5f22/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncTableResultScanner.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncTableResultScanner.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncTableResultScanner.html
index 9d39e8d..6918fd0 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncTableResultScanner.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncTableResultScanner.html
@@ -27,166 +27,174 @@
 <span class="sourceLineNo">019</span><a name="line.19"></a>
 <span class="sourceLineNo">020</span>import static org.apache.hadoop.hbase.client.ConnectionUtils.calcEstimatedSize;<a name="line.20"></a>
 <span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.shaded.com.google.common.base.Throwables;<a name="line.23"></a>
-<span class="sourceLineNo">024</span><a name="line.24"></a>
-<span class="sourceLineNo">025</span>import java.io.IOException;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import java.io.InterruptedIOException;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import java.util.ArrayDeque;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import java.util.Queue;<a name="line.28"></a>
-<span class="sourceLineNo">029</span><a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.commons.logging.Log;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.commons.logging.LogFactory;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.client.metrics.ScanMetrics;<a name="line.33"></a>
-<span class="sourceLineNo">034</span><a name="line.34"></a>
-<span class="sourceLineNo">035</span>/**<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * The {@link ResultScanner} implementation for {@link AsyncTable}. It will fetch data automatically<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * in background and cache it in memory. Typically the {@link #maxCacheSize} will be<a name="line.37"></a>
-<span class="sourceLineNo">038</span> * {@code 2 * scan.getMaxResultSize()}.<a name="line.38"></a>
-<span class="sourceLineNo">039</span> */<a name="line.39"></a>
-<span class="sourceLineNo">040</span>@InterfaceAudience.Private<a name="line.40"></a>
-<span class="sourceLineNo">041</span>class AsyncTableResultScanner implements ResultScanner, RawScanResultConsumer {<a name="line.41"></a>
-<span class="sourceLineNo">042</span><a name="line.42"></a>
-<span class="sourceLineNo">043</span>  private static final Log LOG = LogFactory.getLog(AsyncTableResultScanner.class);<a name="line.43"></a>
-<span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span>  private final RawAsyncTable rawTable;<a name="line.45"></a>
-<span class="sourceLineNo">046</span><a name="line.46"></a>
-<span class="sourceLineNo">047</span>  private final long maxCacheSize;<a name="line.47"></a>
-<span class="sourceLineNo">048</span><a name="line.48"></a>
-<span class="sourceLineNo">049</span>  private final Queue&lt;Result&gt; queue = new ArrayDeque&lt;&gt;();<a name="line.49"></a>
-<span class="sourceLineNo">050</span><a name="line.50"></a>
-<span class="sourceLineNo">051</span>  private ScanMetrics scanMetrics;<a name="line.51"></a>
-<span class="sourceLineNo">052</span><a name="line.52"></a>
-<span class="sourceLineNo">053</span>  private long cacheSize;<a name="line.53"></a>
-<span class="sourceLineNo">054</span><a name="line.54"></a>
-<span class="sourceLineNo">055</span>  private boolean closed = false;<a name="line.55"></a>
-<span class="sourceLineNo">056</span><a name="line.56"></a>
-<span class="sourceLineNo">057</span>  private Throwable error;<a name="line.57"></a>
-<span class="sourceLineNo">058</span><a name="line.58"></a>
-<span class="sourceLineNo">059</span>  private ScanResumer resumer;<a name="line.59"></a>
-<span class="sourceLineNo">060</span><a name="line.60"></a>
-<span class="sourceLineNo">061</span>  public AsyncTableResultScanner(RawAsyncTable table, Scan scan, long maxCacheSize) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>    this.rawTable = table;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    this.maxCacheSize = maxCacheSize;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    table.scan(scan, this);<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  }<a name="line.65"></a>
-<span class="sourceLineNo">066</span><a name="line.66"></a>
-<span class="sourceLineNo">067</span>  private void addToCache(Result result) {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    queue.add(result);<a name="line.68"></a>
-<span class="sourceLineNo">069</span>    cacheSize += calcEstimatedSize(result);<a name="line.69"></a>
-<span class="sourceLineNo">070</span>  }<a name="line.70"></a>
-<span class="sourceLineNo">071</span><a name="line.71"></a>
-<span class="sourceLineNo">072</span>  private void stopPrefetch(ScanController controller) {<a name="line.72"></a>
-<span class="sourceLineNo">073</span>    if (LOG.isDebugEnabled()) {<a name="line.73"></a>
-<span class="sourceLineNo">074</span>      LOG.debug(String.format("0x%x", System.identityHashCode(this)) +<a name="line.74"></a>
-<span class="sourceLineNo">075</span>          " stop prefetching when scanning " + rawTable.getName() + " as the cache size " +<a name="line.75"></a>
-<span class="sourceLineNo">076</span>          cacheSize + " is greater than the maxCacheSize " + maxCacheSize);<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    }<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    resumer = controller.suspend();<a name="line.78"></a>
-<span class="sourceLineNo">079</span>  }<a name="line.79"></a>
-<span class="sourceLineNo">080</span><a name="line.80"></a>
-<span class="sourceLineNo">081</span>  @Override<a name="line.81"></a>
-<span class="sourceLineNo">082</span>  public synchronized void onNext(Result[] results, ScanController controller) {<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    assert results.length &gt; 0;<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    if (closed) {<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      controller.terminate();<a name="line.85"></a>
-<span class="sourceLineNo">086</span>      return;<a name="line.86"></a>
-<span class="sourceLineNo">087</span>    }<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    for (Result result : results) {<a name="line.88"></a>
-<span class="sourceLineNo">089</span>      addToCache(result);<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    }<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    notifyAll();<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    if (cacheSize &gt;= maxCacheSize) {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>      stopPrefetch(controller);<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    }<a name="line.94"></a>
-<span class="sourceLineNo">095</span>  }<a name="line.95"></a>
-<span class="sourceLineNo">096</span><a name="line.96"></a>
-<span class="sourceLineNo">097</span>  @Override<a name="line.97"></a>
-<span class="sourceLineNo">098</span>  public synchronized void onHeartbeat(ScanController controller) {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    if (closed) {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>      controller.terminate();<a name="line.100"></a>
-<span class="sourceLineNo">101</span>    }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>  }<a name="line.102"></a>
-<span class="sourceLineNo">103</span><a name="line.103"></a>
-<span class="sourceLineNo">104</span>  @Override<a name="line.104"></a>
-<span class="sourceLineNo">105</span>  public synchronized void onError(Throwable error) {<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    this.error = error;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    notifyAll();<a name="line.107"></a>
+<span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.InterruptedIOException;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.ArrayDeque;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.Queue;<a name="line.25"></a>
+<span class="sourceLineNo">026</span><a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.commons.logging.Log;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.commons.logging.LogFactory;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.client.metrics.ScanMetrics;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.shaded.com.google.common.base.Throwables;<a name="line.32"></a>
+<span class="sourceLineNo">033</span><a name="line.33"></a>
+<span class="sourceLineNo">034</span>/**<a name="line.34"></a>
+<span class="sourceLineNo">035</span> * The {@link ResultScanner} implementation for {@link AsyncTable}. It will fetch data automatically<a name="line.35"></a>
+<span class="sourceLineNo">036</span> * in background and cache it in memory. Typically the {@link #maxCacheSize} will be<a name="line.36"></a>
+<span class="sourceLineNo">037</span> * {@code 2 * scan.getMaxResultSize()}.<a name="line.37"></a>
+<span class="sourceLineNo">038</span> */<a name="line.38"></a>
+<span class="sourceLineNo">039</span>@InterfaceAudience.Private<a name="line.39"></a>
+<span class="sourceLineNo">040</span>class AsyncTableResultScanner implements ResultScanner, RawScanResultConsumer {<a name="line.40"></a>
+<span class="sourceLineNo">041</span><a name="line.41"></a>
+<span class="sourceLineNo">042</span>  private static final Log LOG = LogFactory.getLog(AsyncTableResultScanner.class);<a name="line.42"></a>
+<span class="sourceLineNo">043</span><a name="line.43"></a>
+<span class="sourceLineNo">044</span>  private final RawAsyncTable rawTable;<a name="line.44"></a>
+<span class="sourceLineNo">045</span><a name="line.45"></a>
+<span class="sourceLineNo">046</span>  private final long maxCacheSize;<a name="line.46"></a>
+<span class="sourceLineNo">047</span><a name="line.47"></a>
+<span class="sourceLineNo">048</span>  private final Scan scan;<a name="line.48"></a>
+<span class="sourceLineNo">049</span><a name="line.49"></a>
+<span class="sourceLineNo">050</span>  private final Queue&lt;Result&gt; queue = new ArrayDeque&lt;&gt;();<a name="line.50"></a>
+<span class="sourceLineNo">051</span><a name="line.51"></a>
+<span class="sourceLineNo">052</span>  private ScanMetrics scanMetrics;<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>  private long cacheSize;<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>  private boolean closed = false;<a name="line.56"></a>
+<span class="sourceLineNo">057</span><a name="line.57"></a>
+<span class="sourceLineNo">058</span>  private Throwable error;<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
+<span class="sourceLineNo">060</span>  private ScanResumer resumer;<a name="line.60"></a>
+<span class="sourceLineNo">061</span><a name="line.61"></a>
+<span class="sourceLineNo">062</span>  public AsyncTableResultScanner(RawAsyncTable table, Scan scan, long maxCacheSize) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    this.rawTable = table;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    this.maxCacheSize = maxCacheSize;<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    this.scan = scan;<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    table.scan(scan, this);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  }<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>  private void addToCache(Result result) {<a name="line.69"></a>
+<span class="sourceLineNo">070</span>    queue.add(result);<a name="line.70"></a>
+<span class="sourceLineNo">071</span>    cacheSize += calcEstimatedSize(result);<a name="line.71"></a>
+<span class="sourceLineNo">072</span>  }<a name="line.72"></a>
+<span class="sourceLineNo">073</span><a name="line.73"></a>
+<span class="sourceLineNo">074</span>  private void stopPrefetch(ScanController controller) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    if (LOG.isDebugEnabled()) {<a name="line.75"></a>
+<span class="sourceLineNo">076</span>      LOG.debug(String.format("0x%x", System.identityHashCode(this)) +<a name="line.76"></a>
+<span class="sourceLineNo">077</span>          " stop prefetching when scanning " + rawTable.getName() + " as the cache size " +<a name="line.77"></a>
+<span class="sourceLineNo">078</span>          cacheSize + " is greater than the maxCacheSize " + maxCacheSize);<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    }<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    resumer = controller.suspend();<a name="line.80"></a>
+<span class="sourceLineNo">081</span>  }<a name="line.81"></a>
+<span class="sourceLineNo">082</span><a name="line.82"></a>
+<span class="sourceLineNo">083</span>  @Override<a name="line.83"></a>
+<span class="sourceLineNo">084</span>  public synchronized void onNext(Result[] results, ScanController controller) {<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    assert results.length &gt; 0;<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    if (closed) {<a name="line.86"></a>
+<span class="sourceLineNo">087</span>      controller.terminate();<a name="line.87"></a>
+<span class="sourceLineNo">088</span>      return;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    }<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    for (Result result : results) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>      addToCache(result);<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    }<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    notifyAll();<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    if (cacheSize &gt;= maxCacheSize) {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      stopPrefetch(controller);<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    }<a name="line.96"></a>
+<span class="sourceLineNo">097</span>  }<a name="line.97"></a>
+<span class="sourceLineNo">098</span><a name="line.98"></a>
+<span class="sourceLineNo">099</span>  @Override<a name="line.99"></a>
+<span class="sourceLineNo">100</span>  public synchronized void onHeartbeat(ScanController controller) {<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    if (closed) {<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      controller.terminate();<a name="line.102"></a>
+<span class="sourceLineNo">103</span>      return;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>    }<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    if (scan.isNeedCursorResult()) {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      controller.cursor().ifPresent(c -&gt; queue.add(Result.createCursorResult(c)));<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    }<a name="line.107"></a>
 <span class="sourceLineNo">108</span>  }<a name="line.108"></a>
 <span class="sourceLineNo">109</span><a name="line.109"></a>
 <span class="sourceLineNo">110</span>  @Override<a name="line.110"></a>
-<span class="sourceLineNo">111</span>  public synchronized void onComplete() {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>    closed = true;<a name="line.112"></a>
+<span class="sourceLineNo">111</span>  public synchronized void onError(Throwable error) {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    this.error = error;<a name="line.112"></a>
 <span class="sourceLineNo">113</span>    notifyAll();<a name="line.113"></a>
 <span class="sourceLineNo">114</span>  }<a name="line.114"></a>
 <span class="sourceLineNo">115</span><a name="line.115"></a>
 <span class="sourceLineNo">116</span>  @Override<a name="line.116"></a>
-<span class="sourceLineNo">117</span>  public void onScanMetricsCreated(ScanMetrics scanMetrics) {<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    this.scanMetrics = scanMetrics;<a name="line.118"></a>
-<span class="sourceLineNo">119</span>  }<a name="line.119"></a>
-<span class="sourceLineNo">120</span><a name="line.120"></a>
-<span class="sourceLineNo">121</span>  private void resumePrefetch() {<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    if (LOG.isDebugEnabled()) {<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      LOG.debug(String.format("0x%x", System.identityHashCode(this)) + " resume prefetching");<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    }<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    resumer.resume();<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    resumer = null;<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  }<a name="line.127"></a>
-<span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>  @Override<a name="line.129"></a>
-<span class="sourceLineNo">130</span>  public synchronized Result next() throws IOException {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    while (queue.isEmpty()) {<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      if (closed) {<a name="line.132"></a>
-<span class="sourceLineNo">133</span>        return null;<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      }<a name="line.134"></a>
-<span class="sourceLineNo">135</span>      if (error != null) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>        Throwables.propagateIfPossible(error, IOException.class);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>        throw new IOException(error);<a name="line.137"></a>
-<span class="sourceLineNo">138</span>      }<a name="line.138"></a>
-<span class="sourceLineNo">139</span>      try {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>        wait();<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      } catch (InterruptedException e) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>        throw new InterruptedIOException();<a name="line.142"></a>
-<span class="sourceLineNo">143</span>      }<a name="line.143"></a>
-<span class="sourceLineNo">144</span>    }<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    Result result = queue.poll();<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    cacheSize -= calcEstimatedSize(result);<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    if (resumer != null &amp;&amp; cacheSize &lt;= maxCacheSize / 2) {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      resumePrefetch();<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    }<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    return result;<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 synchronized void close() {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    closed = true;<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    queue.clear();<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    cacheSize = 0;<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    if (resumer != null) {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>      resumePrefetch();<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    notifyAll();<a name="line.161"></a>
-<span class="sourceLineNo">162</span>  }<a name="line.162"></a>
-<span class="sourceLineNo">163</span><a name="line.163"></a>
-<span class="sourceLineNo">164</span>  @Override<a name="line.164"></a>
-<span class="sourceLineNo">165</span>  public boolean renewLease() {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    // we will do prefetching in the background and if there is no space we will just suspend the<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    // scanner. The renew lease operation will be handled in the background.<a name="line.167"></a>
-<span class="sourceLineNo">168</span>    return false;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>  }<a name="line.169"></a>
-<span class="sourceLineNo">170</span><a name="line.170"></a>
-<span class="sourceLineNo">171</span>  // used in tests to test whether the scanner has been suspended<a name="line.171"></a>
-<span class="sourceLineNo">172</span>  @VisibleForTesting<a name="line.172"></a>
-<span class="sourceLineNo">173</span>  synchronized boolean isSuspended() {<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    return resumer != null;<a name="line.174"></a>
-<span class="sourceLineNo">175</span>  }<a name="line.175"></a>
-<span class="sourceLineNo">176</span><a name="line.176"></a>
-<span class="sourceLineNo">177</span>  @Override<a name="line.177"></a>
-<span class="sourceLineNo">178</span>  public ScanMetrics getScanMetrics() {<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    return scanMetrics;<a name="line.179"></a>
-<span class="sourceLineNo">180</span>  }<a name="line.180"></a>
-<span class="sourceLineNo">181</span>}<a name="line.181"></a>
+<span class="sourceLineNo">117</span>  public synchronized void onComplete() {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    closed = true;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    notifyAll();<a name="line.119"></a>
+<span class="sourceLineNo">120</span>  }<a name="line.120"></a>
+<span class="sourceLineNo">121</span><a name="line.121"></a>
+<span class="sourceLineNo">122</span>  @Override<a name="line.122"></a>
+<span class="sourceLineNo">123</span>  public void onScanMetricsCreated(ScanMetrics scanMetrics) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    this.scanMetrics = scanMetrics;<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>  private void resumePrefetch() {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    if (LOG.isDebugEnabled()) {<a name="line.128"></a>
+<span class="sourceLineNo">129</span>      LOG.debug(String.format("0x%x", System.identityHashCode(this)) + " resume prefetching");<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    }<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    resumer.resume();<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    resumer = null;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
+<span class="sourceLineNo">134</span><a name="line.134"></a>
+<span class="sourceLineNo">135</span>  @Override<a name="line.135"></a>
+<span class="sourceLineNo">136</span>  public synchronized Result next() throws IOException {<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    while (queue.isEmpty()) {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      if (closed) {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>        return null;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      }<a name="line.140"></a>
+<span class="sourceLineNo">141</span>      if (error != null) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>        Throwables.propagateIfPossible(error, IOException.class);<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        throw new IOException(error);<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      }<a name="line.144"></a>
+<span class="sourceLineNo">145</span>      try {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>        wait();<a name="line.146"></a>
+<span class="sourceLineNo">147</span>      } catch (InterruptedException e) {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>        throw new InterruptedIOException();<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      }<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    }<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    Result result = queue.poll();<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    if (!result.isCursor()) {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      cacheSize -= calcEstimatedSize(result);<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      if (resumer != null &amp;&amp; cacheSize &lt;= maxCacheSize / 2) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>        resumePrefetch();<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>    return result;<a name="line.158"></a>
+<span class="sourceLineNo">159</span>  }<a name="line.159"></a>
+<span class="sourceLineNo">160</span><a name="line.160"></a>
+<span class="sourceLineNo">161</span>  @Override<a name="line.161"></a>
+<span class="sourceLineNo">162</span>  public synchronized void close() {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    closed = true;<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    queue.clear();<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    cacheSize = 0;<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    if (resumer != null) {<a name="line.166"></a>
+<span class="sourceLineNo">167</span>      resumePrefetch();<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    }<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    notifyAll();<a name="line.169"></a>
+<span class="sourceLineNo">170</span>  }<a name="line.170"></a>
+<span class="sourceLineNo">171</span><a name="line.171"></a>
+<span class="sourceLineNo">172</span>  @Override<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public boolean renewLease() {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    // we will do prefetching in the background and if there is no space we will just suspend the<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    // scanner. The renew lease operation will be handled in the background.<a name="line.175"></a>
+<span class="sourceLineNo">176</span>    return false;<a name="line.176"></a>
+<span class="sourceLineNo">177</span>  }<a name="line.177"></a>
+<span class="sourceLineNo">178</span><a name="line.178"></a>
+<span class="sourceLineNo">179</span>  // used in tests to test whether the scanner has been suspended<a name="line.179"></a>
+<span class="sourceLineNo">180</span>  @VisibleForTesting<a name="line.180"></a>
+<span class="sourceLineNo">181</span>  synchronized boolean isSuspended() {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    return resumer != null;<a name="line.182"></a>
+<span class="sourceLineNo">183</span>  }<a name="line.183"></a>
+<span class="sourceLineNo">184</span><a name="line.184"></a>
+<span class="sourceLineNo">185</span>  @Override<a name="line.185"></a>
+<span class="sourceLineNo">186</span>  public ScanMetrics getScanMetrics() {<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    return scanMetrics;<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>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/1ada5f22/devapidocs/src-html/org/apache/hadoop/hbase/client/RawScanResultConsumer.ScanController.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/RawScanResultConsumer.ScanController.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/RawScanResultConsumer.ScanController.html
index 59c2836..c804d26 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/RawScanResultConsumer.ScanController.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/RawScanResultConsumer.ScanController.html
@@ -103,38 +103,45 @@
 <span class="sourceLineNo">095</span>  void onNext(Result[] results, ScanController controller);<a name="line.95"></a>
 <span class="sourceLineNo">096</span><a name="line.96"></a>
 <span class="sourceLineNo">097</span>  /**<a name="line.97"></a>
-<span class="sourceLineNo">098</span>   * Indicate that there is an heartbeat message but we have not cumulated enough cells to call<a name="line.98"></a>
-<span class="sourceLineNo">099</span>   * onNext.<a name="line.99"></a>
+<span class="sourceLineNo">098</span>   * Indicate that there is a heartbeat message but we have not cumulated enough cells to call<a name="line.98"></a>
+<span class="sourceLineNo">099</span>   * {@link #onNext(Result[], ScanController)}.<a name="line.99"></a>
 <span class="sourceLineNo">100</span>   * &lt;p&gt;<a name="line.100"></a>
-<span class="sourceLineNo">101</span>   * This method give you a chance to terminate a slow scan operation.<a name="line.101"></a>
-<span class="sourceLineNo">102</span>   * @param controller used to suspend or terminate the scan. Notice that the {@code controller}<a name="line.102"></a>
-<span class="sourceLineNo">103</span>   *          instance is only valid within the scope of onHeartbeat method. You can only call its<a name="line.103"></a>
-<span class="sourceLineNo">104</span>   *          method in onHeartbeat, do NOT store it and call it later outside onHeartbeat.<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   */<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  default void onHeartbeat(ScanController controller) {<a name="line.106"></a>
-<span class="sourceLineNo">107</span>  }<a name="line.107"></a>
-<span class="sourceLineNo">108</span><a name="line.108"></a>
-<span class="sourceLineNo">109</span>  /**<a name="line.109"></a>
-<span class="sourceLineNo">110</span>   * Indicate that we hit an unrecoverable error and the scan operation is terminated.<a name="line.110"></a>
-<span class="sourceLineNo">111</span>   * &lt;p&gt;<a name="line.111"></a>
-<span class="sourceLineNo">112</span>   * We will not call {@link #onComplete()} after calling {@link #onError(Throwable)}.<a name="line.112"></a>
-<span class="sourceLineNo">113</span>   */<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  void onError(Throwable error);<a name="line.114"></a>
+<span class="sourceLineNo">101</span>   * Note that this method will always be called when RS returns something to us but we do not have<a name="line.101"></a>
+<span class="sourceLineNo">102</span>   * enough cells to call {@link #onNext(Result[], ScanController)}. Sometimes it may not be a<a name="line.102"></a>
+<span class="sourceLineNo">103</span>   * 'heartbeat' message for RS, for example, we have a large row with many cells and size limit is<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   * exceeded before sending all the cells for this row. For RS it does send some data to us and the<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   * time limit has not been reached, but we can not return the data to client so here we call this<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   * method to tell client we have already received something.<a name="line.106"></a>
+<span class="sourceLineNo">107</span>   * &lt;p&gt;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>   * This method give you a chance to terminate a slow scan operation.<a name="line.108"></a>
+<span class="sourceLineNo">109</span>   * @param controller used to suspend or terminate the scan. Notice that the {@code controller}<a name="line.109"></a>
+<span class="sourceLineNo">110</span>   *          instance is only valid within the scope of onHeartbeat method. You can only call its<a name="line.110"></a>
+<span class="sourceLineNo">111</span>   *          method in onHeartbeat, do NOT store it and call it later outside onHeartbeat.<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   */<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  default void onHeartbeat(ScanController controller) {<a name="line.113"></a>
+<span class="sourceLineNo">114</span>  }<a name="line.114"></a>
 <span class="sourceLineNo">115</span><a name="line.115"></a>
 <span class="sourceLineNo">116</span>  /**<a name="line.116"></a>
-<span class="sourceLineNo">117</span>   * Indicate that the scan operation is completed normally.<a name="line.117"></a>
-<span class="sourceLineNo">118</span>   */<a name="line.118"></a>
-<span class="sourceLineNo">119</span>  void onComplete();<a name="line.119"></a>
-<span class="sourceLineNo">120</span><a name="line.120"></a>
-<span class="sourceLineNo">121</span>  /**<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   * If {@code scan.isScanMetricsEnabled()} returns true, then this method will be called prior to<a name="line.122"></a>
-<span class="sourceLineNo">123</span>   * all other methods in this interface to give you the {@link ScanMetrics} instance for this scan<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * operation. The {@link ScanMetrics} instance will be updated on-the-fly during the scan, you can<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   * store it somewhere to get the metrics at any time if you want.<a name="line.125"></a>
-<span class="sourceLineNo">126</span>   */<a name="line.126"></a>
-<span class="sourceLineNo">127</span>  default void onScanMetricsCreated(ScanMetrics scanMetrics) {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>  }<a name="line.128"></a>
-<span class="sourceLineNo">129</span>}<a name="line.129"></a>
+<span class="sourceLineNo">117</span>   * Indicate that we hit an unrecoverable error and the scan operation is terminated.<a name="line.117"></a>
+<span class="sourceLineNo">118</span>   * &lt;p&gt;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>   * We will not call {@link #onComplete()} after calling {@link #onError(Throwable)}.<a name="line.119"></a>
+<span class="sourceLineNo">120</span>   */<a name="line.120"></a>
+<span class="sourceLineNo">121</span>  void onError(Throwable error);<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>  /**<a name="line.123"></a>
+<span class="sourceLineNo">124</span>   * Indicate that the scan operation is completed normally.<a name="line.124"></a>
+<span class="sourceLineNo">125</span>   */<a name="line.125"></a>
+<span class="sourceLineNo">126</span>  void onComplete();<a name="line.126"></a>
+<span class="sourceLineNo">127</span><a name="line.127"></a>
+<span class="sourceLineNo">128</span>  /**<a name="line.128"></a>
+<span class="sourceLineNo">129</span>   * If {@code scan.isScanMetricsEnabled()} returns true, then this method will be called prior to<a name="line.129"></a>
+<span class="sourceLineNo">130</span>   * all other methods in this interface to give you the {@link ScanMetrics} instance for this scan<a name="line.130"></a>
+<span class="sourceLineNo">131</span>   * operation. The {@link ScanMetrics} instance will be updated on-the-fly during the scan, you can<a name="line.131"></a>
+<span class="sourceLineNo">132</span>   * store it somewhere to get the metrics at any time if you want.<a name="line.132"></a>
+<span class="sourceLineNo">133</span>   */<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  default void onScanMetricsCreated(ScanMetrics scanMetrics) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
+<span class="sourceLineNo">136</span>}<a name="line.136"></a>
 
 
 


Mime
View raw message