hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [07/51] [partial] hbase-site git commit: Published site at 22b95aebcd7fc742412ab514520008fda5e327de.
Date Fri, 11 Dec 2015 16:30:59 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/900a9477/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.AsyncRequestFutureImpl.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.AsyncRequestFutureImpl.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.AsyncRequestFutureImpl.html
index c8d868f..d0040f6 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.AsyncRequestFutureImpl.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.AsyncRequestFutureImpl.html
@@ -49,1752 +49,1792 @@
 <span class="sourceLineNo">041</span><a name="line.41"></a>
 <span class="sourceLineNo">042</span>import org.apache.commons.logging.Log;<a name="line.42"></a>
 <span class="sourceLineNo">043</span>import org.apache.commons.logging.LogFactory;<a name="line.43"></a>
-<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.44"></a>
-<span class="sourceLineNo">045</span>import org.apache.hadoop.conf.Configuration;<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.HConstants;<a name="line.47"></a>
-<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.HRegionInfo;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>import org.apache.hadoop.hbase.ServerName;<a name="line.51"></a>
-<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.TableName;<a name="line.52"></a>
-<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.client.backoff.ServerStatistics;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.client.coprocessor.Batch;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.ipc.RpcControllerFactory;<a name="line.55"></a>
-<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.56"></a>
-<span class="sourceLineNo">057</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.57"></a>
-<span class="sourceLineNo">058</span>import org.apache.htrace.Trace;<a name="line.58"></a>
-<span class="sourceLineNo">059</span><a name="line.59"></a>
-<span class="sourceLineNo">060</span>import com.google.common.annotations.VisibleForTesting;<a name="line.60"></a>
-<span class="sourceLineNo">061</span><a name="line.61"></a>
-<span class="sourceLineNo">062</span>/**<a name="line.62"></a>
-<span class="sourceLineNo">063</span> * This class  allows a continuous flow of requests. It's written to be compatible with a<a name="line.63"></a>
-<span class="sourceLineNo">064</span> * synchronous caller such as HTable.<a name="line.64"></a>
-<span class="sourceLineNo">065</span> * &lt;p&gt;<a name="line.65"></a>
-<span class="sourceLineNo">066</span> * The caller sends a buffer of operation, by calling submit. This class extract from this list<a name="line.66"></a>
-<span class="sourceLineNo">067</span> * the operations it can send, i.e. the operations that are on region that are not considered<a name="line.67"></a>
-<span class="sourceLineNo">068</span> * as busy. The process is asynchronous, i.e. it returns immediately when if has finished to<a name="line.68"></a>
-<span class="sourceLineNo">069</span> * iterate on the list. If, and only if, the maximum number of current task is reached, the call<a name="line.69"></a>
-<span class="sourceLineNo">070</span> * to submit will block. Alternatively, the caller can call submitAll, in which case all the<a name="line.70"></a>
-<span class="sourceLineNo">071</span> * operations will be sent. Each call to submit returns a future-like object that can be used<a name="line.71"></a>
-<span class="sourceLineNo">072</span> * to track operation progress.<a name="line.72"></a>
-<span class="sourceLineNo">073</span> * &lt;/p&gt;<a name="line.73"></a>
-<span class="sourceLineNo">074</span> * &lt;p&gt;<a name="line.74"></a>
-<span class="sourceLineNo">075</span> * The class manages internally the retries.<a name="line.75"></a>
-<span class="sourceLineNo">076</span> * &lt;/p&gt;<a name="line.76"></a>
-<span class="sourceLineNo">077</span> * &lt;p&gt;<a name="line.77"></a>
-<span class="sourceLineNo">078</span> * The class can be constructed in regular mode, or "global error" mode. In global error mode,<a name="line.78"></a>
-<span class="sourceLineNo">079</span> * AP tracks errors across all calls (each "future" also has global view of all errors). That<a name="line.79"></a>
-<span class="sourceLineNo">080</span> * mode is necessary for backward compat with HTable behavior, where multiple submissions are<a name="line.80"></a>
-<span class="sourceLineNo">081</span> * made and the errors can propagate using any put/flush call, from previous calls.<a name="line.81"></a>
-<span class="sourceLineNo">082</span> * In "regular" mode, the errors are tracked inside the Future object that is returned.<a name="line.82"></a>
-<span class="sourceLineNo">083</span> * The results are always tracked inside the Future object and can be retrieved when the call<a name="line.83"></a>
-<span class="sourceLineNo">084</span> * has finished. Partial results can also be retrieved if some part of multi-request failed.<a name="line.84"></a>
-<span class="sourceLineNo">085</span> * &lt;/p&gt;<a name="line.85"></a>
-<span class="sourceLineNo">086</span> * &lt;p&gt;<a name="line.86"></a>
-<span class="sourceLineNo">087</span> * This class is thread safe in regular mode; in global error code, submitting operations and<a name="line.87"></a>
-<span class="sourceLineNo">088</span> * retrieving errors from different threads may be not thread safe.<a name="line.88"></a>
-<span class="sourceLineNo">089</span> * Internally, the class is thread safe enough to manage simultaneously new submission and results<a name="line.89"></a>
-<span class="sourceLineNo">090</span> * arising from older operations.<a name="line.90"></a>
-<span class="sourceLineNo">091</span> * &lt;/p&gt;<a name="line.91"></a>
-<span class="sourceLineNo">092</span> * &lt;p&gt;<a name="line.92"></a>
-<span class="sourceLineNo">093</span> * Internally, this class works with {@link Row}, this mean it could be theoretically used for<a name="line.93"></a>
-<span class="sourceLineNo">094</span> * gets as well.<a name="line.94"></a>
-<span class="sourceLineNo">095</span> * &lt;/p&gt;<a name="line.95"></a>
-<span class="sourceLineNo">096</span> */<a name="line.96"></a>
-<span class="sourceLineNo">097</span>@InterfaceAudience.Private<a name="line.97"></a>
-<span class="sourceLineNo">098</span>class AsyncProcess {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>  private static final Log LOG = LogFactory.getLog(AsyncProcess.class);<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  protected static final AtomicLong COUNTER = new AtomicLong();<a name="line.100"></a>
-<span class="sourceLineNo">101</span><a name="line.101"></a>
-<span class="sourceLineNo">102</span>  public static final String PRIMARY_CALL_TIMEOUT_KEY = "hbase.client.primaryCallTimeout.multiget";<a name="line.102"></a>
-<span class="sourceLineNo">103</span><a name="line.103"></a>
-<span class="sourceLineNo">104</span>  /**<a name="line.104"></a>
-<span class="sourceLineNo">105</span>   * Configure the number of failures after which the client will start logging. A few failures<a name="line.105"></a>
-<span class="sourceLineNo">106</span>   * is fine: region moved, then is not opened, then is overloaded. We try to have an acceptable<a name="line.106"></a>
-<span class="sourceLineNo">107</span>   * heuristic for the number of errors we don't log. 9 was chosen because we wait for 1s at<a name="line.107"></a>
-<span class="sourceLineNo">108</span>   * this stage.<a name="line.108"></a>
-<span class="sourceLineNo">109</span>   */<a name="line.109"></a>
-<span class="sourceLineNo">110</span>  public static final String START_LOG_ERRORS_AFTER_COUNT_KEY =<a name="line.110"></a>
-<span class="sourceLineNo">111</span>      "hbase.client.start.log.errors.counter";<a name="line.111"></a>
-<span class="sourceLineNo">112</span>  public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT = 9;<a name="line.112"></a>
-<span class="sourceLineNo">113</span><a name="line.113"></a>
-<span class="sourceLineNo">114</span>  /**<a name="line.114"></a>
-<span class="sourceLineNo">115</span>   * The context used to wait for results from one submit call.<a name="line.115"></a>
-<span class="sourceLineNo">116</span>   * 1) If AsyncProcess is set to track errors globally, and not per call (for HTable puts),<a name="line.116"></a>
-<span class="sourceLineNo">117</span>   *    then errors and failed operations in this object will reflect global errors.<a name="line.117"></a>
-<span class="sourceLineNo">118</span>   * 2) If submit call is made with needResults false, results will not be saved.<a name="line.118"></a>
-<span class="sourceLineNo">119</span>   *  */<a name="line.119"></a>
-<span class="sourceLineNo">120</span>  public static interface AsyncRequestFuture {<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    public boolean hasError();<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    public RetriesExhaustedWithDetailsException getErrors();<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    public List&lt;? extends Row&gt; getFailedOperations();<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    public Object[] getResults() throws InterruptedIOException;<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    /** Wait until all tasks are executed, successfully or not. */<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    public void waitUntilDone() throws InterruptedIOException;<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>  /** Return value from a submit that didn't contain any requests. */<a name="line.129"></a>
-<span class="sourceLineNo">130</span>  private static final AsyncRequestFuture NO_REQS_RESULT = new AsyncRequestFuture() {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    final Object[] result = new Object[0];<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    @Override<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    public boolean hasError() { return false; }<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    @Override<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    public RetriesExhaustedWithDetailsException getErrors() { return null; }<a name="line.135"></a>
+<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.RetryImmediatelyException;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import org.apache.hadoop.conf.Configuration;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.DoNotRetryIOException;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>import org.apache.hadoop.hbase.HConstants;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>import org.apache.hadoop.hbase.HRegionInfo;<a name="line.49"></a>
+<span class="sourceLineNo">050</span>import org.apache.hadoop.hbase.HRegionLocation;<a name="line.50"></a>
+<span class="sourceLineNo">051</span>import org.apache.hadoop.hbase.RegionLocations;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>import org.apache.hadoop.hbase.ServerName;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>import org.apache.hadoop.hbase.TableName;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>import org.apache.hadoop.hbase.client.backoff.ServerStatistics;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>import org.apache.hadoop.hbase.client.coprocessor.Batch;<a name="line.55"></a>
+<span class="sourceLineNo">056</span>import org.apache.hadoop.hbase.ipc.RpcControllerFactory;<a name="line.56"></a>
+<span class="sourceLineNo">057</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.58"></a>
+<span class="sourceLineNo">059</span>import org.apache.htrace.Trace;<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>import com.google.common.annotations.VisibleForTesting;<a name="line.61"></a>
+<span class="sourceLineNo">062</span><a name="line.62"></a>
+<span class="sourceLineNo">063</span>/**<a name="line.63"></a>
+<span class="sourceLineNo">064</span> * This class  allows a continuous flow of requests. It's written to be compatible with a<a name="line.64"></a>
+<span class="sourceLineNo">065</span> * synchronous caller such as HTable.<a name="line.65"></a>
+<span class="sourceLineNo">066</span> * &lt;p&gt;<a name="line.66"></a>
+<span class="sourceLineNo">067</span> * The caller sends a buffer of operation, by calling submit. This class extract from this list<a name="line.67"></a>
+<span class="sourceLineNo">068</span> * the operations it can send, i.e. the operations that are on region that are not considered<a name="line.68"></a>
+<span class="sourceLineNo">069</span> * as busy. The process is asynchronous, i.e. it returns immediately when if has finished to<a name="line.69"></a>
+<span class="sourceLineNo">070</span> * iterate on the list. If, and only if, the maximum number of current task is reached, the call<a name="line.70"></a>
+<span class="sourceLineNo">071</span> * to submit will block. Alternatively, the caller can call submitAll, in which case all the<a name="line.71"></a>
+<span class="sourceLineNo">072</span> * operations will be sent. Each call to submit returns a future-like object that can be used<a name="line.72"></a>
+<span class="sourceLineNo">073</span> * to track operation progress.<a name="line.73"></a>
+<span class="sourceLineNo">074</span> * &lt;/p&gt;<a name="line.74"></a>
+<span class="sourceLineNo">075</span> * &lt;p&gt;<a name="line.75"></a>
+<span class="sourceLineNo">076</span> * The class manages internally the retries.<a name="line.76"></a>
+<span class="sourceLineNo">077</span> * &lt;/p&gt;<a name="line.77"></a>
+<span class="sourceLineNo">078</span> * &lt;p&gt;<a name="line.78"></a>
+<span class="sourceLineNo">079</span> * The class can be constructed in regular mode, or "global error" mode. In global error mode,<a name="line.79"></a>
+<span class="sourceLineNo">080</span> * AP tracks errors across all calls (each "future" also has global view of all errors). That<a name="line.80"></a>
+<span class="sourceLineNo">081</span> * mode is necessary for backward compat with HTable behavior, where multiple submissions are<a name="line.81"></a>
+<span class="sourceLineNo">082</span> * made and the errors can propagate using any put/flush call, from previous calls.<a name="line.82"></a>
+<span class="sourceLineNo">083</span> * In "regular" mode, the errors are tracked inside the Future object that is returned.<a name="line.83"></a>
+<span class="sourceLineNo">084</span> * The results are always tracked inside the Future object and can be retrieved when the call<a name="line.84"></a>
+<span class="sourceLineNo">085</span> * has finished. Partial results can also be retrieved if some part of multi-request failed.<a name="line.85"></a>
+<span class="sourceLineNo">086</span> * &lt;/p&gt;<a name="line.86"></a>
+<span class="sourceLineNo">087</span> * &lt;p&gt;<a name="line.87"></a>
+<span class="sourceLineNo">088</span> * This class is thread safe in regular mode; in global error code, submitting operations and<a name="line.88"></a>
+<span class="sourceLineNo">089</span> * retrieving errors from different threads may be not thread safe.<a name="line.89"></a>
+<span class="sourceLineNo">090</span> * Internally, the class is thread safe enough to manage simultaneously new submission and results<a name="line.90"></a>
+<span class="sourceLineNo">091</span> * arising from older operations.<a name="line.91"></a>
+<span class="sourceLineNo">092</span> * &lt;/p&gt;<a name="line.92"></a>
+<span class="sourceLineNo">093</span> * &lt;p&gt;<a name="line.93"></a>
+<span class="sourceLineNo">094</span> * Internally, this class works with {@link Row}, this mean it could be theoretically used for<a name="line.94"></a>
+<span class="sourceLineNo">095</span> * gets as well.<a name="line.95"></a>
+<span class="sourceLineNo">096</span> * &lt;/p&gt;<a name="line.96"></a>
+<span class="sourceLineNo">097</span> */<a name="line.97"></a>
+<span class="sourceLineNo">098</span>@InterfaceAudience.Private<a name="line.98"></a>
+<span class="sourceLineNo">099</span>class AsyncProcess {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>  private static final Log LOG = LogFactory.getLog(AsyncProcess.class);<a name="line.100"></a>
+<span class="sourceLineNo">101</span>  protected static final AtomicLong COUNTER = new AtomicLong();<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>  public static final String PRIMARY_CALL_TIMEOUT_KEY = "hbase.client.primaryCallTimeout.multiget";<a name="line.103"></a>
+<span class="sourceLineNo">104</span><a name="line.104"></a>
+<span class="sourceLineNo">105</span>  /**<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   * Configure the number of failures after which the client will start logging. A few failures<a name="line.106"></a>
+<span class="sourceLineNo">107</span>   * is fine: region moved, then is not opened, then is overloaded. We try to have an acceptable<a name="line.107"></a>
+<span class="sourceLineNo">108</span>   * heuristic for the number of errors we don't log. 9 was chosen because we wait for 1s at<a name="line.108"></a>
+<span class="sourceLineNo">109</span>   * this stage.<a name="line.109"></a>
+<span class="sourceLineNo">110</span>   */<a name="line.110"></a>
+<span class="sourceLineNo">111</span>  public static final String START_LOG_ERRORS_AFTER_COUNT_KEY =<a name="line.111"></a>
+<span class="sourceLineNo">112</span>      "hbase.client.start.log.errors.counter";<a name="line.112"></a>
+<span class="sourceLineNo">113</span>  public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT = 9;<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>   * The context used to wait for results from one submit call.<a name="line.116"></a>
+<span class="sourceLineNo">117</span>   * 1) If AsyncProcess is set to track errors globally, and not per call (for HTable puts),<a name="line.117"></a>
+<span class="sourceLineNo">118</span>   *    then errors and failed operations in this object will reflect global errors.<a name="line.118"></a>
+<span class="sourceLineNo">119</span>   * 2) If submit call is made with needResults false, results will not be saved.<a name="line.119"></a>
+<span class="sourceLineNo">120</span>   *  */<a name="line.120"></a>
+<span class="sourceLineNo">121</span>  public static interface AsyncRequestFuture {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    public boolean hasError();<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    public RetriesExhaustedWithDetailsException getErrors();<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    public List&lt;? extends Row&gt; getFailedOperations();<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    public Object[] getResults() throws InterruptedIOException;<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    /** Wait until all tasks are executed, successfully or not. */<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    public void waitUntilDone() throws InterruptedIOException;<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">130</span>  /**<a name="line.130"></a>
+<span class="sourceLineNo">131</span>   * Return value from a submit that didn't contain any requests.<a name="line.131"></a>
+<span class="sourceLineNo">132</span>   */<a name="line.132"></a>
+<span class="sourceLineNo">133</span>  private static final AsyncRequestFuture NO_REQS_RESULT = new AsyncRequestFuture() {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>    final Object[] result = new Object[0];<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
 <span class="sourceLineNo">136</span>    @Override<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    public List&lt;? extends Row&gt; getFailedOperations() { return null; }<a name="line.137"></a>
-<span class="sourceLineNo">138</span>    @Override<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    public Object[] getResults() { return result; }<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    @Override<a name="line.140"></a>
-<span class="sourceLineNo">141</span>    public void waitUntilDone() throws InterruptedIOException {}<a name="line.141"></a>
-<span class="sourceLineNo">142</span>  };<a name="line.142"></a>
-<span class="sourceLineNo">143</span><a name="line.143"></a>
-<span class="sourceLineNo">144</span>  /** Sync point for calls to multiple replicas for the same user request (Get).<a name="line.144"></a>
-<span class="sourceLineNo">145</span>   * Created and put in the results array (we assume replica calls require results) when<a name="line.145"></a>
-<span class="sourceLineNo">146</span>   * the replica calls are launched. See results for details of this process.<a name="line.146"></a>
-<span class="sourceLineNo">147</span>   * POJO, all fields are public. To modify them, the object itself is locked. */<a name="line.147"></a>
-<span class="sourceLineNo">148</span>  private static class ReplicaResultState {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    public ReplicaResultState(int callCount) {<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      this.callCount = callCount;<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>    /** Number of calls outstanding, or 0 if a call succeeded (even with others outstanding). */<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    int callCount;<a name="line.154"></a>
-<span class="sourceLineNo">155</span>    /** Errors for which it is not decided whether we will report them to user. If one of the<a name="line.155"></a>
-<span class="sourceLineNo">156</span>     * calls succeeds, we will discard the errors that may have happened in the other calls. */<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    BatchErrors replicaErrors = null;<a name="line.157"></a>
-<span class="sourceLineNo">158</span><a name="line.158"></a>
-<span class="sourceLineNo">159</span>    @Override<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    public String toString() {<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      return "[call count " + callCount + "; errors " + replicaErrors + "]";<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><a name="line.164"></a>
-<span class="sourceLineNo">165</span><a name="line.165"></a>
-<span class="sourceLineNo">166</span>  // TODO: many of the fields should be made private<a name="line.166"></a>
-<span class="sourceLineNo">167</span>  protected final long id;<a name="line.167"></a>
-<span class="sourceLineNo">168</span><a name="line.168"></a>
-<span class="sourceLineNo">169</span>  protected final ClusterConnection connection;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>  protected final RpcRetryingCallerFactory rpcCallerFactory;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>  protected final RpcControllerFactory rpcFactory;<a name="line.171"></a>
-<span class="sourceLineNo">172</span>  protected final BatchErrors globalErrors;<a name="line.172"></a>
-<span class="sourceLineNo">173</span>  protected final ExecutorService pool;<a name="line.173"></a>
-<span class="sourceLineNo">174</span><a name="line.174"></a>
-<span class="sourceLineNo">175</span>  protected final AtomicLong tasksInProgress = new AtomicLong(0);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>  protected final ConcurrentMap&lt;byte[], AtomicInteger&gt; taskCounterPerRegion =<a name="line.176"></a>
-<span class="sourceLineNo">177</span>      new ConcurrentSkipListMap&lt;byte[], AtomicInteger&gt;(Bytes.BYTES_COMPARATOR);<a name="line.177"></a>
-<span class="sourceLineNo">178</span>  protected final ConcurrentMap&lt;ServerName, AtomicInteger&gt; taskCounterPerServer =<a name="line.178"></a>
-<span class="sourceLineNo">179</span>      new ConcurrentHashMap&lt;ServerName, AtomicInteger&gt;();<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>  // Start configuration settings.<a name="line.181"></a>
-<span class="sourceLineNo">182</span>  private final int startLogErrorsCnt;<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>   * The number of tasks simultaneously executed on the cluster.<a name="line.185"></a>
-<span class="sourceLineNo">186</span>   */<a name="line.186"></a>
-<span class="sourceLineNo">187</span>  protected final int maxTotalConcurrentTasks;<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>   * The number of tasks we run in parallel on a single region.<a name="line.190"></a>
-<span class="sourceLineNo">191</span>   * With 1 (the default) , we ensure that the ordering of the queries is respected: we don't start<a name="line.191"></a>
-<span class="sourceLineNo">192</span>   * a set of operations on a region before the previous one is done. As well, this limits<a name="line.192"></a>
-<span class="sourceLineNo">193</span>   * the pressure we put on the region server.<a name="line.193"></a>
-<span class="sourceLineNo">194</span>   */<a name="line.194"></a>
-<span class="sourceLineNo">195</span>  protected final int maxConcurrentTasksPerRegion;<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>   * The number of task simultaneously executed on a single region server.<a name="line.198"></a>
-<span class="sourceLineNo">199</span>   */<a name="line.199"></a>
-<span class="sourceLineNo">200</span>  protected final int maxConcurrentTasksPerServer;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>  protected final long pause;<a name="line.201"></a>
-<span class="sourceLineNo">202</span>  protected int numTries;<a name="line.202"></a>
-<span class="sourceLineNo">203</span>  protected int serverTrackerTimeout;<a name="line.203"></a>
-<span class="sourceLineNo">204</span>  protected int timeout;<a name="line.204"></a>
-<span class="sourceLineNo">205</span>  protected long primaryCallTimeoutMicroseconds;<a name="line.205"></a>
-<span class="sourceLineNo">206</span>  // End configuration settings.<a name="line.206"></a>
-<span class="sourceLineNo">207</span><a name="line.207"></a>
-<span class="sourceLineNo">208</span>  protected static class BatchErrors {<a name="line.208"></a>
-<span class="sourceLineNo">209</span>    private final List&lt;Throwable&gt; throwables = new ArrayList&lt;Throwable&gt;();<a name="line.209"></a>
-<span class="sourceLineNo">210</span>    private final List&lt;Row&gt; actions = new ArrayList&lt;Row&gt;();<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    private final List&lt;String&gt; addresses = new ArrayList&lt;String&gt;();<a name="line.211"></a>
-<span class="sourceLineNo">212</span><a name="line.212"></a>
-<span class="sourceLineNo">213</span>    public synchronized void add(Throwable ex, Row row, ServerName serverName) {<a name="line.213"></a>
-<span class="sourceLineNo">214</span>      if (row == null){<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        throw new IllegalArgumentException("row cannot be null. location=" + serverName);<a name="line.215"></a>
-<span class="sourceLineNo">216</span>      }<a name="line.216"></a>
-<span class="sourceLineNo">217</span><a name="line.217"></a>
-<span class="sourceLineNo">218</span>      throwables.add(ex);<a name="line.218"></a>
-<span class="sourceLineNo">219</span>      actions.add(row);<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      addresses.add(serverName != null ? serverName.toString() : "null");<a name="line.220"></a>
-<span class="sourceLineNo">221</span>    }<a name="line.221"></a>
-<span class="sourceLineNo">222</span><a name="line.222"></a>
-<span class="sourceLineNo">223</span>    public boolean hasErrors() {<a name="line.223"></a>
-<span class="sourceLineNo">224</span>      return !throwables.isEmpty();<a name="line.224"></a>
-<span class="sourceLineNo">225</span>    }<a name="line.225"></a>
-<span class="sourceLineNo">226</span><a name="line.226"></a>
-<span class="sourceLineNo">227</span>    private synchronized RetriesExhaustedWithDetailsException makeException() {<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      return new RetriesExhaustedWithDetailsException(<a name="line.228"></a>
-<span class="sourceLineNo">229</span>          new ArrayList&lt;Throwable&gt;(throwables),<a name="line.229"></a>
-<span class="sourceLineNo">230</span>          new ArrayList&lt;Row&gt;(actions), new ArrayList&lt;String&gt;(addresses));<a name="line.230"></a>
-<span class="sourceLineNo">231</span>    }<a name="line.231"></a>
-<span class="sourceLineNo">232</span><a name="line.232"></a>
-<span class="sourceLineNo">233</span>    public synchronized void clear() {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>      throwables.clear();<a name="line.234"></a>
-<span class="sourceLineNo">235</span>      actions.clear();<a name="line.235"></a>
-<span class="sourceLineNo">236</span>      addresses.clear();<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>    public synchronized void merge(BatchErrors other) {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>      throwables.addAll(other.throwables);<a name="line.240"></a>
-<span class="sourceLineNo">241</span>      actions.addAll(other.actions);<a name="line.241"></a>
-<span class="sourceLineNo">242</span>      addresses.addAll(other.addresses);<a name="line.242"></a>
-<span class="sourceLineNo">243</span>    }<a name="line.243"></a>
-<span class="sourceLineNo">244</span>  }<a name="line.244"></a>
-<span class="sourceLineNo">245</span><a name="line.245"></a>
-<span class="sourceLineNo">246</span>  public AsyncProcess(ClusterConnection hc, Configuration conf, ExecutorService pool,<a name="line.246"></a>
-<span class="sourceLineNo">247</span>      RpcRetryingCallerFactory rpcCaller, boolean useGlobalErrors,<a name="line.247"></a>
-<span class="sourceLineNo">248</span>      RpcControllerFactory rpcFactory) {<a name="line.248"></a>
-<span class="sourceLineNo">249</span>    if (hc == null) {<a name="line.249"></a>
-<span class="sourceLineNo">250</span>      throw new IllegalArgumentException("HConnection cannot be null.");<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    }<a name="line.251"></a>
-<span class="sourceLineNo">252</span><a name="line.252"></a>
-<span class="sourceLineNo">253</span>    this.connection = hc;<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    this.pool = pool;<a name="line.254"></a>
-<span class="sourceLineNo">255</span>    this.globalErrors = useGlobalErrors ? new BatchErrors() : null;<a name="line.255"></a>
-<span class="sourceLineNo">256</span><a name="line.256"></a>
-<span class="sourceLineNo">257</span>    this.id = COUNTER.incrementAndGet();<a name="line.257"></a>
-<span class="sourceLineNo">258</span><a name="line.258"></a>
-<span class="sourceLineNo">259</span>    this.pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,<a name="line.259"></a>
-<span class="sourceLineNo">260</span>        HConstants.DEFAULT_HBASE_CLIENT_PAUSE);<a name="line.260"></a>
-<span class="sourceLineNo">261</span>    // how many times we could try in total, one more than retry number<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    this.numTries = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,<a name="line.262"></a>
-<span class="sourceLineNo">263</span>        HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER) + 1;<a name="line.263"></a>
-<span class="sourceLineNo">264</span>    this.timeout = conf.getInt(HConstants.HBASE_RPC_TIMEOUT_KEY,<a name="line.264"></a>
-<span class="sourceLineNo">265</span>        HConstants.DEFAULT_HBASE_RPC_TIMEOUT);<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    this.primaryCallTimeoutMicroseconds = conf.getInt(PRIMARY_CALL_TIMEOUT_KEY, 10000);<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>    this.maxTotalConcurrentTasks = conf.getInt(HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS,<a name="line.268"></a>
-<span class="sourceLineNo">269</span>      HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS);<a name="line.269"></a>
-<span class="sourceLineNo">270</span>    this.maxConcurrentTasksPerServer = conf.getInt(HConstants.HBASE_CLIENT_MAX_PERSERVER_TASKS,<a name="line.270"></a>
-<span class="sourceLineNo">271</span>          HConstants.DEFAULT_HBASE_CLIENT_MAX_PERSERVER_TASKS);<a name="line.271"></a>
-<span class="sourceLineNo">272</span>    this.maxConcurrentTasksPerRegion = conf.getInt(HConstants.HBASE_CLIENT_MAX_PERREGION_TASKS,<a name="line.272"></a>
-<span class="sourceLineNo">273</span>          HConstants.DEFAULT_HBASE_CLIENT_MAX_PERREGION_TASKS);<a name="line.273"></a>
-<span class="sourceLineNo">274</span><a name="line.274"></a>
-<span class="sourceLineNo">275</span>    this.startLogErrorsCnt =<a name="line.275"></a>
-<span class="sourceLineNo">276</span>        conf.getInt(START_LOG_ERRORS_AFTER_COUNT_KEY, DEFAULT_START_LOG_ERRORS_AFTER_COUNT);<a name="line.276"></a>
-<span class="sourceLineNo">277</span><a name="line.277"></a>
-<span class="sourceLineNo">278</span>    if (this.maxTotalConcurrentTasks &lt;= 0) {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>      throw new IllegalArgumentException("maxTotalConcurrentTasks=" + maxTotalConcurrentTasks);<a name="line.279"></a>
-<span class="sourceLineNo">280</span>    }<a name="line.280"></a>
-<span class="sourceLineNo">281</span>    if (this.maxConcurrentTasksPerServer &lt;= 0) {<a name="line.281"></a>
-<span class="sourceLineNo">282</span>      throw new IllegalArgumentException("maxConcurrentTasksPerServer=" +<a name="line.282"></a>
-<span class="sourceLineNo">283</span>          maxConcurrentTasksPerServer);<a name="line.283"></a>
-<span class="sourceLineNo">284</span>    }<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    if (this.maxConcurrentTasksPerRegion &lt;= 0) {<a name="line.285"></a>
-<span class="sourceLineNo">286</span>      throw new IllegalArgumentException("maxConcurrentTasksPerRegion=" +<a name="line.286"></a>
-<span class="sourceLineNo">287</span>          maxConcurrentTasksPerRegion);<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>    // Server tracker allows us to do faster, and yet useful (hopefully), retries.<a name="line.290"></a>
-<span class="sourceLineNo">291</span>    // However, if we are too useful, we might fail very quickly due to retry count limit.<a name="line.291"></a>
-<span class="sourceLineNo">292</span>    // To avoid this, we are going to cheat for now (see HBASE-7659), and calculate maximum<a name="line.292"></a>
-<span class="sourceLineNo">293</span>    // retry time if normal retries were used. Then we will retry until this time runs out.<a name="line.293"></a>
-<span class="sourceLineNo">294</span>    // If we keep hitting one server, the net effect will be the incremental backoff, and<a name="line.294"></a>
-<span class="sourceLineNo">295</span>    // essentially the same number of retries as planned. If we have to do faster retries,<a name="line.295"></a>
-<span class="sourceLineNo">296</span>    // we will do more retries in aggregate, but the user will be none the wiser.<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    this.serverTrackerTimeout = 0;<a name="line.297"></a>
-<span class="sourceLineNo">298</span>    for (int i = 0; i &lt; this.numTries; ++i) {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>      serverTrackerTimeout += ConnectionUtils.getPauseTime(this.pause, i);<a name="line.299"></a>
-<span class="sourceLineNo">300</span>    }<a name="line.300"></a>
-<span class="sourceLineNo">301</span><a name="line.301"></a>
-<span class="sourceLineNo">302</span>    this.rpcCallerFactory = rpcCaller;<a name="line.302"></a>
-<span class="sourceLineNo">303</span>    this.rpcFactory = rpcFactory;<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>   * @return pool if non null, otherwise returns this.pool if non null, otherwise throws<a name="line.307"></a>
-<span class="sourceLineNo">308</span>   *         RuntimeException<a name="line.308"></a>
-<span class="sourceLineNo">309</span>   */<a name="line.309"></a>
-<span class="sourceLineNo">310</span>  private ExecutorService getPool(ExecutorService pool) {<a name="line.310"></a>
-<span class="sourceLineNo">311</span>    if (pool != null) return pool;<a name="line.311"></a>
-<span class="sourceLineNo">312</span>    if (this.pool != null) return this.pool;<a name="line.312"></a>
-<span class="sourceLineNo">313</span>    throw new RuntimeException("Neither AsyncProcess nor request have ExecutorService");<a name="line.313"></a>
-<span class="sourceLineNo">314</span>  }<a name="line.314"></a>
-<span class="sourceLineNo">315</span><a name="line.315"></a>
-<span class="sourceLineNo">316</span>  /**<a name="line.316"></a>
-<span class="sourceLineNo">317</span>   * See {@link #submit(ExecutorService, TableName, List, boolean, Batch.Callback, boolean)}.<a name="line.317"></a>
-<span class="sourceLineNo">318</span>   * Uses default ExecutorService for this AP (must have been created with one).<a name="line.318"></a>
-<span class="sourceLineNo">319</span>   */<a name="line.319"></a>
-<span class="sourceLineNo">320</span>  public &lt;CResult&gt; AsyncRequestFuture submit(TableName tableName, List&lt;? extends Row&gt; rows,<a name="line.320"></a>
-<span class="sourceLineNo">321</span>      boolean atLeastOne, Batch.Callback&lt;CResult&gt; callback, boolean needResults)<a name="line.321"></a>
-<span class="sourceLineNo">322</span>      throws InterruptedIOException {<a name="line.322"></a>
-<span class="sourceLineNo">323</span>    return submit(null, tableName, rows, atLeastOne, callback, needResults);<a name="line.323"></a>
-<span class="sourceLineNo">324</span>  }<a name="line.324"></a>
-<span class="sourceLineNo">325</span><a name="line.325"></a>
-<span class="sourceLineNo">326</span>  /**<a name="line.326"></a>
-<span class="sourceLineNo">327</span>   * Extract from the rows list what we can submit. The rows we can not submit are kept in the<a name="line.327"></a>
-<span class="sourceLineNo">328</span>   * list. Does not send requests to replicas (not currently used for anything other<a name="line.328"></a>
-<span class="sourceLineNo">329</span>   * than streaming puts anyway).<a name="line.329"></a>
-<span class="sourceLineNo">330</span>   *<a name="line.330"></a>
-<span class="sourceLineNo">331</span>   * @param pool ExecutorService to use.<a name="line.331"></a>
-<span class="sourceLineNo">332</span>   * @param tableName The table for which this request is needed.<a name="line.332"></a>
-<span class="sourceLineNo">333</span>   * @param callback Batch callback. Only called on success (94 behavior).<a name="line.333"></a>
-<span class="sourceLineNo">334</span>   * @param needResults Whether results are needed, or can be discarded.<a name="line.334"></a>
-<span class="sourceLineNo">335</span>   * @param rows - the submitted row. Modified by the method: we remove the rows we took.<a name="line.335"></a>
-<span class="sourceLineNo">336</span>   * @param atLeastOne true if we should submit at least a subset.<a name="line.336"></a>
-<span class="sourceLineNo">337</span>   */<a name="line.337"></a>
-<span class="sourceLineNo">338</span>  public &lt;CResult&gt; AsyncRequestFuture submit(ExecutorService pool, TableName tableName,<a name="line.338"></a>
-<span class="sourceLineNo">339</span>      List&lt;? extends Row&gt; rows, boolean atLeastOne, Batch.Callback&lt;CResult&gt; callback,<a name="line.339"></a>
-<span class="sourceLineNo">340</span>      boolean needResults) throws InterruptedIOException {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>    if (rows.isEmpty()) {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>      return NO_REQS_RESULT;<a name="line.342"></a>
-<span class="sourceLineNo">343</span>    }<a name="line.343"></a>
-<span class="sourceLineNo">344</span><a name="line.344"></a>
-<span class="sourceLineNo">345</span>    Map&lt;ServerName, MultiAction&lt;Row&gt;&gt; actionsByServer =<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        new HashMap&lt;ServerName, MultiAction&lt;Row&gt;&gt;();<a name="line.346"></a>
-<span class="sourceLineNo">347</span>    List&lt;Action&lt;Row&gt;&gt; retainedActions = new ArrayList&lt;Action&lt;Row&gt;&gt;(rows.size());<a name="line.347"></a>
-<span class="sourceLineNo">348</span><a name="line.348"></a>
-<span class="sourceLineNo">349</span>    NonceGenerator ng = this.connection.getNonceGenerator();<a name="line.349"></a>
-<span class="sourceLineNo">350</span>    long nonceGroup = ng.getNonceGroup(); // Currently, nonce group is per entire client.<a name="line.350"></a>
-<span class="sourceLineNo">351</span><a name="line.351"></a>
-<span class="sourceLineNo">352</span>    // Location errors that happen before we decide what requests to take.<a name="line.352"></a>
-<span class="sourceLineNo">353</span>    List&lt;Exception&gt; locationErrors = null;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>    List&lt;Integer&gt; locationErrorRows = null;<a name="line.354"></a>
-<span class="sourceLineNo">355</span>    do {<a name="line.355"></a>
-<span class="sourceLineNo">356</span>      // Wait until there is at least one slot for a new task.<a name="line.356"></a>
-<span class="sourceLineNo">357</span>      waitForMaximumCurrentTasks(maxTotalConcurrentTasks - 1);<a name="line.357"></a>
-<span class="sourceLineNo">358</span><a name="line.358"></a>
-<span class="sourceLineNo">359</span>      // Remember the previous decisions about regions or region servers we put in the<a name="line.359"></a>
-<span class="sourceLineNo">360</span>      //  final multi.<a name="line.360"></a>
-<span class="sourceLineNo">361</span>      Map&lt;Long, Boolean&gt; regionIncluded = new HashMap&lt;Long, Boolean&gt;();<a name="line.361"></a>
-<span class="sourceLineNo">362</span>      Map&lt;ServerName, Boolean&gt; serverIncluded = new HashMap&lt;ServerName, Boolean&gt;();<a name="line.362"></a>
-<span class="sourceLineNo">363</span><a name="line.363"></a>
-<span class="sourceLineNo">364</span>      int posInList = -1;<a name="line.364"></a>
-<span class="sourceLineNo">365</span>      Iterator&lt;? extends Row&gt; it = rows.iterator();<a name="line.365"></a>
-<span class="sourceLineNo">366</span>      while (it.hasNext()) {<a name="line.366"></a>
-<span class="sourceLineNo">367</span>        Row r = it.next();<a name="line.367"></a>
-<span class="sourceLineNo">368</span>        HRegionLocation loc;<a name="line.368"></a>
-<span class="sourceLineNo">369</span>        try {<a name="line.369"></a>
-<span class="sourceLineNo">370</span>          if (r == null) throw new IllegalArgumentException("#" + id + ", row cannot be null");<a name="line.370"></a>
-<span class="sourceLineNo">371</span>          // Make sure we get 0-s replica.<a name="line.371"></a>
-<span class="sourceLineNo">372</span>          RegionLocations locs = connection.locateRegion(<a name="line.372"></a>
-<span class="sourceLineNo">373</span>              tableName, r.getRow(), true, true, RegionReplicaUtil.DEFAULT_REPLICA_ID);<a name="line.373"></a>
-<span class="sourceLineNo">374</span>          if (locs == null || locs.isEmpty() || locs.getDefaultRegionLocation() == null) {<a name="line.374"></a>
-<span class="sourceLineNo">375</span>            throw new IOException("#" + id + ", no location found, aborting submit for"<a name="line.375"></a>
-<span class="sourceLineNo">376</span>                + " tableName=" + tableName + " rowkey=" + Bytes.toStringBinary(r.getRow()));<a name="line.376"></a>
-<span class="sourceLineNo">377</span>          }<a name="line.377"></a>
-<span class="sourceLineNo">378</span>          loc = locs.getDefaultRegionLocation();<a name="line.378"></a>
-<span class="sourceLineNo">379</span>        } catch (IOException ex) {<a name="line.379"></a>
-<span class="sourceLineNo">380</span>          locationErrors = new ArrayList&lt;Exception&gt;();<a name="line.380"></a>
-<span class="sourceLineNo">381</span>          locationErrorRows = new ArrayList&lt;Integer&gt;();<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          LOG.error("Failed to get region location ", ex);<a name="line.382"></a>
-<span class="sourceLineNo">383</span>          // This action failed before creating ars. Retain it, but do not add to submit list.<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          // We will then add it to ars in an already-failed state.<a name="line.384"></a>
-<span class="sourceLineNo">385</span>          retainedActions.add(new Action&lt;Row&gt;(r, ++posInList));<a name="line.385"></a>
-<span class="sourceLineNo">386</span>          locationErrors.add(ex);<a name="line.386"></a>
-<span class="sourceLineNo">387</span>          locationErrorRows.add(posInList);<a name="line.387"></a>
-<span class="sourceLineNo">388</span>          it.remove();<a name="line.388"></a>
-<span class="sourceLineNo">389</span>          break; // Backward compat: we stop considering actions on location error.<a name="line.389"></a>
-<span class="sourceLineNo">390</span>        }<a name="line.390"></a>
-<span class="sourceLineNo">391</span><a name="line.391"></a>
-<span class="sourceLineNo">392</span>        if (canTakeOperation(loc, regionIncluded, serverIncluded)) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>          Action&lt;Row&gt; action = new Action&lt;Row&gt;(r, ++posInList);<a name="line.393"></a>
-<span class="sourceLineNo">394</span>          setNonce(ng, r, action);<a name="line.394"></a>
-<span class="sourceLineNo">395</span>          retainedActions.add(action);<a name="line.395"></a>
-<span class="sourceLineNo">396</span>          // TODO: replica-get is not supported on this path<a name="line.396"></a>
-<span class="sourceLineNo">397</span>          byte[] regionName = loc.getRegionInfo().getRegionName();<a name="line.397"></a>
-<span class="sourceLineNo">398</span>          addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);<a name="line.398"></a>
-<span class="sourceLineNo">399</span>          it.remove();<a name="line.399"></a>
-<span class="sourceLineNo">400</span>        }<a name="line.400"></a>
-<span class="sourceLineNo">401</span>      }<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    } while (retainedActions.isEmpty() &amp;&amp; atLeastOne &amp;&amp; (locationErrors == null));<a name="line.402"></a>
-<span class="sourceLineNo">403</span><a name="line.403"></a>
-<span class="sourceLineNo">404</span>    if (retainedActions.isEmpty()) return NO_REQS_RESULT;<a name="line.404"></a>
-<span class="sourceLineNo">405</span><a name="line.405"></a>
-<span class="sourceLineNo">406</span>    return submitMultiActions(tableName, retainedActions, nonceGroup, callback, null, needResults,<a name="line.406"></a>
-<span class="sourceLineNo">407</span>      locationErrors, locationErrorRows, actionsByServer, pool);<a name="line.407"></a>
-<span class="sourceLineNo">408</span>  }<a name="line.408"></a>
-<span class="sourceLineNo">409</span><a name="line.409"></a>
-<span class="sourceLineNo">410</span>  &lt;CResult&gt; AsyncRequestFuture submitMultiActions(TableName tableName,<a name="line.410"></a>
-<span class="sourceLineNo">411</span>      List&lt;Action&lt;Row&gt;&gt; retainedActions, long nonceGroup, Batch.Callback&lt;CResult&gt; callback,<a name="line.411"></a>
-<span class="sourceLineNo">412</span>      Object[] results, boolean needResults, List&lt;Exception&gt; locationErrors,<a name="line.412"></a>
-<span class="sourceLineNo">413</span>      List&lt;Integer&gt; locationErrorRows, Map&lt;ServerName, MultiAction&lt;Row&gt;&gt; actionsByServer,<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      ExecutorService pool) {<a name="line.414"></a>
-<span class="sourceLineNo">415</span>    AsyncRequestFutureImpl&lt;CResult&gt; ars = createAsyncRequestFuture(<a name="line.415"></a>
-<span class="sourceLineNo">416</span>      tableName, retainedActions, nonceGroup, pool, callback, results, needResults);<a name="line.416"></a>
-<span class="sourceLineNo">417</span>    // Add location errors if any<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    if (locationErrors != null) {<a name="line.418"></a>
-<span class="sourceLineNo">419</span>      for (int i = 0; i &lt; locationErrors.size(); ++i) {<a name="line.419"></a>
-<span class="sourceLineNo">420</span>        int originalIndex = locationErrorRows.get(i);<a name="line.420"></a>
-<span class="sourceLineNo">421</span>        Row row = retainedActions.get(originalIndex).getAction();<a name="line.421"></a>
-<span class="sourceLineNo">422</span>        ars.manageError(originalIndex, row,<a name="line.422"></a>
-<span class="sourceLineNo">423</span>          Retry.NO_LOCATION_PROBLEM, locationErrors.get(i), null);<a name="line.423"></a>
+<span class="sourceLineNo">137</span>    public boolean hasError() {<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      return false;<a name="line.138"></a>
+<span class="sourceLineNo">139</span>    }<a name="line.139"></a>
+<span class="sourceLineNo">140</span><a name="line.140"></a>
+<span class="sourceLineNo">141</span>    @Override<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    public RetriesExhaustedWithDetailsException getErrors() {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      return null;<a name="line.143"></a>
+<span class="sourceLineNo">144</span>    }<a name="line.144"></a>
+<span class="sourceLineNo">145</span><a name="line.145"></a>
+<span class="sourceLineNo">146</span>    @Override<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    public List&lt;? extends Row&gt; getFailedOperations() {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      return null;<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>    @Override<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    public Object[] getResults() {<a name="line.152"></a>
+<span class="sourceLineNo">153</span>      return result;<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    }<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>    @Override<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    public void waitUntilDone() throws InterruptedIOException {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    }<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>  /** Sync point for calls to multiple replicas for the same user request (Get).<a name="line.161"></a>
+<span class="sourceLineNo">162</span>   * Created and put in the results array (we assume replica calls require results) when<a name="line.162"></a>
+<span class="sourceLineNo">163</span>   * the replica calls are launched. See results for details of this process.<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   * POJO, all fields are public. To modify them, the object itself is locked. */<a name="line.164"></a>
+<span class="sourceLineNo">165</span>  private static class ReplicaResultState {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>    public ReplicaResultState(int callCount) {<a name="line.166"></a>
+<span class="sourceLineNo">167</span>      this.callCount = callCount;<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    }<a name="line.168"></a>
+<span class="sourceLineNo">169</span><a name="line.169"></a>
+<span class="sourceLineNo">170</span>    /** Number of calls outstanding, or 0 if a call succeeded (even with others outstanding). */<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    int callCount;<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    /** Errors for which it is not decided whether we will report them to user. If one of the<a name="line.172"></a>
+<span class="sourceLineNo">173</span>     * calls succeeds, we will discard the errors that may have happened in the other calls. */<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    BatchErrors replicaErrors = null;<a name="line.174"></a>
+<span class="sourceLineNo">175</span><a name="line.175"></a>
+<span class="sourceLineNo">176</span>    @Override<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    public String toString() {<a name="line.177"></a>
+<span class="sourceLineNo">178</span>      return "[call count " + callCount + "; errors " + replicaErrors + "]";<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    }<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">182</span><a name="line.182"></a>
+<span class="sourceLineNo">183</span>  // TODO: many of the fields should be made private<a name="line.183"></a>
+<span class="sourceLineNo">184</span>  protected final long id;<a name="line.184"></a>
+<span class="sourceLineNo">185</span><a name="line.185"></a>
+<span class="sourceLineNo">186</span>  protected final ClusterConnection connection;<a name="line.186"></a>
+<span class="sourceLineNo">187</span>  protected final RpcRetryingCallerFactory rpcCallerFactory;<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  protected final RpcControllerFactory rpcFactory;<a name="line.188"></a>
+<span class="sourceLineNo">189</span>  protected final BatchErrors globalErrors;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>  protected final ExecutorService pool;<a name="line.190"></a>
+<span class="sourceLineNo">191</span><a name="line.191"></a>
+<span class="sourceLineNo">192</span>  protected final AtomicLong tasksInProgress = new AtomicLong(0);<a name="line.192"></a>
+<span class="sourceLineNo">193</span>  protected final ConcurrentMap&lt;byte[], AtomicInteger&gt; taskCounterPerRegion =<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      new ConcurrentSkipListMap&lt;byte[], AtomicInteger&gt;(Bytes.BYTES_COMPARATOR);<a name="line.194"></a>
+<span class="sourceLineNo">195</span>  protected final ConcurrentMap&lt;ServerName, AtomicInteger&gt; taskCounterPerServer =<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      new ConcurrentHashMap&lt;ServerName, AtomicInteger&gt;();<a name="line.196"></a>
+<span class="sourceLineNo">197</span><a name="line.197"></a>
+<span class="sourceLineNo">198</span>  // Start configuration settings.<a name="line.198"></a>
+<span class="sourceLineNo">199</span>  private final int startLogErrorsCnt;<a name="line.199"></a>
+<span class="sourceLineNo">200</span><a name="line.200"></a>
+<span class="sourceLineNo">201</span>  /**<a name="line.201"></a>
+<span class="sourceLineNo">202</span>   * The number of tasks simultaneously executed on the cluster.<a name="line.202"></a>
+<span class="sourceLineNo">203</span>   */<a name="line.203"></a>
+<span class="sourceLineNo">204</span>  protected final int maxTotalConcurrentTasks;<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>   * The number of tasks we run in parallel on a single region.<a name="line.207"></a>
+<span class="sourceLineNo">208</span>   * With 1 (the default) , we ensure that the ordering of the queries is respected: we don't start<a name="line.208"></a>
+<span class="sourceLineNo">209</span>   * a set of operations on a region before the previous one is done. As well, this limits<a name="line.209"></a>
+<span class="sourceLineNo">210</span>   * the pressure we put on the region server.<a name="line.210"></a>
+<span class="sourceLineNo">211</span>   */<a name="line.211"></a>
+<span class="sourceLineNo">212</span>  protected final int maxConcurrentTasksPerRegion;<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>   * The number of task simultaneously executed on a single region server.<a name="line.215"></a>
+<span class="sourceLineNo">216</span>   */<a name="line.216"></a>
+<span class="sourceLineNo">217</span>  protected final int maxConcurrentTasksPerServer;<a name="line.217"></a>
+<span class="sourceLineNo">218</span>  protected final long pause;<a name="line.218"></a>
+<span class="sourceLineNo">219</span>  protected int numTries;<a name="line.219"></a>
+<span class="sourceLineNo">220</span>  protected int serverTrackerTimeout;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>  protected int timeout;<a name="line.221"></a>
+<span class="sourceLineNo">222</span>  protected long primaryCallTimeoutMicroseconds;<a name="line.222"></a>
+<span class="sourceLineNo">223</span>  // End configuration settings.<a name="line.223"></a>
+<span class="sourceLineNo">224</span><a name="line.224"></a>
+<span class="sourceLineNo">225</span>  protected static class BatchErrors {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    private final List&lt;Throwable&gt; throwables = new ArrayList&lt;Throwable&gt;();<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    private final List&lt;Row&gt; actions = new ArrayList&lt;Row&gt;();<a name="line.227"></a>
+<span class="sourceLineNo">228</span>    private final List&lt;String&gt; addresses = new ArrayList&lt;String&gt;();<a name="line.228"></a>
+<span class="sourceLineNo">229</span><a name="line.229"></a>
+<span class="sourceLineNo">230</span>    public synchronized void add(Throwable ex, Row row, ServerName serverName) {<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      if (row == null){<a name="line.231"></a>
+<span class="sourceLineNo">232</span>        throw new IllegalArgumentException("row cannot be null. location=" + serverName);<a name="line.232"></a>
+<span class="sourceLineNo">233</span>      }<a name="line.233"></a>
+<span class="sourceLineNo">234</span><a name="line.234"></a>
+<span class="sourceLineNo">235</span>      throwables.add(ex);<a name="line.235"></a>
+<span class="sourceLineNo">236</span>      actions.add(row);<a name="line.236"></a>
+<span class="sourceLineNo">237</span>      addresses.add(serverName != null ? serverName.toString() : "null");<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>    public boolean hasErrors() {<a name="line.240"></a>
+<span class="sourceLineNo">241</span>      return !throwables.isEmpty();<a name="line.241"></a>
+<span class="sourceLineNo">242</span>    }<a name="line.242"></a>
+<span class="sourceLineNo">243</span><a name="line.243"></a>
+<span class="sourceLineNo">244</span>    private synchronized RetriesExhaustedWithDetailsException makeException() {<a name="line.244"></a>
+<span class="sourceLineNo">245</span>      return new RetriesExhaustedWithDetailsException(<a name="line.245"></a>
+<span class="sourceLineNo">246</span>          new ArrayList&lt;Throwable&gt;(throwables),<a name="line.246"></a>
+<span class="sourceLineNo">247</span>          new ArrayList&lt;Row&gt;(actions), new ArrayList&lt;String&gt;(addresses));<a name="line.247"></a>
+<span class="sourceLineNo">248</span>    }<a name="line.248"></a>
+<span class="sourceLineNo">249</span><a name="line.249"></a>
+<span class="sourceLineNo">250</span>    public synchronized void clear() {<a name="line.250"></a>
+<span class="sourceLineNo">251</span>      throwables.clear();<a name="line.251"></a>
+<span class="sourceLineNo">252</span>      actions.clear();<a name="line.252"></a>
+<span class="sourceLineNo">253</span>      addresses.clear();<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>    public synchronized void merge(BatchErrors other) {<a name="line.256"></a>
+<span class="sourceLineNo">257</span>      throwables.addAll(other.throwables);<a name="line.257"></a>
+<span class="sourceLineNo">258</span>      actions.addAll(other.actions);<a name="line.258"></a>
+<span class="sourceLineNo">259</span>      addresses.addAll(other.addresses);<a name="line.259"></a>
+<span class="sourceLineNo">260</span>    }<a name="line.260"></a>
+<span class="sourceLineNo">261</span>  }<a name="line.261"></a>
+<span class="sourceLineNo">262</span><a name="line.262"></a>
+<span class="sourceLineNo">263</span>  public AsyncProcess(ClusterConnection hc, Configuration conf, ExecutorService pool,<a name="line.263"></a>
+<span class="sourceLineNo">264</span>      RpcRetryingCallerFactory rpcCaller, boolean useGlobalErrors,<a name="line.264"></a>
+<span class="sourceLineNo">265</span>      RpcControllerFactory rpcFactory) {<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    if (hc == null) {<a name="line.266"></a>
+<span class="sourceLineNo">267</span>      throw new IllegalArgumentException("HConnection cannot be null.");<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    }<a name="line.268"></a>
+<span class="sourceLineNo">269</span><a name="line.269"></a>
+<span class="sourceLineNo">270</span>    this.connection = hc;<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    this.pool = pool;<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    this.globalErrors = useGlobalErrors ? new BatchErrors() : null;<a name="line.272"></a>
+<span class="sourceLineNo">273</span><a name="line.273"></a>
+<span class="sourceLineNo">274</span>    this.id = COUNTER.incrementAndGet();<a name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>    this.pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,<a name="line.276"></a>
+<span class="sourceLineNo">277</span>        HConstants.DEFAULT_HBASE_CLIENT_PAUSE);<a name="line.277"></a>
+<span class="sourceLineNo">278</span>    // how many times we could try in total, one more than retry number<a name="line.278"></a>
+<span class="sourceLineNo">279</span>    this.numTries = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,<a name="line.279"></a>
+<span class="sourceLineNo">280</span>        HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER) + 1;<a name="line.280"></a>
+<span class="sourceLineNo">281</span>    this.timeout = conf.getInt(HConstants.HBASE_RPC_TIMEOUT_KEY,<a name="line.281"></a>
+<span class="sourceLineNo">282</span>        HConstants.DEFAULT_HBASE_RPC_TIMEOUT);<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    this.primaryCallTimeoutMicroseconds = conf.getInt(PRIMARY_CALL_TIMEOUT_KEY, 10000);<a name="line.283"></a>
+<span class="sourceLineNo">284</span><a name="line.284"></a>
+<span class="sourceLineNo">285</span>    this.maxTotalConcurrentTasks = conf.getInt(HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS,<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS);<a name="line.286"></a>
+<span class="sourceLineNo">287</span>    this.maxConcurrentTasksPerServer = conf.getInt(HConstants.HBASE_CLIENT_MAX_PERSERVER_TASKS,<a name="line.287"></a>
+<span class="sourceLineNo">288</span>          HConstants.DEFAULT_HBASE_CLIENT_MAX_PERSERVER_TASKS);<a name="line.288"></a>
+<span class="sourceLineNo">289</span>    this.maxConcurrentTasksPerRegion = conf.getInt(HConstants.HBASE_CLIENT_MAX_PERREGION_TASKS,<a name="line.289"></a>
+<span class="sourceLineNo">290</span>          HConstants.DEFAULT_HBASE_CLIENT_MAX_PERREGION_TASKS);<a name="line.290"></a>
+<span class="sourceLineNo">291</span><a name="line.291"></a>
+<span class="sourceLineNo">292</span>    this.startLogErrorsCnt =<a name="line.292"></a>
+<span class="sourceLineNo">293</span>        conf.getInt(START_LOG_ERRORS_AFTER_COUNT_KEY, DEFAULT_START_LOG_ERRORS_AFTER_COUNT);<a name="line.293"></a>
+<span class="sourceLineNo">294</span><a name="line.294"></a>
+<span class="sourceLineNo">295</span>    if (this.maxTotalConcurrentTasks &lt;= 0) {<a name="line.295"></a>
+<span class="sourceLineNo">296</span>      throw new IllegalArgumentException("maxTotalConcurrentTasks=" + maxTotalConcurrentTasks);<a name="line.296"></a>
+<span class="sourceLineNo">297</span>    }<a name="line.297"></a>
+<span class="sourceLineNo">298</span>    if (this.maxConcurrentTasksPerServer &lt;= 0) {<a name="line.298"></a>
+<span class="sourceLineNo">299</span>      throw new IllegalArgumentException("maxConcurrentTasksPerServer=" +<a name="line.299"></a>
+<span class="sourceLineNo">300</span>          maxConcurrentTasksPerServer);<a name="line.300"></a>
+<span class="sourceLineNo">301</span>    }<a name="line.301"></a>
+<span class="sourceLineNo">302</span>    if (this.maxConcurrentTasksPerRegion &lt;= 0) {<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      throw new IllegalArgumentException("maxConcurrentTasksPerRegion=" +<a name="line.303"></a>
+<span class="sourceLineNo">304</span>          maxConcurrentTasksPerRegion);<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>    // Server tracker allows us to do faster, and yet useful (hopefully), retries.<a name="line.307"></a>
+<span class="sourceLineNo">308</span>    // However, if we are too useful, we might fail very quickly due to retry count limit.<a name="line.308"></a>
+<span class="sourceLineNo">309</span>    // To avoid this, we are going to cheat for now (see HBASE-7659), and calculate maximum<a name="line.309"></a>
+<span class="sourceLineNo">310</span>    // retry time if normal retries were used. Then we will retry until this time runs out.<a name="line.310"></a>
+<span class="sourceLineNo">311</span>    // If we keep hitting one server, the net effect will be the incremental backoff, and<a name="line.311"></a>
+<span class="sourceLineNo">312</span>    // essentially the same number of retries as planned. If we have to do faster retries,<a name="line.312"></a>
+<span class="sourceLineNo">313</span>    // we will do more retries in aggregate, but the user will be none the wiser.<a name="line.313"></a>
+<span class="sourceLineNo">314</span>    this.serverTrackerTimeout = 0;<a name="line.314"></a>
+<span class="sourceLineNo">315</span>    for (int i = 0; i &lt; this.numTries; ++i) {<a name="line.315"></a>
+<span class="sourceLineNo">316</span>      serverTrackerTimeout += ConnectionUtils.getPauseTime(this.pause, i);<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>    this.rpcCallerFactory = rpcCaller;<a name="line.319"></a>
+<span class="sourceLineNo">320</span>    this.rpcFactory = rpcFactory;<a name="line.320"></a>
+<span class="sourceLineNo">321</span>  }<a name="line.321"></a>
+<span class="sourceLineNo">322</span><a name="line.322"></a>
+<span class="sourceLineNo">323</span>  /**<a name="line.323"></a>
+<span class="sourceLineNo">324</span>   * @return pool if non null, otherwise returns this.pool if non null, otherwise throws<a name="line.324"></a>
+<span class="sourceLineNo">325</span>   *         RuntimeException<a name="line.325"></a>
+<span class="sourceLineNo">326</span>   */<a name="line.326"></a>
+<span class="sourceLineNo">327</span>  private ExecutorService getPool(ExecutorService pool) {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    if (pool != null) {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>      return pool;<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
+<span class="sourceLineNo">331</span>    if (this.pool != null) {<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      return this.pool;<a name="line.332"></a>
+<span class="sourceLineNo">333</span>    }<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    throw new RuntimeException("Neither AsyncProcess nor request have ExecutorService");<a name="line.334"></a>
+<span class="sourceLineNo">335</span>  }<a name="line.335"></a>
+<span class="sourceLineNo">336</span><a name="line.336"></a>
+<span class="sourceLineNo">337</span>  /**<a name="line.337"></a>
+<span class="sourceLineNo">338</span>   * See {@link #submit(ExecutorService, TableName, List, boolean, Batch.Callback, boolean)}.<a name="line.338"></a>
+<span class="sourceLineNo">339</span>   * Uses default ExecutorService for this AP (must have been created with one).<a name="line.339"></a>
+<span class="sourceLineNo">340</span>   */<a name="line.340"></a>
+<span class="sourceLineNo">341</span>  public &lt;CResult&gt; AsyncRequestFuture submit(TableName tableName, List&lt;? extends Row&gt; rows,<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      boolean atLeastOne, Batch.Callback&lt;CResult&gt; callback, boolean needResults)<a name="line.342"></a>
+<span class="sourceLineNo">343</span>      throws InterruptedIOException {<a name="line.343"></a>
+<span class="sourceLineNo">344</span>    return submit(null, tableName, rows, atLeastOne, callback, needResults);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>  }<a name="line.345"></a>
+<span class="sourceLineNo">346</span><a name="line.346"></a>
+<span class="sourceLineNo">347</span>  /**<a name="line.347"></a>
+<span class="sourceLineNo">348</span>   * Extract from the rows list what we can submit. The rows we can not submit are kept in the<a name="line.348"></a>
+<span class="sourceLineNo">349</span>   * list. Does not send requests to replicas (not currently used for anything other<a name="line.349"></a>
+<span class="sourceLineNo">350</span>   * than streaming puts anyway).<a name="line.350"></a>
+<span class="sourceLineNo">351</span>   *<a name="line.351"></a>
+<span class="sourceLineNo">352</span>   * @param pool ExecutorService to use.<a name="line.352"></a>
+<span class="sourceLineNo">353</span>   * @param tableName The table for which this request is needed.<a name="line.353"></a>
+<span class="sourceLineNo">354</span>   * @param callback Batch callback. Only called on success (94 behavior).<a name="line.354"></a>
+<span class="sourceLineNo">355</span>   * @param needResults Whether results are needed, or can be discarded.<a name="line.355"></a>
+<span class="sourceLineNo">356</span>   * @param rows - the submitted row. Modified by the method: we remove the rows we took.<a name="line.356"></a>
+<span class="sourceLineNo">357</span>   * @param atLeastOne true if we should submit at least a subset.<a name="line.357"></a>
+<span class="sourceLineNo">358</span>   */<a name="line.358"></a>
+<span class="sourceLineNo">359</span>  public &lt;CResult&gt; AsyncRequestFuture submit(ExecutorService pool, TableName tableName,<a name="line.359"></a>
+<span class="sourceLineNo">360</span>      List&lt;? extends Row&gt; rows, boolean atLeastOne, Batch.Callback&lt;CResult&gt; callback,<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      boolean needResults) throws InterruptedIOException {<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    if (rows.isEmpty()) {<a name="line.362"></a>
+<span class="sourceLineNo">363</span>      return NO_REQS_RESULT;<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>    Map&lt;ServerName, MultiAction&lt;Row&gt;&gt; actionsByServer =<a name="line.366"></a>
+<span class="sourceLineNo">367</span>        new HashMap&lt;ServerName, MultiAction&lt;Row&gt;&gt;();<a name="line.367"></a>
+<span class="sourceLineNo">368</span>    List&lt;Action&lt;Row&gt;&gt; retainedActions = new ArrayList&lt;Action&lt;Row&gt;&gt;(rows.size());<a name="line.368"></a>
+<span class="sourceLineNo">369</span><a name="line.369"></a>
+<span class="sourceLineNo">370</span>    NonceGenerator ng = this.connection.getNonceGenerator();<a name="line.370"></a>
+<span class="sourceLineNo">371</span>    long nonceGroup = ng.getNonceGroup(); // Currently, nonce group is per entire client.<a name="line.371"></a>
+<span class="sourceLineNo">372</span><a name="line.372"></a>
+<span class="sourceLineNo">373</span>    // Location errors that happen before we decide what requests to take.<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    List&lt;Exception&gt; locationErrors = null;<a name="line.374"></a>
+<span class="sourceLineNo">375</span>    List&lt;Integer&gt; locationErrorRows = null;<a name="line.375"></a>
+<span class="sourceLineNo">376</span>    do {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>      // Wait until there is at least one slot for a new task.<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      waitForMaximumCurrentTasks(maxTotalConcurrentTasks - 1);<a name="line.378"></a>
+<span class="sourceLineNo">379</span><a name="line.379"></a>
+<span class="sourceLineNo">380</span>      // Remember the previous decisions about regions or region servers we put in the<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      //  final multi.<a name="line.381"></a>
+<span class="sourceLineNo">382</span>      Map&lt;Long, Boolean&gt; regionIncluded = new HashMap&lt;Long, Boolean&gt;();<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      Map&lt;ServerName, Boolean&gt; serverIncluded = new HashMap&lt;ServerName, Boolean&gt;();<a name="line.383"></a>
+<span class="sourceLineNo">384</span><a name="line.384"></a>
+<span class="sourceLineNo">385</span>      int posInList = -1;<a name="line.385"></a>
+<span class="sourceLineNo">386</span>      Iterator&lt;? extends Row&gt; it = rows.iterator();<a name="line.386"></a>
+<span class="sourceLineNo">387</span>      while (it.hasNext()) {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>        Row r = it.next();<a name="line.388"></a>
+<span class="sourceLineNo">389</span>        HRegionLocation loc;<a name="line.389"></a>
+<span class="sourceLineNo">390</span>        try {<a name="line.390"></a>
+<span class="sourceLineNo">391</span>          if (r == null) {<a name="line.391"></a>
+<span class="sourceLineNo">392</span>            throw new IllegalArgumentException("#" + id + ", row cannot be null");<a name="line.392"></a>
+<span class="sourceLineNo">393</span>          }<a name="line.393"></a>
+<span class="sourceLineNo">394</span>          // Make sure we get 0-s replica.<a name="line.394"></a>
+<span class="sourceLineNo">395</span>          RegionLocations locs = connection.locateRegion(<a name="line.395"></a>
+<span class="sourceLineNo">396</span>              tableName, r.getRow(), true, true, RegionReplicaUtil.DEFAULT_REPLICA_ID);<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          if (locs == null || locs.isEmpty() || locs.getDefaultRegionLocation() == null) {<a name="line.397"></a>
+<span class="sourceLineNo">398</span>            throw new IOException("#" + id + ", no location found, aborting submit for"<a name="line.398"></a>
+<span class="sourceLineNo">399</span>                + " tableName=" + tableName + " rowkey=" + Bytes.toStringBinary(r.getRow()));<a name="line.399"></a>
+<span class="sourceLineNo">400</span>          }<a name="line.400"></a>
+<span class="sourceLineNo">401</span>          loc = locs.getDefaultRegionLocation();<a name="line.401"></a>
+<span class="sourceLineNo">402</span>        } catch (IOException ex) {<a name="line.402"></a>
+<span class="sourceLineNo">403</span>          locationErrors = new ArrayList&lt;Exception&gt;();<a name="line.403"></a>
+<span class="sourceLineNo">404</span>          locationErrorRows = new ArrayList&lt;Integer&gt;();<a name="line.404"></a>
+<span class="sourceLineNo">405</span>          LOG.error("Failed to get region location ", ex);<a name="line.405"></a>
+<span class="sourceLineNo">406</span>          // This action failed before creating ars. Retain it, but do not add to submit list.<a name="line.406"></a>
+<span class="sourceLineNo">407</span>          // We will then add it to ars in an already-failed state.<a name="line.407"></a>
+<span class="sourceLineNo">408</span>          retainedActions.add(new Action&lt;Row&gt;(r, ++posInList));<a name="line.408"></a>
+<span class="sourceLineNo">409</span>          locationErrors.add(ex);<a name="line.409"></a>
+<span class="sourceLineNo">410</span>          locationErrorRows.add(posInList);<a name="line.410"></a>
+<span class="sourceLineNo">411</span>          it.remove();<a name="line.411"></a>
+<span class="sourceLineNo">412</span>          break; // Backward compat: we stop considering actions on location error.<a name="line.412"></a>
+<span class="sourceLineNo">413</span>        }<a name="line.413"></a>
+<span class="sourceLineNo">414</span><a name="line.414"></a>
+<span class="sourceLineNo">415</span>        if (canTakeOperation(loc, regionIncluded, serverIncluded)) {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>          Action&lt;Row&gt; action = new Action&lt;Row&gt;(r, ++posInList);<a name="line.416"></a>
+<span class="sourceLineNo">417</span>          setNonce(ng, r, action);<a name="line.417"></a>
+<span class="sourceLineNo">418</span>          retainedActions.add(action);<a name="line.418"></a>
+<span class="sourceLineNo">419</span>          // TODO: replica-get is not supported on this path<a name="line.419"></a>
+<span class="sourceLineNo">420</span>          byte[] regionName = loc.getRegionInfo().getRegionName();<a name="line.420"></a>
+<span class="sourceLineNo">421</span>          addAction(loc.getServerName(), regionName, action, actionsByServer, nonceGroup);<a name="line.421"></a>
+<span class="sourceLineNo">422</span>          it.remove();<a name="line.422"></a>
+<span class="sourceLineNo">423</span>        }<a name="line.423"></a>
 <span class="sourceLineNo">424</span>      }<a name="line.424"></a>
-<span class="sourceLineNo">425</span>    }<a name="line.425"></a>
-<span class="sourceLineNo">426</span>    ars.sendMultiAction(actionsByServer, 1, null, false);<a name="line.426"></a>
-<span class="sourceLineNo">427</span>    return ars;<a name="line.427"></a>
-<span class="sourceLineNo">428</span>  }<a name="line.428"></a>
-<span class="sourceLineNo">429</span><a name="line.429"></a>
-<span class="sourceLineNo">430</span>  /**<a name="line.430"></a>
-<span class="sourceLineNo">431</span>   * Helper that is used when grouping the actions per region server.<a name="line.431"></a>
-<span class="sourceLineNo">432</span>   *<a name="line.432"></a>
-<span class="sourceLineNo">433</span>   * @param loc - the destination. Must not be null.<a name="line.433"></a>
-<span class="sourceLineNo">434</span>   * @param action - the action to add to the multiaction<a name="line.434"></a>
-<span class="sourceLineNo">435</span>   * @param actionsByServer the multiaction per server<a name="line.435"></a>
-<span class="sourceLineNo">436</span>   * @param nonceGroup Nonce group.<a name="line.436"></a>
-<span class="sourceLineNo">437</span>   */<a name="line.437"></a>
-<span class="sourceLineNo">438</span>  private static void addAction(ServerName server, byte[] regionName, Action&lt;Row&gt; action,<a name="line.438"></a>
-<span class="sourceLineNo">439</span>      Map&lt;ServerName, MultiAction&lt;Row&gt;&gt; actionsByServer, long nonceGroup) {<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    MultiAction&lt;Row&gt; multiAction = actionsByServer.get(server);<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    if (multiAction == null) {<a name="line.441"></a>
-<span class="sourceLineNo">442</span>      multiAction = new MultiAction&lt;Row&gt;();<a name="line.442"></a>
-<span class="sourceLineNo">443</span>      actionsByServer.put(server, multiAction);<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    }<a name="line.444"></a>
-<span class="sourceLineNo">445</span>    if (action.hasNonce() &amp;&amp; !multiAction.hasNonceGroup()) {<a name="line.445"></a>
-<span class="sourceLineNo">446</span>      multiAction.setNonceGroup(nonceGroup);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>    multiAction.add(regionName, action);<a name="line.449"></a>
-<span class="sourceLineNo">450</span>  }<a name="line.450"></a>
-<span class="sourceLineNo">451</span><a name="line.451"></a>
-<span class="sourceLineNo">452</span>  /**<a name="line.452"></a>
-<span class="sourceLineNo">453</span>   * Check if we should send new operations to this region or region server.<a name="line.453"></a>
-<span class="sourceLineNo">454</span>   * We're taking into account the past decision; if we have already accepted<a name="line.454"></a>
-<span class="sourceLineNo">455</span>   * operation on a given region, we accept all operations for this region.<a name="line.455"></a>
-<span class="sourceLineNo">456</span>   *<a name="line.456"></a>
-<span class="sourceLineNo">457</span>   * @param loc; the region and the server name we want to use.<a name="line.457"></a>
-<span class="sourceLineNo">458</span>   * @return true if this region is considered as busy.<a name="line.458"></a>
-<span class="sourceLineNo">459</span>   */<a name="line.459"></a>
-<span class="sourceLineNo">460</span>  protected boolean canTakeOperation(HRegionLocation loc,<a name="line.460"></a>
-<span class="sourceLineNo">461</span>                                     Map&lt;Long, Boolean&gt; regionsIncluded,<a name="line.461"></a>
-<span class="sourceLineNo">462</span>                                     Map&lt;ServerName, Boolean&gt; serversIncluded) {<a name="line.462"></a>
-<span class="sourceLineNo">463</span>    long regionId = loc.getRegionInfo().getRegionId();<a name="line.463"></a>
-<span class="sourceLineNo">464</span>    Boolean regionPrevious = regionsIncluded.get(regionId);<a name="line.464"></a>
-<span class="sourceLineNo">465</span><a name="line.465"></a>
-<span class="sourceLineNo">466</span>    if (regionPrevious != null) {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>      // We already know what to do with this region.<a name="line.467"></a>
-<span class="sourceLineNo">468</span>      return regionPrevious;<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    }<a name="line.469"></a>
-<span class="sourceLineNo">470</span><a name="line.470"></a>
-<span class="sourceLineNo">471</span>    Boolean serverPrevious = serversIncluded.get(loc.getServerName());<a name="line.471"></a>
-<span class="sourceLineNo">472</span>    if (Boolean.FALSE.equals(serverPrevious)) {<a name="line.472"></a>
-<span class="sourceLineNo">473</span>      // It's a new region, on a region server that we have already excluded.<a name="line.473"></a>
-<span class="sourceLineNo">474</span>      regionsIncluded.put(regionId, Boolean.FALSE);<a name="line.474"></a>
-<span class="sourceLineNo">475</span>      return false;<a name="line.475"></a>
-<span class="sourceLineNo">476</span>    }<a name="line.476"></a>
-<span class="sourceLineNo">477</span><a name="line.477"></a>
-<span class="sourceLineNo">478</span>    AtomicInteger regionCnt = taskCounterPerRegion.get(loc.getRegionInfo().getRegionName());<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    if (regionCnt != null &amp;&amp; regionCnt.get() &gt;= maxConcurrentTasksPerRegion) {<a name="line.479"></a>
-<span class="sourceLineNo">480</span>      // Too many tasks on this region already.<a name="line.480"></a>
-<span class="sourceLineNo">481</span>      regionsIncluded.put(regionId, Boolean.FALSE);<a name="line.481"></a>
-<span class="sourceLineNo">482</span>      return false;<a name="line.482"></a>
-<span class="sourceLineNo">483</span>    }<a name="line.483"></a>
-<span class="sourceLineNo">484</span><a name="line.484"></a>
-<span class="sourceLineNo">485</span>    if (serverPrevious == null) {<a name="line.485"></a>
-<span class="sourceLineNo">486</span>      // The region is ok, but we need to decide for this region server.<a name="line.486"></a>
-<span class="sourceLineNo">487</span>      int newServers = 0; // number of servers we're going to contact so far<a name="line.487"></a>
-<span class="sourceLineNo">488</span>      for (Map.Entry&lt;ServerName, Boolean&gt; kv : serversIncluded.entrySet()) {<a name="line.488"></a>
-<span class="sourceLineNo">489</span>        if (kv.getValue()) {<a name="line.489"></a>
-<span class="sourceLineNo">490</span>          newServers++;<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">425</span>    } while (retainedActions.isEmpty() &amp;&amp; atLeastOne &amp;&amp; (locationErrors == null));<a name="line.425"></a>
+<span class="sourceLineNo">426</span><a name="line.426"></a>
+<span class="sourceLineNo">427</span>    if (retainedActions.isEmpty()) return NO_REQS_RESULT;<a name="line.427"></a>
+<span class="sourceLineNo">428</span><a name="line.428"></a>
+<span class="sourceLineNo">429</span>    return submitMultiActions(tableName, retainedActions, nonceGroup, callback, null, needResults,<a name="line.429"></a>
+<span class="sourceLineNo">430</span>      locationErrors, locationErrorRows, actionsByServer, pool);<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>  &lt;CResult&gt; AsyncRequestFuture submitMultiActions(TableName tableName,<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      List&lt;Action&lt;Row&gt;&gt; retainedActions, long nonceGroup, Batch.Callback&lt;CResult&gt; callback,<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      Object[] results, boolean needResults, List&lt;Exception&gt; locationErrors,<a name="line.435"></a>
+<span class="sourceLineNo">436</span>

<TRUNCATED>

Mime
View raw message