hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [34/51] [partial] hbase git commit: Published website at 112900d0425a8157b89041f0e353ebf5cc259c69 with HBASE-14785
Date Tue, 10 Nov 2015 05:32:00 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/565d7685/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.BatchErrors.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.BatchErrors.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.BatchErrors.html
index c70a913..c8d868f 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.BatchErrors.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/AsyncProcess.BatchErrors.html
@@ -1017,767 +1017,784 @@
 <span class="sourceLineNo">1009</span>        int numAttempt) {<a name="line.1009"></a>
 <span class="sourceLineNo">1010</span>      // no stats to manage, just do the standard action<a name="line.1010"></a>
 <span class="sourceLineNo">1011</span>      if (AsyncProcess.this.connection.getStatisticsTracker() == null) {<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        return Collections.singletonList(Trace.wrap("AsyncProcess.sendMultiAction",<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>            new SingleServerRequestRunnable(multiAction, numAttempt, server, callsInProgress)));<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>      }<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span><a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>      // group the actions by the amount of delay<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>      Map&lt;Long, DelayingRunner&gt; actions = new HashMap&lt;Long, DelayingRunner&gt;(multiAction<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>          .size());<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span><a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>      // split up the actions<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; e : multiAction.actions.entrySet()) {<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>        Long backoff = getBackoff(server, e.getKey());<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>        DelayingRunner runner = actions.get(backoff);<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>        if (runner == null) {<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>          actions.put(backoff, new DelayingRunner(backoff, e));<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>        } else {<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>          runner.add(e);<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>        }<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>      }<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span><a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>      List&lt;Runnable&gt; toReturn = new ArrayList&lt;Runnable&gt;(actions.size());<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>      for (DelayingRunner runner : actions.values()) {<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>        String traceText = "AsyncProcess.sendMultiAction";<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>        Runnable runnable =<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>            new SingleServerRequestRunnable(runner.getActions(), numAttempt, server,<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>                callsInProgress);<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>        // use a delay runner only if we need to sleep for some time<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>        if (runner.getSleepTime() &gt; 0) {<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>          runner.setRunner(runnable);<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>          traceText = "AsyncProcess.clientBackoff.sendMultiAction";<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>          runnable = runner;<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>        }<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        runnable = Trace.wrap(traceText, runnable);<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>        toReturn.add(runnable);<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span><a name="line.1045"></a>
-<span class="sourceLineNo">1046</span>      }<a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>      return toReturn;<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>    }<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span><a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>    /**<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>     * @param server server location where the target region is hosted<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>     * @param regionName name of the region which we are going to write some data<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>     * @return the amount of time the client should wait until it submit a request to the<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>     * specified server and region<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>     */<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    private Long getBackoff(ServerName server, byte[] regionName) {<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>      ServerStatisticTracker tracker = AsyncProcess.this.connection.getStatisticsTracker();<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>      ServerStatistics stats = tracker.getStats(server);<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>      return AsyncProcess.this.connection.getBackoffPolicy()<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span>          .getBackoffTime(server, regionName, stats);<a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>    }<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span><a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>    /**<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>     * Starts waiting to issue replica calls on a different thread; or issues them immediately.<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>     */<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>    private void startWaitingForReplicaCalls(List&lt;Action&lt;Row&gt;&gt; actionsForReplicaThread) {<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>      long startTime = EnvironmentEdgeManager.currentTime();<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>      ReplicaCallIssuingRunnable replicaRunnable = new ReplicaCallIssuingRunnable(<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>          actionsForReplicaThread, startTime);<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      if (primaryCallTimeoutMicroseconds == 0) {<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>        // Start replica calls immediately.<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>        replicaRunnable.run();<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>      } else {<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>        // Start the thread that may kick off replica gets.<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>        // TODO: we could do it on the same thread, but it's a user thread, might be a bad idea.<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>        try {<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>          pool.submit(replicaRunnable);<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>        } catch (RejectedExecutionException ree) {<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>          LOG.warn("#" + id + ", replica task was rejected by the pool - no replica calls", ree);<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>        }<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>      }<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>    }<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span><a name="line.1083"></a>
-<span class="sourceLineNo">1084</span>    /**<a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>     * Check that we can retry acts accordingly: logs, set the error status.<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>     *<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>     * @param originalIndex the position in the list sent<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span>     * @param row           the row<a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>     * @param canRetry      if false, we won't retry whatever the settings.<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>     * @param throwable     the throwable, if any (can be null)<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>     * @param server        the location, if any (can be null)<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span>     * @return true if the action can be retried, false otherwise.<a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>     */<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>    public Retry manageError(int originalIndex, Row row, Retry canRetry,<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>                                Throwable throwable, ServerName server) {<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span>      if (canRetry == Retry.YES<a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>          &amp;&amp; throwable != null &amp;&amp; throwable instanceof DoNotRetryIOException) {<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>        canRetry = Retry.NO_NOT_RETRIABLE;<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>      }<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span><a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>      if (canRetry != Retry.YES) {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>        // Batch.Callback&lt;Res&gt; was not called on failure in 0.94. We keep this.<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>        setError(originalIndex, row, throwable, server);<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>      } else if (isActionComplete(originalIndex, row)) {<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>        canRetry = Retry.NO_OTHER_SUCCEEDED;<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>      }<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span>      return canRetry;<a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    }<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span><a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>    /**<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>     * Resubmit all the actions from this multiaction after a failure.<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>     *<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>     * @param rsActions  the actions still to do from the initial list<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>     * @param server   the destination<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span>     * @param numAttempt the number of attempts so far<a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>     * @param t the throwable (if any) that caused the resubmit<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>     */<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>    private void receiveGlobalFailure(<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>        MultiAction&lt;Row&gt; rsActions, ServerName server, int numAttempt, Throwable t) {<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      errorsByServer.reportServerError(server);<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>      Retry canRetry = errorsByServer.canTryMore(numAttempt)<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span>          ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;<a name="line.1122"></a>
-<span class="sourceLineNo">1123</span><a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>      if (tableName == null) {<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>        // tableName is null when we made a cross-table RPC call.<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>        connection.clearCaches(server);<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>      }<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>      int failed = 0, stopped = 0;<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>      List&lt;Action&lt;Row&gt;&gt; toReplay = new ArrayList&lt;Action&lt;Row&gt;&gt;();<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; e : rsActions.actions.entrySet()) {<a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>        byte[] regionName = e.getKey();<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>        byte[] row = e.getValue().iterator().next().getAction().getRow();<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>        // Do not use the exception for updating cache because it might be coming from<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span>        // any of the regions in the MultiAction.<a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>        // TODO: depending on type of exception we might not want to update cache at all?<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>        if (tableName != null) {<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>          connection.updateCachedLocations(tableName, regionName, row, null, server);<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span>        }<a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>        for (Action&lt;Row&gt; action : e.getValue()) {<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>          Retry retry = manageError(<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>              action.getOriginalIndex(), action.getAction(), canRetry, t, server);<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span>          if (retry == Retry.YES) {<a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>            toReplay.add(action);<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>            ++stopped;<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>          } else {<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span>            ++failed;<a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>          }<a name="line.1148"></a>
+<span class="sourceLineNo">1012</span>        if (connection.getConnectionMetrics() != null) {<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>          connection.getConnectionMetrics().incrNormalRunners();<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>        }<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>        return Collections.singletonList(Trace.wrap("AsyncProcess.sendMultiAction",<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>            new SingleServerRequestRunnable(multiAction, numAttempt, server, callsInProgress)));<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>      }<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span><a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>      // group the actions by the amount of delay<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>      Map&lt;Long, DelayingRunner&gt; actions = new HashMap&lt;Long, DelayingRunner&gt;(multiAction<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>          .size());<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span><a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>      // split up the actions<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; e : multiAction.actions.entrySet()) {<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>        Long backoff = getBackoff(server, e.getKey());<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>        DelayingRunner runner = actions.get(backoff);<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>        if (runner == null) {<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>          actions.put(backoff, new DelayingRunner(backoff, e));<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>        } else {<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>          runner.add(e);<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>        }<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>      }<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span><a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>      List&lt;Runnable&gt; toReturn = new ArrayList&lt;Runnable&gt;(actions.size());<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>      for (DelayingRunner runner : actions.values()) {<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>        String traceText = "AsyncProcess.sendMultiAction";<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>        Runnable runnable =<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>            new SingleServerRequestRunnable(runner.getActions(), numAttempt, server,<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>                callsInProgress);<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>        // use a delay runner only if we need to sleep for some time<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>        if (runner.getSleepTime() &gt; 0) {<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>          runner.setRunner(runnable);<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>          traceText = "AsyncProcess.clientBackoff.sendMultiAction";<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>          runnable = runner;<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>          if (connection.getConnectionMetrics() != null) {<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>            connection.getConnectionMetrics().incrDelayRunners();<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span>            connection.getConnectionMetrics().updateDelayInterval(runner.getSleepTime());<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>          }<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>        } else {<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>          if (connection.getConnectionMetrics() != null) {<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>            connection.getConnectionMetrics().incrNormalRunners();<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>          }<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>        }<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>        runnable = Trace.wrap(traceText, runnable);<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>        toReturn.add(runnable);<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span><a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>      }<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>      return toReturn;<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>    }<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span><a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>    /**<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>     * @param server server location where the target region is hosted<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>     * @param regionName name of the region which we are going to write some data<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>     * @return the amount of time the client should wait until it submit a request to the<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>     * specified server and region<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>     */<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>    private Long getBackoff(ServerName server, byte[] regionName) {<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>      ServerStatisticTracker tracker = AsyncProcess.this.connection.getStatisticsTracker();<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>      ServerStatistics stats = tracker.getStats(server);<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>      return AsyncProcess.this.connection.getBackoffPolicy()<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>          .getBackoffTime(server, regionName, stats);<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>    }<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span><a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>    /**<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>     * Starts waiting to issue replica calls on a different thread; or issues them immediately.<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>     */<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span>    private void startWaitingForReplicaCalls(List&lt;Action&lt;Row&gt;&gt; actionsForReplicaThread) {<a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>      long startTime = EnvironmentEdgeManager.currentTime();<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>      ReplicaCallIssuingRunnable replicaRunnable = new ReplicaCallIssuingRunnable(<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>          actionsForReplicaThread, startTime);<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span>      if (primaryCallTimeoutMicroseconds == 0) {<a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>        // Start replica calls immediately.<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>        replicaRunnable.run();<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>      } else {<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span>        // Start the thread that may kick off replica gets.<a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>        // TODO: we could do it on the same thread, but it's a user thread, might be a bad idea.<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>        try {<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>          pool.submit(replicaRunnable);<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span>        } catch (RejectedExecutionException ree) {<a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>          LOG.warn("#" + id + ", replica task was rejected by the pool - no replica calls", ree);<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>        }<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>      }<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span>    }<a name="line.1093"></a>
+<span class="sourceLineNo">1094</span><a name="line.1094"></a>
+<span class="sourceLineNo">1095</span>    /**<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>     * Check that we can retry acts accordingly: logs, set the error status.<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span>     *<a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>     * @param originalIndex the position in the list sent<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>     * @param row           the row<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>     * @param canRetry      if false, we won't retry whatever the settings.<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span>     * @param throwable     the throwable, if any (can be null)<a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>     * @param server        the location, if any (can be null)<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span>     * @return true if the action can be retried, false otherwise.<a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>     */<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>    public Retry manageError(int originalIndex, Row row, Retry canRetry,<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>                                Throwable throwable, ServerName server) {<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span>      if (canRetry == Retry.YES<a name="line.1107"></a>
+<span class="sourceLineNo">1108</span>          &amp;&amp; throwable != null &amp;&amp; throwable instanceof DoNotRetryIOException) {<a name="line.1108"></a>
+<span class="sourceLineNo">1109</span>        canRetry = Retry.NO_NOT_RETRIABLE;<a name="line.1109"></a>
+<span class="sourceLineNo">1110</span>      }<a name="line.1110"></a>
+<span class="sourceLineNo">1111</span><a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>      if (canRetry != Retry.YES) {<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>        // Batch.Callback&lt;Res&gt; was not called on failure in 0.94. We keep this.<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>        setError(originalIndex, row, throwable, server);<a name="line.1114"></a>
+<span class="sourceLineNo">1115</span>      } else if (isActionComplete(originalIndex, row)) {<a name="line.1115"></a>
+<span class="sourceLineNo">1116</span>        canRetry = Retry.NO_OTHER_SUCCEEDED;<a name="line.1116"></a>
+<span class="sourceLineNo">1117</span>      }<a name="line.1117"></a>
+<span class="sourceLineNo">1118</span>      return canRetry;<a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>    }<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span><a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>    /**<a name="line.1121"></a>
+<span class="sourceLineNo">1122</span>     * Resubmit all the actions from this multiaction after a failure.<a name="line.1122"></a>
+<span class="sourceLineNo">1123</span>     *<a name="line.1123"></a>
+<span class="sourceLineNo">1124</span>     * @param rsActions  the actions still to do from the initial list<a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>     * @param server   the destination<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>     * @param numAttempt the number of attempts so far<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span>     * @param t the throwable (if any) that caused the resubmit<a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>     */<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>    private void receiveGlobalFailure(<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span>        MultiAction&lt;Row&gt; rsActions, ServerName server, int numAttempt, Throwable t) {<a name="line.1130"></a>
+<span class="sourceLineNo">1131</span>      errorsByServer.reportServerError(server);<a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>      Retry canRetry = errorsByServer.canTryMore(numAttempt)<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>          ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED;<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span><a name="line.1134"></a>
+<span class="sourceLineNo">1135</span>      if (tableName == null) {<a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>        // tableName is null when we made a cross-table RPC call.<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>        connection.clearCaches(server);<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span>      }<a name="line.1138"></a>
+<span class="sourceLineNo">1139</span>      int failed = 0, stopped = 0;<a name="line.1139"></a>
+<span class="sourceLineNo">1140</span>      List&lt;Action&lt;Row&gt;&gt; toReplay = new ArrayList&lt;Action&lt;Row&gt;&gt;();<a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; e : rsActions.actions.entrySet()) {<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>        byte[] regionName = e.getKey();<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span>        byte[] row = e.getValue().iterator().next().getAction().getRow();<a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>        // Do not use the exception for updating cache because it might be coming from<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>        // any of the regions in the MultiAction.<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>        // TODO: depending on type of exception we might not want to update cache at all?<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>        if (tableName != null) {<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span>          connection.updateCachedLocations(tableName, regionName, row, null, server);<a name="line.1148"></a>
 <span class="sourceLineNo">1149</span>        }<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>      }<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span><a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>      if (toReplay.isEmpty()) {<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>        logNoResubmit(server, numAttempt, rsActions.size(), t, failed, stopped);<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>      } else {<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>        resubmit(server, toReplay, numAttempt, rsActions.size(), t);<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>      }<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>    }<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span><a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>    /**<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>     * Log as much info as possible, and, if there is something to replay,<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>     * submit it again after a back off sleep.<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>     */<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>    private void resubmit(ServerName oldServer, List&lt;Action&lt;Row&gt;&gt; toReplay,<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>        int numAttempt, int failureCount, Throwable throwable) {<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>      // We have something to replay. We're going to sleep a little before.<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span><a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>      // We have two contradicting needs here:<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span>      //  1) We want to get the new location after having slept, as it may change.<a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>      //  2) We want to take into account the location when calculating the sleep time.<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>      // It should be possible to have some heuristics to take the right decision. Short term,<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>      //  we go for one.<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>      long backOffTime = errorsByServer.calculateBackoffTime(oldServer, pause);<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>      if (numAttempt &gt; startLogErrorsCnt) {<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>        // We use this value to have some logs when we have multiple failures, but not too many<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span>        //  logs, as errors are to be expected when a region moves, splits and so on<a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>        LOG.info(createLog(numAttempt, failureCount, toReplay.size(),<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>            oldServer, throwable, backOffTime, true, null, -1, -1));<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>      }<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span><a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>      try {<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>        Thread.sleep(backOffTime);<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>      } catch (InterruptedException e) {<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>        LOG.warn("#" + id + ", not sent: " + toReplay.size() + " operations, " + oldServer, e);<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>        Thread.currentThread().interrupt();<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>        return;<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>      }<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span><a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>      groupAndSendMultiAction(toReplay, numAttempt + 1);<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>    }<a name="line.1189"></a>
+<span class="sourceLineNo">1150</span>        for (Action&lt;Row&gt; action : e.getValue()) {<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>          Retry retry = manageError(<a name="line.1151"></a>
+<span class="sourceLineNo">1152</span>              action.getOriginalIndex(), action.getAction(), canRetry, t, server);<a name="line.1152"></a>
+<span class="sourceLineNo">1153</span>          if (retry == Retry.YES) {<a name="line.1153"></a>
+<span class="sourceLineNo">1154</span>            toReplay.add(action);<a name="line.1154"></a>
+<span class="sourceLineNo">1155</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1155"></a>
+<span class="sourceLineNo">1156</span>            ++stopped;<a name="line.1156"></a>
+<span class="sourceLineNo">1157</span>          } else {<a name="line.1157"></a>
+<span class="sourceLineNo">1158</span>            ++failed;<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span>          }<a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>        }<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>      }<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span><a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>      if (toReplay.isEmpty()) {<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>        logNoResubmit(server, numAttempt, rsActions.size(), t, failed, stopped);<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>      } else {<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>        resubmit(server, toReplay, numAttempt, rsActions.size(), t);<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>      }<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>    }<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span><a name="line.1169"></a>
+<span class="sourceLineNo">1170</span>    /**<a name="line.1170"></a>
+<span class="sourceLineNo">1171</span>     * Log as much info as possible, and, if there is something to replay,<a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>     * submit it again after a back off sleep.<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span>     */<a name="line.1173"></a>
+<span class="sourceLineNo">1174</span>    private void resubmit(ServerName oldServer, List&lt;Action&lt;Row&gt;&gt; toReplay,<a name="line.1174"></a>
+<span class="sourceLineNo">1175</span>        int numAttempt, int failureCount, Throwable throwable) {<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span>      // We have something to replay. We're going to sleep a little before.<a name="line.1176"></a>
+<span class="sourceLineNo">1177</span><a name="line.1177"></a>
+<span class="sourceLineNo">1178</span>      // We have two contradicting needs here:<a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>      //  1) We want to get the new location after having slept, as it may change.<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span>      //  2) We want to take into account the location when calculating the sleep time.<a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>      // It should be possible to have some heuristics to take the right decision. Short term,<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span>      //  we go for one.<a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>      long backOffTime = errorsByServer.calculateBackoffTime(oldServer, pause);<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span>      if (numAttempt &gt; startLogErrorsCnt) {<a name="line.1184"></a>
+<span class="sourceLineNo">1185</span>        // We use this value to have some logs when we have multiple failures, but not too many<a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>        //  logs, as errors are to be expected when a region moves, splits and so on<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>        LOG.info(createLog(numAttempt, failureCount, toReplay.size(),<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>            oldServer, throwable, backOffTime, true, null, -1, -1));<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>      }<a name="line.1189"></a>
 <span class="sourceLineNo">1190</span><a name="line.1190"></a>
-<span class="sourceLineNo">1191</span>    private void logNoResubmit(ServerName oldServer, int numAttempt,<a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>        int failureCount, Throwable throwable, int failed, int stopped) {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>      if (failureCount != 0 || numAttempt &gt; startLogErrorsCnt + 1) {<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>        String timeStr = new Date(errorsByServer.getStartTrackingTime()).toString();<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>        String logMessage = createLog(numAttempt, failureCount, 0, oldServer,<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>            throwable, -1, false, timeStr, failed, stopped);<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>        if (failed != 0) {<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>          // Only log final failures as warning<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>          LOG.warn(logMessage);<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>        } else {<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>          LOG.info(logMessage);<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>        }<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      }<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>    }<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span><a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>    /**<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>     * Called when we receive the result of a server query.<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>     *<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>     * @param multiAction    - the multiAction we sent<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>     * @param server       - the location. It's used as a server name.<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>     * @param responses      - the response, if any<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>     * @param numAttempt     - the attempt<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>     */<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>    private void receiveMultiAction(MultiAction&lt;Row&gt; multiAction,<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>        ServerName server, MultiResponse responses, int numAttempt) {<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>       assert responses != null;<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span><a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>      // Success or partial success<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>      // Analyze detailed results. We can still have individual failures to be redo.<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>      // two specific throwables are managed:<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>      //  - DoNotRetryIOException: we continue to retry for other actions<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>      //  - RegionMovedException: we update the cache with the new region location<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span><a name="line.1223"></a>
-<span class="sourceLineNo">1224</span>      List&lt;Action&lt;Row&gt;&gt; toReplay = new ArrayList&lt;Action&lt;Row&gt;&gt;();<a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>      Throwable throwable = null;<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>      int failureCount = 0;<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>      boolean canRetry = true;<a name="line.1227"></a>
+<span class="sourceLineNo">1191</span>      try {<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span>        Thread.sleep(backOffTime);<a name="line.1192"></a>
+<span class="sourceLineNo">1193</span>      } catch (InterruptedException e) {<a name="line.1193"></a>
+<span class="sourceLineNo">1194</span>        LOG.warn("#" + id + ", not sent: " + toReplay.size() + " operations, " + oldServer, e);<a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>        Thread.currentThread().interrupt();<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>        return;<a name="line.1196"></a>
+<span class="sourceLineNo">1197</span>      }<a name="line.1197"></a>
+<span class="sourceLineNo">1198</span><a name="line.1198"></a>
+<span class="sourceLineNo">1199</span>      groupAndSendMultiAction(toReplay, numAttempt + 1);<a name="line.1199"></a>
+<span class="sourceLineNo">1200</span>    }<a name="line.1200"></a>
+<span class="sourceLineNo">1201</span><a name="line.1201"></a>
+<span class="sourceLineNo">1202</span>    private void logNoResubmit(ServerName oldServer, int numAttempt,<a name="line.1202"></a>
+<span class="sourceLineNo">1203</span>        int failureCount, Throwable throwable, int failed, int stopped) {<a name="line.1203"></a>
+<span class="sourceLineNo">1204</span>      if (failureCount != 0 || numAttempt &gt; startLogErrorsCnt + 1) {<a name="line.1204"></a>
+<span class="sourceLineNo">1205</span>        String timeStr = new Date(errorsByServer.getStartTrackingTime()).toString();<a name="line.1205"></a>
+<span class="sourceLineNo">1206</span>        String logMessage = createLog(numAttempt, failureCount, 0, oldServer,<a name="line.1206"></a>
+<span class="sourceLineNo">1207</span>            throwable, -1, false, timeStr, failed, stopped);<a name="line.1207"></a>
+<span class="sourceLineNo">1208</span>        if (failed != 0) {<a name="line.1208"></a>
+<span class="sourceLineNo">1209</span>          // Only log final failures as warning<a name="line.1209"></a>
+<span class="sourceLineNo">1210</span>          LOG.warn(logMessage);<a name="line.1210"></a>
+<span class="sourceLineNo">1211</span>        } else {<a name="line.1211"></a>
+<span class="sourceLineNo">1212</span>          LOG.info(logMessage);<a name="line.1212"></a>
+<span class="sourceLineNo">1213</span>        }<a name="line.1213"></a>
+<span class="sourceLineNo">1214</span>      }<a name="line.1214"></a>
+<span class="sourceLineNo">1215</span>    }<a name="line.1215"></a>
+<span class="sourceLineNo">1216</span><a name="line.1216"></a>
+<span class="sourceLineNo">1217</span>    /**<a name="line.1217"></a>
+<span class="sourceLineNo">1218</span>     * Called when we receive the result of a server query.<a name="line.1218"></a>
+<span class="sourceLineNo">1219</span>     *<a name="line.1219"></a>
+<span class="sourceLineNo">1220</span>     * @param multiAction    - the multiAction we sent<a name="line.1220"></a>
+<span class="sourceLineNo">1221</span>     * @param server       - the location. It's used as a server name.<a name="line.1221"></a>
+<span class="sourceLineNo">1222</span>     * @param responses      - the response, if any<a name="line.1222"></a>
+<span class="sourceLineNo">1223</span>     * @param numAttempt     - the attempt<a name="line.1223"></a>
+<span class="sourceLineNo">1224</span>     */<a name="line.1224"></a>
+<span class="sourceLineNo">1225</span>    private void receiveMultiAction(MultiAction&lt;Row&gt; multiAction,<a name="line.1225"></a>
+<span class="sourceLineNo">1226</span>        ServerName server, MultiResponse responses, int numAttempt) {<a name="line.1226"></a>
+<span class="sourceLineNo">1227</span>       assert responses != null;<a name="line.1227"></a>
 <span class="sourceLineNo">1228</span><a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>      // Go by original action.<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span>      int failed = 0, stopped = 0;<a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; regionEntry : multiAction.actions.entrySet()) {<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>        byte[] regionName = regionEntry.getKey();<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>        Map&lt;Integer, Object&gt; regionResults = responses.getResults().get(regionName);<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span>        if (regionResults == null) {<a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>          if (!responses.getExceptions().containsKey(regionName)) {<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>            LOG.error("Server sent us neither results nor exceptions for "<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>                + Bytes.toStringBinary(regionName));<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span>            responses.getExceptions().put(regionName, new RuntimeException("Invalid response"));<a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>          }<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>          continue;<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>        }<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>        boolean regionFailureRegistered = false;<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>        for (Action&lt;Row&gt; sentAction : regionEntry.getValue()) {<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>          Object result = regionResults.get(sentAction.getOriginalIndex());<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>          // Failure: retry if it's make sense else update the errors lists<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>          if (result == null || result instanceof Throwable) {<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>            Row row = sentAction.getAction();<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>            // Register corresponding failures once per server/once per region.<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>            if (!regionFailureRegistered) {<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>              regionFailureRegistered = true;<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span>              connection.updateCachedLocations(<a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>                  tableName, regionName, row.getRow(), result, server);<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>            }<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>            if (failureCount == 0) {<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>              errorsByServer.reportServerError(server);<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span>              // We determine canRetry only once for all calls, after reporting server failure.<a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>              canRetry = errorsByServer.canTryMore(numAttempt);<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>            }<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>            ++failureCount;<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span>            Retry retry = manageError(sentAction.getOriginalIndex(), row,<a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>                canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, (Throwable)result, server);<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>            if (retry == Retry.YES) {<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>              toReplay.add(sentAction);<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>            } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>              ++stopped;<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>            } else {<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>              ++failed;<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>            }<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span>          } else {<a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>            // update the stats about the region, if its a user table. We don't want to slow down<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>            // updates to meta tables, especially from internal updates (master, etc).<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span>            if (AsyncProcess.this.connection.getStatisticsTracker() != null) {<a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>              result = ResultStatsUtil.updateStats(result,<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>                  AsyncProcess.this.connection.getStatisticsTracker(), server, regionName);<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>            }<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span><a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>            if (callback != null) {<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>              try {<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>                //noinspection unchecked<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>                // TODO: would callback expect a replica region name if it gets one?<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>                this.callback.update(regionName, sentAction.getAction().getRow(), (CResult)result);<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>              } catch (Throwable t) {<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>                LOG.error("User callback threw an exception for "<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>                    + Bytes.toStringBinary(regionName) + ", ignoring", t);<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>              }<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>            }<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>            setResult(sentAction, result);<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span>          }<a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>        }<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>      }<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span><a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>      // The failures global to a region. We will use for multiAction we sent previously to find the<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>      //   actions to replay.<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>      for (Map.Entry&lt;byte[], Throwable&gt; throwableEntry : responses.getExceptions().entrySet()) {<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>        throwable = throwableEntry.getValue();<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>        byte[] region = throwableEntry.getKey();<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span>        List&lt;Action&lt;Row&gt;&gt; actions = multiAction.actions.get(region);<a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>        if (actions == null || actions.isEmpty()) {<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>          throw new IllegalStateException("Wrong response for the region: " +<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>              HRegionInfo.encodeRegionName(region));<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>        }<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span><a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>        if (failureCount == 0) {<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>          errorsByServer.reportServerError(server);<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>          canRetry = errorsByServer.canTryMore(numAttempt);<a name="line.1305"></a>
+<span class="sourceLineNo">1229</span>      // Success or partial success<a name="line.1229"></a>
+<span class="sourceLineNo">1230</span>      // Analyze detailed results. We can still have individual failures to be redo.<a name="line.1230"></a>
+<span class="sourceLineNo">1231</span>      // two specific throwables are managed:<a name="line.1231"></a>
+<span class="sourceLineNo">1232</span>      //  - DoNotRetryIOException: we continue to retry for other actions<a name="line.1232"></a>
+<span class="sourceLineNo">1233</span>      //  - RegionMovedException: we update the cache with the new region location<a name="line.1233"></a>
+<span class="sourceLineNo">1234</span><a name="line.1234"></a>
+<span class="sourceLineNo">1235</span>      List&lt;Action&lt;Row&gt;&gt; toReplay = new ArrayList&lt;Action&lt;Row&gt;&gt;();<a name="line.1235"></a>
+<span class="sourceLineNo">1236</span>      Throwable throwable = null;<a name="line.1236"></a>
+<span class="sourceLineNo">1237</span>      int failureCount = 0;<a name="line.1237"></a>
+<span class="sourceLineNo">1238</span>      boolean canRetry = true;<a name="line.1238"></a>
+<span class="sourceLineNo">1239</span><a name="line.1239"></a>
+<span class="sourceLineNo">1240</span>      // Go by original action.<a name="line.1240"></a>
+<span class="sourceLineNo">1241</span>      int failed = 0, stopped = 0;<a name="line.1241"></a>
+<span class="sourceLineNo">1242</span>      for (Map.Entry&lt;byte[], List&lt;Action&lt;Row&gt;&gt;&gt; regionEntry : multiAction.actions.entrySet()) {<a name="line.1242"></a>
+<span class="sourceLineNo">1243</span>        byte[] regionName = regionEntry.getKey();<a name="line.1243"></a>
+<span class="sourceLineNo">1244</span>        Map&lt;Integer, Object&gt; regionResults = responses.getResults().get(regionName);<a name="line.1244"></a>
+<span class="sourceLineNo">1245</span>        if (regionResults == null) {<a name="line.1245"></a>
+<span class="sourceLineNo">1246</span>          if (!responses.getExceptions().containsKey(regionName)) {<a name="line.1246"></a>
+<span class="sourceLineNo">1247</span>            LOG.error("Server sent us neither results nor exceptions for "<a name="line.1247"></a>
+<span class="sourceLineNo">1248</span>                + Bytes.toStringBinary(regionName));<a name="line.1248"></a>
+<span class="sourceLineNo">1249</span>            responses.getExceptions().put(regionName, new RuntimeException("Invalid response"));<a name="line.1249"></a>
+<span class="sourceLineNo">1250</span>          }<a name="line.1250"></a>
+<span class="sourceLineNo">1251</span>          continue;<a name="line.1251"></a>
+<span class="sourceLineNo">1252</span>        }<a name="line.1252"></a>
+<span class="sourceLineNo">1253</span>        boolean regionFailureRegistered = false;<a name="line.1253"></a>
+<span class="sourceLineNo">1254</span>        for (Action&lt;Row&gt; sentAction : regionEntry.getValue()) {<a name="line.1254"></a>
+<span class="sourceLineNo">1255</span>          Object result = regionResults.get(sentAction.getOriginalIndex());<a name="line.1255"></a>
+<span class="sourceLineNo">1256</span>          // Failure: retry if it's make sense else update the errors lists<a name="line.1256"></a>
+<span class="sourceLineNo">1257</span>          if (result == null || result instanceof Throwable) {<a name="line.1257"></a>
+<span class="sourceLineNo">1258</span>            Row row = sentAction.getAction();<a name="line.1258"></a>
+<span class="sourceLineNo">1259</span>            // Register corresponding failures once per server/once per region.<a name="line.1259"></a>
+<span class="sourceLineNo">1260</span>            if (!regionFailureRegistered) {<a name="line.1260"></a>
+<span class="sourceLineNo">1261</span>              regionFailureRegistered = true;<a name="line.1261"></a>
+<span class="sourceLineNo">1262</span>              connection.updateCachedLocations(<a name="line.1262"></a>
+<span class="sourceLineNo">1263</span>                  tableName, regionName, row.getRow(), result, server);<a name="line.1263"></a>
+<span class="sourceLineNo">1264</span>            }<a name="line.1264"></a>
+<span class="sourceLineNo">1265</span>            if (failureCount == 0) {<a name="line.1265"></a>
+<span class="sourceLineNo">1266</span>              errorsByServer.reportServerError(server);<a name="line.1266"></a>
+<span class="sourceLineNo">1267</span>              // We determine canRetry only once for all calls, after reporting server failure.<a name="line.1267"></a>
+<span class="sourceLineNo">1268</span>              canRetry = errorsByServer.canTryMore(numAttempt);<a name="line.1268"></a>
+<span class="sourceLineNo">1269</span>            }<a name="line.1269"></a>
+<span class="sourceLineNo">1270</span>            ++failureCount;<a name="line.1270"></a>
+<span class="sourceLineNo">1271</span>            Retry retry = manageError(sentAction.getOriginalIndex(), row,<a name="line.1271"></a>
+<span class="sourceLineNo">1272</span>                canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, (Throwable)result, server);<a name="line.1272"></a>
+<span class="sourceLineNo">1273</span>            if (retry == Retry.YES) {<a name="line.1273"></a>
+<span class="sourceLineNo">1274</span>              toReplay.add(sentAction);<a name="line.1274"></a>
+<span class="sourceLineNo">1275</span>            } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1275"></a>
+<span class="sourceLineNo">1276</span>              ++stopped;<a name="line.1276"></a>
+<span class="sourceLineNo">1277</span>            } else {<a name="line.1277"></a>
+<span class="sourceLineNo">1278</span>              ++failed;<a name="line.1278"></a>
+<span class="sourceLineNo">1279</span>            }<a name="line.1279"></a>
+<span class="sourceLineNo">1280</span>          } else {<a name="line.1280"></a>
+<span class="sourceLineNo">1281</span>            <a name="line.1281"></a>
+<span class="sourceLineNo">1282</span>            if (AsyncProcess.this.connection.getConnectionMetrics() != null) {<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span>              AsyncProcess.this.connection.getConnectionMetrics().<a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>                      updateServerStats(server, regionName, result);<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span>            }<a name="line.1285"></a>
+<span class="sourceLineNo">1286</span><a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>            // update the stats about the region, if its a user table. We don't want to slow down<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>            // updates to meta tables, especially from internal updates (master, etc).<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span>            if (AsyncProcess.this.connection.getStatisticsTracker() != null) {<a name="line.1289"></a>
+<span class="sourceLineNo">1290</span>              result = ResultStatsUtil.updateStats(result,<a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>                  AsyncProcess.this.connection.getStatisticsTracker(), server, regionName);<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>            }<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span><a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>            if (callback != null) {<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span>              try {<a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>                //noinspection unchecked<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>                // TODO: would callback expect a replica region name if it gets one?<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span>                this.callback.update(regionName, sentAction.getAction().getRow(), (CResult)result);<a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>              } catch (Throwable t) {<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span>                LOG.error("User callback threw an exception for "<a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>                    + Bytes.toStringBinary(regionName) + ", ignoring", t);<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>              }<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>            }<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span>            setResult(sentAction, result);<a name="line.1304"></a>
+<span class="sourceLineNo">1305</span>          }<a name="line.1305"></a>
 <span class="sourceLineNo">1306</span>        }<a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>        connection.updateCachedLocations(<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>            tableName, region, actions.get(0).getAction().getRow(), throwable, server);<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>        failureCount += actions.size();<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span><a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>        for (Action&lt;Row&gt; action : actions) {<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>          Row row = action.getAction();<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>          Retry retry = manageError(action.getOriginalIndex(), row,<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>              canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, throwable, server);<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>          if (retry == Retry.YES) {<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>            toReplay.add(action);<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>            ++stopped;<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>          } else {<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>            ++failed;<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>          }<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>        }<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>      }<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span><a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      if (toReplay.isEmpty()) {<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>        logNoResubmit(server, numAttempt, failureCount, throwable, failed, stopped);<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      } else {<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>        resubmit(server, toReplay, numAttempt, failureCount, throwable);<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>      }<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>    }<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span><a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>    private String createLog(int numAttempt, int failureCount, int replaySize, ServerName sn,<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>        Throwable error, long backOffTime, boolean willRetry, String startTime,<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>        int failed, int stopped) {<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      StringBuilder sb = new StringBuilder();<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>      sb.append("#").append(id).append(", table=").append(tableName).append(", ")<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>        .append("attempt=").append(numAttempt)<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>        .append("/").append(numTries).append(" ");<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span><a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      if (failureCount &gt; 0 || error != null){<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>        sb.append("failed=").append(failureCount).append("ops").append(", last exception: ").<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>            append(error == null ? "null" : error);<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>      } else {<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>        sb.append("succeeded");<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>      }<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span><a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>      sb.append(" on ").append(sn).append(", tracking started ").append(startTime);<a name="line.1347"></a>
+<span class="sourceLineNo">1307</span>      }<a name="line.1307"></a>
+<span class="sourceLineNo">1308</span><a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>      // The failures global to a region. We will use for multiAction we sent previously to find the<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span>      //   actions to replay.<a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>      for (Map.Entry&lt;byte[], Throwable&gt; throwableEntry : responses.getExceptions().entrySet()) {<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>        throwable = throwableEntry.getValue();<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span>        byte[] region = throwableEntry.getKey();<a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>        List&lt;Action&lt;Row&gt;&gt; actions = multiAction.actions.get(region);<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span>        if (actions == null || actions.isEmpty()) {<a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>          throw new IllegalStateException("Wrong response for the region: " +<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>              HRegionInfo.encodeRegionName(region));<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>        }<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span><a name="line.1319"></a>
+<span class="sourceLineNo">1320</span>        if (failureCount == 0) {<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>          errorsByServer.reportServerError(server);<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>          canRetry = errorsByServer.canTryMore(numAttempt);<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>        }<a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>        connection.updateCachedLocations(<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>            tableName, region, actions.get(0).getAction().getRow(), throwable, server);<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span>        failureCount += actions.size();<a name="line.1326"></a>
+<span class="sourceLineNo">1327</span><a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>        for (Action&lt;Row&gt; action : actions) {<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>          Row row = action.getAction();<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>          Retry retry = manageError(action.getOriginalIndex(), row,<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>              canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, throwable, server);<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span>          if (retry == Retry.YES) {<a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>            toReplay.add(action);<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>            ++stopped;<a name="line.1335"></a>
+<span class="sourceLineNo">1336</span>          } else {<a name="line.1336"></a>
+<span class="sourceLineNo">1337</span>            ++failed;<a name="line.1337"></a>
+<span class="sourceLineNo">1338</span>          }<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span>        }<a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>      }<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span><a name="line.1341"></a>
+<span class="sourceLineNo">1342</span>      if (toReplay.isEmpty()) {<a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>        logNoResubmit(server, numAttempt, failureCount, throwable, failed, stopped);<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>      } else {<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>        resubmit(server, toReplay, numAttempt, failureCount, throwable);<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span>      }<a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>    }<a name="line.1347"></a>
 <span class="sourceLineNo">1348</span><a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>      if (willRetry) {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>        sb.append(", retrying after=").append(backOffTime).append("ms").<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>            append(", replay=").append(replaySize).append("ops");<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>      } else if (failureCount &gt; 0) {<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>        if (stopped &gt; 0) {<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>          sb.append("; not retrying ").append(stopped).append(" due to success from other replica");<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>        }<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>        if (failed &gt; 0) {<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>          sb.append("; not retrying ").append(failed).append(" - final failure");<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>        }<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span><a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>      }<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span><a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>      return sb.toString();<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>    }<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span><a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>    /**<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>     * Sets the non-error result from a particular action.<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>     * @param action Action (request) that the server responded to.<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>     * @param result The result.<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>     */<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>    private void setResult(Action&lt;Row&gt; action, Object result) {<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>      if (result == null) {<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>        throw new RuntimeException("Result cannot be null");<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>      }<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>      ReplicaResultState state = null;<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>      boolean isStale = !RegionReplicaUtil.isDefaultReplica(action.getReplicaId());<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>      int index = action.getOriginalIndex();<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>      if (results == null) {<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>         decActionCounter(index);<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>         return; // Simple case, no replica requests.<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>      }<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>      state = trySetResultSimple(index, action.getAction(), false, result, null, isStale);<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>      if (state == null) {<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>        return; // Simple case, no replica requests.<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>      }<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>      // At this point we know that state is set to replica tracking class.<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>      // It could be that someone else is also looking at it; however, we know there can<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>      // only be one state object, and only one thread can set callCount to 0. Other threads<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>      // will either see state with callCount 0 after locking it; or will not see state at all<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>      // we will replace it with the result.<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>      synchronized (state) {<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>        if (state.callCount == 0) return; // someone already set the result<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>        state.callCount = 0;<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>      }<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>      synchronized (replicaResultLock) {<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>        if (results[index] != state) {<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          throw new AssertionError("We set the callCount but someone else replaced the result");<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>        }<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>        results[index] = result;<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>      }<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span><a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>      decActionCounter(index);<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>    }<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span><a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>    /**<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>     * Sets the error from a particular action.<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>     * @param index Original action index.<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>     * @param row Original request.<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>     * @param throwable The resulting error.<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>     * @param server The source server.<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>     */<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>    private void setError(int index, Row row, Throwable throwable, ServerName server) {<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>      ReplicaResultState state = null;<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>      if (results == null) {<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>        // Note that we currently cannot have replica requests with null results. So it shouldn't<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>        // happen that multiple replica calls will call dAC for same actions with results == null.<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>        // Only one call per action should be present in this case.<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>        errors.add(throwable, row, server);<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>        decActionCounter(index);<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>        return; // Simple case, no replica requests.<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>      }<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>      state = trySetResultSimple(index, row, true, throwable, server, false);<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>      if (state == null) {<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>        return; // Simple case, no replica requests.<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>      }<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>      BatchErrors target = null; // Error will be added to final errors, or temp replica errors.<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>      boolean isActionDone = false;<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>      synchronized (state) {<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>        switch (state.callCount) {<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>          case 0: return; // someone already set the result<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>          case 1: { // All calls failed, we are the last error.<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>            target = errors;<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>            isActionDone = true;<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>            break;<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>          }<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>          default: {<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>            assert state.callCount &gt; 1;<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>            if (state.replicaErrors == null) {<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>              state.replicaErrors = new BatchErrors();<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>            }<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>            target = state.replicaErrors;<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>            break;<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>          }<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>        }<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>        --state.callCount;<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>      }<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>      target.add(throwable, row, server);<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>      if (isActionDone) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>        if (state.replicaErrors != null) { // last call, no need to lock<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>          errors.merge(state.replicaErrors);<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>        }<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>        // See setResult for explanations.<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>        synchronized (replicaResultLock) {<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>          if (results[index] != state) {<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>            throw new AssertionError("We set the callCount but someone else replaced the result");<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>          }<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>          results[index] = throwable;<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>        }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>        decActionCounter(index);<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>      }<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>    }<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span><a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>    /**<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>     * Checks if the action is complete; used on error to prevent needless retries.<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>     * Does not synchronize, assuming element index/field accesses are atomic.<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>     * This is an opportunistic optimization check, doesn't have to be strict.<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>     * @param index Original action index.<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>     * @param row Original request.<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>     */<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    private boolean isActionComplete(int index, Row row) {<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>      if (!isReplicaGet(row)) return false;<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      Object resObj = results[index];<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>      return (resObj != null) &amp;&amp; (!(resObj instanceof ReplicaResultState)<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>          || ((ReplicaResultState)resObj).callCount == 0);<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>    }<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span><a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    /**<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>     * Tries to set the result or error for a particular action as if there were no replica calls.<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>     * @return null if successful; replica state if there were in fact replica calls.<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>     */<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>    private ReplicaResultState trySetResultSimple(int index, Row row, boolean isError,<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>        Object result, ServerName server, boolean isFromReplica) {<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>      Object resObj = null;<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      if (!isReplicaGet(row)) {<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>        if (isFromReplica) {<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>          throw new AssertionError("Unexpected stale result for " + row);<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        }<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>        results[index] = result;<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>      } else {<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>        synchronized (replicaResultLock) {<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>          resObj = results[index];<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>          if (resObj == null) {<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>            if (isFromReplica) {<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>              throw new AssertionError("Unexpected stale result for " + row);<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>            }<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>            results[index] = result;<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>          }<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>        }<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>      }<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span><a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>      ReplicaResultState rrs =<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>          (resObj instanceof ReplicaResultState) ? (ReplicaResultState)resObj : null;<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>      if (rrs == null &amp;&amp; isError) {<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>        // The resObj is not replica state (null or already set).<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>        errors.add((Throwable)result, row, server);<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>      }<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span><a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>      if (resObj == null) {<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>        // resObj is null - no replica calls were made.<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>        decActionCounter(index);<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        return null;<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>      }<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      return rrs;<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>    }<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span><a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>    private void decActionCounter(int index) {<a name="line.1515"></a

<TRUNCATED>

Mime
View raw message