hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [28/51] [partial] hbase-site git commit: Published site at 58283fa1b1b10beec62cefa40babff6a1424b06c.
Date Tue, 23 Feb 2016 17:08:36 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d02dd5db/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 3180076..d813e71 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
@@ -1368,474 +1368,481 @@
 <span class="sourceLineNo">1360</span>          errorsByServer.reportServerError(server);<a name="line.1360"></a>
 <span class="sourceLineNo">1361</span>          canRetry = errorsByServer.canTryMore(numAttempt);<a name="line.1361"></a>
 <span class="sourceLineNo">1362</span>        }<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>        connection.updateCachedLocations(<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>            tableName, region, actions.get(0).getAction().getRow(), throwable, server);<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>        failureCount += actions.size();<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span><a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>        for (Action&lt;Row&gt; action : actions) {<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>          Row row = action.getAction();<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>          Retry retry = manageError(action.getOriginalIndex(), row,<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>              canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, throwable, server);<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>          if (retry == Retry.YES) {<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>            toReplay.add(action);<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>            ++stopped;<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>          } else {<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>            ++failed;<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>          }<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>        }<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>      }<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span><a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>      if (toReplay.isEmpty()) {<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>        logNoResubmit(server, numAttempt, failureCount, throwable, failed, stopped);<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>      } else {<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>        resubmit(server, toReplay, numAttempt, failureCount, throwable);<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>      }<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>    }<a name="line.1386"></a>
+<span class="sourceLineNo">1363</span>        if (null == tableName &amp;&amp; ClientExceptionsUtil.isMetaClearingException(throwable)) {<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span>          // For multi-actions, we don't have a table name, but we want to make sure to clear the<a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>          // cache in case there were location-related exceptions. We don't to clear the cache<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>          // for every possible exception that comes through, however.<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>          connection.clearCaches(server);<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>        } else {<a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>          connection.updateCachedLocations(<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>              tableName, region, actions.get(0).getAction().getRow(), throwable, server);<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>        }<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>        failureCount += actions.size();<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span><a name="line.1373"></a>
+<span class="sourceLineNo">1374</span>        for (Action&lt;Row&gt; action : actions) {<a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>          Row row = action.getAction();<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>          Retry retry = manageError(action.getOriginalIndex(), row,<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span>              canRetry ? Retry.YES : Retry.NO_RETRIES_EXHAUSTED, throwable, server);<a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>          if (retry == Retry.YES) {<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span>            toReplay.add(action);<a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>          } else if (retry == Retry.NO_OTHER_SUCCEEDED) {<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>            ++stopped;<a name="line.1381"></a>
+<span class="sourceLineNo">1382</span>          } else {<a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>            ++failed;<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>          }<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>        }<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>      }<a name="line.1386"></a>
 <span class="sourceLineNo">1387</span><a name="line.1387"></a>
-<span class="sourceLineNo">1388</span>    private String createLog(int numAttempt, int failureCount, int replaySize, ServerName sn,<a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>        Throwable error, long backOffTime, boolean willRetry, String startTime,<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>        int failed, int stopped) {<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>      StringBuilder sb = new StringBuilder();<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>      sb.append("#").append(id).append(", table=").append(tableName).append(", ")<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>        .append("attempt=").append(numAttempt)<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>        .append("/").append(numTries).append(" ");<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span><a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>      if (failureCount &gt; 0 || error != null){<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>        sb.append("failed=").append(failureCount).append("ops").append(", last exception: ").<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>            append(error == null ? "null" : error);<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>      } else {<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>        sb.append("succeeded");<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>      }<a name="line.1401"></a>
+<span class="sourceLineNo">1388</span>      if (toReplay.isEmpty()) {<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span>        logNoResubmit(server, numAttempt, failureCount, throwable, failed, stopped);<a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>      } else {<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>        resubmit(server, toReplay, numAttempt, failureCount, throwable);<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>      }<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>    }<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span><a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>    private String createLog(int numAttempt, int failureCount, int replaySize, ServerName sn,<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>        Throwable error, long backOffTime, boolean willRetry, String startTime,<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>        int failed, int stopped) {<a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>      StringBuilder sb = new StringBuilder();<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>      sb.append("#").append(id).append(", table=").append(tableName).append(", ")<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>        .append("attempt=").append(numAttempt)<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>        .append("/").append(numTries).append(" ");<a name="line.1401"></a>
 <span class="sourceLineNo">1402</span><a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>      sb.append(" on ").append(sn).append(", tracking started ").append(startTime);<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span><a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>      if (willRetry) {<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>        sb.append(", retrying after=").append(backOffTime).append("ms").<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>            append(", replay=").append(replaySize).append("ops");<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>      } else if (failureCount &gt; 0) {<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>        if (stopped &gt; 0) {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>          sb.append("; not retrying ").append(stopped).append(" due to success from other replica");<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>        }<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>        if (failed &gt; 0) {<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>          sb.append("; not retrying ").append(failed).append(" - final failure");<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>        }<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span><a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>      }<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span><a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>      return sb.toString();<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>    }<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span><a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>    /**<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>     * Sets the non-error result from a particular action.<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>     * @param action Action (request) that the server responded to.<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>     * @param result The result.<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>     */<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>    private void setResult(Action&lt;Row&gt; action, Object result) {<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>      if (result == null) {<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>        throw new RuntimeException("Result cannot be null");<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>      }<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>      ReplicaResultState state = null;<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>      boolean isStale = !RegionReplicaUtil.isDefaultReplica(action.getReplicaId());<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>      int index = action.getOriginalIndex();<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>      if (results == null) {<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>         decActionCounter(index);<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>         return; // Simple case, no replica requests.<a name="line.1435"></a>
+<span class="sourceLineNo">1403</span>      if (failureCount &gt; 0 || error != null){<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>        sb.append("failed=").append(failureCount).append("ops").append(", last exception: ").<a name="line.1404"></a>
+<span class="sourceLineNo">1405</span>            append(error == null ? "null" : error);<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>      } else {<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>        sb.append("succeeded");<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>      }<a name="line.1408"></a>
+<span class="sourceLineNo">1409</span><a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>      sb.append(" on ").append(sn).append(", tracking started ").append(startTime);<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span><a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>      if (willRetry) {<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>        sb.append(", retrying after=").append(backOffTime).append("ms").<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>            append(", replay=").append(replaySize).append("ops");<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>      } else if (failureCount &gt; 0) {<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>        if (stopped &gt; 0) {<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>          sb.append("; not retrying ").append(stopped).append(" due to success from other replica");<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>        }<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>        if (failed &gt; 0) {<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>          sb.append("; not retrying ").append(failed).append(" - final failure");<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>        }<a name="line.1421"></a>
+<span class="sourceLineNo">1422</span><a name="line.1422"></a>
+<span class="sourceLineNo">1423</span>      }<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span><a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>      return sb.toString();<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>    }<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span><a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>    /**<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>     * Sets the non-error result from a particular action.<a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>     * @param action Action (request) that the server responded to.<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>     * @param result The result.<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>     */<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span>    private void setResult(Action&lt;Row&gt; action, Object result) {<a name="line.1433"></a>
+<span class="sourceLineNo">1434</span>      if (result == null) {<a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>        throw new RuntimeException("Result cannot be null");<a name="line.1435"></a>
 <span class="sourceLineNo">1436</span>      }<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>      state = trySetResultSimple(index, action.getAction(), false, result, null, isStale);<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>      if (state == null) {<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>        return; // Simple case, no replica requests.<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>      }<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>      // At this point we know that state is set to replica tracking class.<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>      // It could be that someone else is also looking at it; however, we know there can<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>      // only be one state object, and only one thread can set callCount to 0. Other threads<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>      // will either see state with callCount 0 after locking it; or will not see state at all<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>      // we will replace it with the result.<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>      synchronized (state) {<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>        if (state.callCount == 0) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>          return; // someone already set the result<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>        }<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>        state.callCount = 0;<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>      }<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] = result;<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>      }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span><a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>      decActionCounter(index);<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>     * Sets the error from a particular action.<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>     * @param index Original action index.<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>     * @param row Original request.<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>     * @param throwable The resulting error.<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>     * @param server The source server.<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>     */<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    private void setError(int index, Row row, Throwable throwable, ServerName server) {<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>      ReplicaResultState state = null;<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      if (results == null) {<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        // Note that we currently cannot have replica requests with null results. So it shouldn't<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>        // happen that multiple replica calls will call dAC for same actions with results == null.<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>        // Only one call per action should be present in this case.<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>        errors.add(throwable, row, server);<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>        decActionCounter(index);<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>        return; // Simple case, no replica requests.<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>      }<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>      state = trySetResultSimple(index, row, true, throwable, server, false);<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>      if (state == null) {<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>        return; // Simple case, no replica requests.<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>      }<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      BatchErrors target = null; // Error will be added to final errors, or temp replica errors.<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>      boolean isActionDone = false;<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>      synchronized (state) {<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        switch (state.callCount) {<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>          case 0: return; // someone already set the result<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>          case 1: { // All calls failed, we are the last error.<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>            target = errors;<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>            isActionDone = true;<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>            break;<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>          }<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>          default: {<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>            assert state.callCount &gt; 1;<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>            if (state.replicaErrors == null) {<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>              state.replicaErrors = new BatchErrors();<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>            }<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>            target = state.replicaErrors;<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>            break;<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>          }<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>        }<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>        --state.callCount;<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>      }<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      target.add(throwable, row, server);<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>      if (isActionDone) {<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>        if (state.replicaErrors != null) { // last call, no need to lock<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>          errors.merge(state.replicaErrors);<a name="line.1507"></a>
+<span class="sourceLineNo">1437</span>      ReplicaResultState state = null;<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span>      boolean isStale = !RegionReplicaUtil.isDefaultReplica(action.getReplicaId());<a name="line.1438"></a>
+<span class="sourceLineNo">1439</span>      int index = action.getOriginalIndex();<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span>      if (results == null) {<a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>         decActionCounter(index);<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>         return; // Simple case, no replica requests.<a name="line.1442"></a>
+<span class="sourceLineNo">1443</span>      }<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>      state = trySetResultSimple(index, action.getAction(), false, result, null, isStale);<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>      if (state == null) {<a name="line.1445"></a>
+<span class="sourceLineNo">1446</span>        return; // Simple case, no replica requests.<a name="line.1446"></a>
+<span class="sourceLineNo">1447</span>      }<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>      // At this point we know that state is set to replica tracking class.<a name="line.1448"></a>
+<span class="sourceLineNo">1449</span>      // It could be that someone else is also looking at it; however, we know there can<a name="line.1449"></a>
+<span class="sourceLineNo">1450</span>      // only be one state object, and only one thread can set callCount to 0. Other threads<a name="line.1450"></a>
+<span class="sourceLineNo">1451</span>      // will either see state with callCount 0 after locking it; or will not see state at all<a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>      // we will replace it with the result.<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span>      synchronized (state) {<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>        if (state.callCount == 0) {<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>          return; // someone already set the result<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>        }<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>        state.callCount = 0;<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>      }<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>      synchronized (replicaResultLock) {<a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>        if (results[index] != state) {<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>          throw new AssertionError("We set the callCount but someone else replaced the result");<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>        }<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span>        results[index] = result;<a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>      }<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span><a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>      decActionCounter(index);<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>    }<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span><a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>    /**<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>     * Sets the error from a particular action.<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>     * @param index Original action index.<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>     * @param row Original request.<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>     * @param throwable The resulting error.<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>     * @param server The source server.<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span>     */<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>    private void setError(int index, Row row, Throwable throwable, ServerName server) {<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>      ReplicaResultState state = null;<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span>      if (results == null) {<a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>        // Note that we currently cannot have replica requests with null results. So it shouldn't<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>        // happen that multiple replica calls will call dAC for same actions with results == null.<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>        // Only one call per action should be present in this case.<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>        errors.add(throwable, row, server);<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>        decActionCounter(index);<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>        return; // Simple case, no replica requests.<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      }<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>      state = trySetResultSimple(index, row, true, throwable, server, false);<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>      if (state == null) {<a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>        return; // Simple case, no replica requests.<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>      }<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>      BatchErrors target = null; // Error will be added to final errors, or temp replica errors.<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>      boolean isActionDone = false;<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>      synchronized (state) {<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>        switch (state.callCount) {<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>          case 0: return; // someone already set the result<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>          case 1: { // All calls failed, we are the last error.<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>            target = errors;<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span>            isActionDone = true;<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>            break;<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>          }<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>          default: {<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>            assert state.callCount &gt; 1;<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>            if (state.replicaErrors == null) {<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>              state.replicaErrors = new BatchErrors();<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>            }<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>            target = state.replicaErrors;<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>            break;<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>          }<a name="line.1507"></a>
 <span class="sourceLineNo">1508</span>        }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>        // See setResult for explanations.<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        synchronized (replicaResultLock) {<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>          if (results[index] != state) {<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>            throw new AssertionError("We set the callCount but someone else replaced the result");<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>          }<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>          results[index] = throwable;<a name="line.1514"></a>
+<span class="sourceLineNo">1509</span>        --state.callCount;<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>      }<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>      target.add(throwable, row, server);<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>      if (isActionDone) {<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>        if (state.replicaErrors != null) { // last call, no need to lock<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>          errors.merge(state.replicaErrors);<a name="line.1514"></a>
 <span class="sourceLineNo">1515</span>        }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>        decActionCounter(index);<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>      }<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>    }<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span><a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>    /**<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>     * Checks if the action is complete; used on error to prevent needless retries.<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>     * Does not synchronize, assuming element index/field accesses are atomic.<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>     * This is an opportunistic optimization check, doesn't have to be strict.<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>     * @param index Original action index.<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>     * @param row Original request.<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>     */<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>    private boolean isActionComplete(int index, Row row) {<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>      if (!isReplicaGet(row)) return false;<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>      Object resObj = results[index];<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>      return (resObj != null) &amp;&amp; (!(resObj instanceof ReplicaResultState)<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>          || ((ReplicaResultState)resObj).callCount == 0);<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>    }<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span><a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    /**<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>     * Tries to set the result or error for a particular action as if there were no replica calls.<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>     * @return null if successful; replica state if there were in fact replica calls.<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>     */<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>    private ReplicaResultState trySetResultSimple(int index, Row row, boolean isError,<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        Object result, ServerName server, boolean isFromReplica) {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>      Object resObj = null;<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>      if (!isReplicaGet(row)) {<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>        if (isFromReplica) {<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>          throw new AssertionError("Unexpected stale result for " + row);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>        }<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>        results[index] = result;<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>      } else {<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>        synchronized (replicaResultLock) {<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>          resObj = results[index];<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>          if (resObj == null) {<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>            if (isFromReplica) {<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>              throw new AssertionError("Unexpected stale result for " + row);<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>            }<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>            results[index] = result;<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>          }<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>        }<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>      }<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span><a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>      ReplicaResultState rrs =<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>          (resObj instanceof ReplicaResultState) ? (ReplicaResultState)resObj : null;<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>      if (rrs == null &amp;&amp; isError) {<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>        // The resObj is not replica state (null or already set).<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>        errors.add((Throwable)result, row, server);<a name="line.1562"></a>
+<span class="sourceLineNo">1516</span>        // See setResult for explanations.<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>        synchronized (replicaResultLock) {<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>          if (results[index] != state) {<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>            throw new AssertionError("We set the callCount but someone else replaced the result");<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>          }<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>          results[index] = throwable;<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>        }<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>        decActionCounter(index);<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>      }<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>    }<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span><a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>    /**<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>     * Checks if the action is complete; used on error to prevent needless retries.<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>     * Does not synchronize, assuming element index/field accesses are atomic.<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>     * This is an opportunistic optimization check, doesn't have to be strict.<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>     * @param index Original action index.<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>     * @param row Original request.<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>     */<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>    private boolean isActionComplete(int index, Row row) {<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>      if (!isReplicaGet(row)) return false;<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>      Object resObj = results[index];<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>      return (resObj != null) &amp;&amp; (!(resObj instanceof ReplicaResultState)<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span>          || ((ReplicaResultState)resObj).callCount == 0);<a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>    }<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span><a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>    /**<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>     * Tries to set the result or error for a particular action as if there were no replica calls.<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>     * @return null if successful; replica state if there were in fact replica calls.<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>     */<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>    private ReplicaResultState trySetResultSimple(int index, Row row, boolean isError,<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>        Object result, ServerName server, boolean isFromReplica) {<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span>      Object resObj = null;<a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>      if (!isReplicaGet(row)) {<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>        if (isFromReplica) {<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>          throw new AssertionError("Unexpected stale result for " + row);<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>        }<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>        results[index] = result;<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span>      } else {<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>        synchronized (replicaResultLock) {<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>          resObj = results[index];<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>          if (resObj == null) {<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>            if (isFromReplica) {<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>              throw new AssertionError("Unexpected stale result for " + row);<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>            }<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>            results[index] = result;<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>          }<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>        }<a name="line.1562"></a>
 <span class="sourceLineNo">1563</span>      }<a name="line.1563"></a>
 <span class="sourceLineNo">1564</span><a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      if (resObj == null) {<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>        // resObj is null - no replica calls were made.<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>        decActionCounter(index);<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>        return null;<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>      }<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>      return rrs;<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>    }<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span><a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>    private void decActionCounter(int index) {<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      long actionsRemaining = actionsInProgress.decrementAndGet();<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      if (actionsRemaining &lt; 0) {<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>        String error = buildDetailedErrorMsg("Incorrect actions in progress", index);<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>        throw new AssertionError(error);<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>      } else if (actionsRemaining == 0) {<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>        synchronized (actionsInProgress) {<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>          actionsInProgress.notifyAll();<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        }<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>      }<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>    }<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span><a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>    private String buildDetailedErrorMsg(String string, int index) {<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>      StringBuilder error = new StringBuilder(128);<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>      error.append(string).append("; called for ").append(index).append(", actionsInProgress ")<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>          .append(actionsInProgress.get()).append("; replica gets: ");<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>      if (replicaGetIndices != null) {<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>        for (int i = 0; i &lt; replicaGetIndices.length; ++i) {<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>          error.append(replicaGetIndices[i]).append(", ");<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>        }<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>      } else {<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>        error.append(hasAnyReplicaGets ? "all" : "none");<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>      }<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>      error.append("; results ");<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>      if (results != null) {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>        for (int i = 0; i &lt; results.length; ++i) {<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>          Object o = results[i];<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>          error.append(((o == null) ? "null" : o.toString())).append(", ");<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>        }<a name="line.1601"></a>
+<span class="sourceLineNo">1565</span>      ReplicaResultState rrs =<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>          (resObj instanceof ReplicaResultState) ? (ReplicaResultState)resObj : null;<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>      if (rrs == null &amp;&amp; isError) {<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>        // The resObj is not replica state (null or already set).<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>        errors.add((Throwable)result, row, server);<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span>      }<a name="line.1570"></a>
+<span class="sourceLineNo">1571</span><a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>      if (resObj == null) {<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>        // resObj is null - no replica calls were made.<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span>        decActionCounter(index);<a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>        return null;<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>      }<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>      return rrs;<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>    }<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span><a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>    private void decActionCounter(int index) {<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>      long actionsRemaining = actionsInProgress.decrementAndGet();<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>      if (actionsRemaining &lt; 0) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>        String error = buildDetailedErrorMsg("Incorrect actions in progress", index);<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>        throw new AssertionError(error);<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>      } else if (actionsRemaining == 0) {<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>        synchronized (actionsInProgress) {<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>          actionsInProgress.notifyAll();<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>        }<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>      }<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>    }<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span><a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>    private String buildDetailedErrorMsg(String string, int index) {<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>      StringBuilder error = new StringBuilder(128);<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>      error.append(string).append("; called for ").append(index).append(", actionsInProgress ")<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>          .append(actionsInProgress.get()).append("; replica gets: ");<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>      if (replicaGetIndices != null) {<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>        for (int i = 0; i &lt; replicaGetIndices.length; ++i) {<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>          error.append(replicaGetIndices[i]).append(", ");<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>        }<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>      } else {<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>        error.append(hasAnyReplicaGets ? "all" : "none");<a name="line.1601"></a>
 <span class="sourceLineNo">1602</span>      }<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>      return error.toString();<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>    }<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span><a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>    @Override<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>    public void waitUntilDone() throws InterruptedIOException {<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>      try {<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>        waitUntilDone(Long.MAX_VALUE);<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      } catch (InterruptedException iex) {<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>        throw new InterruptedIOException(iex.getMessage());<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>      } finally {<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>        if (callsInProgress != null) {<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>          for (MultiServerCallable&lt;Row&gt; clb : callsInProgress) {<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>            clb.cancel();<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>          }<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>        }<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      }<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>    }<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span><a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>    private boolean waitUntilDone(long cutoff) throws InterruptedException {<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>      boolean hasWait = cutoff != Long.MAX_VALUE;<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>      long lastLog = EnvironmentEdgeManager.currentTime();<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>      long currentInProgress;<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>      while (0 != (currentInProgress = actionsInProgress.get())) {<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>        long now = EnvironmentEdgeManager.currentTime();<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>        if (hasWait &amp;&amp; (now * 1000L) &gt; cutoff) {<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>          return false;<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>        }<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>        if (!hasWait) { // Only log if wait is infinite.<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>          if (now &gt; lastLog + 10000) {<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>            lastLog = now;<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>            LOG.info("#" + id + ", waiting for " + currentInProgress + "  actions to finish");<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>          }<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>        }<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>        synchronized (actionsInProgress) {<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>          if (actionsInProgress.get() == 0) break;<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>          if (!hasWait) {<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>            actionsInProgress.wait(100);<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>          } else {<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>            long waitMicroSecond = Math.min(100000L, (cutoff - now * 1000L));<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>            TimeUnit.MICROSECONDS.timedWait(actionsInProgress, waitMicroSecond);<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>          }<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>        }<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>      }<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>      return true;<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>    }<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span><a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>    @Override<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>    public boolean hasError() {<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>      return errors.hasErrors();<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>    }<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span><a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>    @Override<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>    public List&lt;? extends Row&gt; getFailedOperations() {<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>      return errors.actions;<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>    }<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span><a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>    @Override<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>    public RetriesExhaustedWithDetailsException getErrors() {<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>      return errors.makeException();<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>    }<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span><a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>    @Override<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>    public Object[] getResults() throws InterruptedIOException {<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>      waitUntilDone();<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>      return results;<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    }<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>  }<a name="line.1669"></a>
+<span class="sourceLineNo">1603</span>      error.append("; results ");<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>      if (results != null) {<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>        for (int i = 0; i &lt; results.length; ++i) {<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>          Object o = results[i];<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>          error.append(((o == null) ? "null" : o.toString())).append(", ");<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>        }<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>      }<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>      return error.toString();<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>    }<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span><a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>    @Override<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>    public void waitUntilDone() throws InterruptedIOException {<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>      try {<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>        waitUntilDone(Long.MAX_VALUE);<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>      } catch (InterruptedException iex) {<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>        throw new InterruptedIOException(iex.getMessage());<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>      } finally {<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>        if (callsInProgress != null) {<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>          for (MultiServerCallable&lt;Row&gt; clb : callsInProgress) {<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span>            clb.cancel();<a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>          }<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>        }<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>      }<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>    }<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span><a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>    private boolean waitUntilDone(long cutoff) throws InterruptedException {<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span>      boolean hasWait = cutoff != Long.MAX_VALUE;<a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>      long lastLog = EnvironmentEdgeManager.currentTime();<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>      long currentInProgress;<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>      while (0 != (currentInProgress = actionsInProgress.get())) {<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>        long now = EnvironmentEdgeManager.currentTime();<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>        if (hasWait &amp;&amp; (now * 1000L) &gt; cutoff) {<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>          return false;<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>        }<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>        if (!hasWait) { // Only log if wait is infinite.<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>          if (now &gt; lastLog + 10000) {<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>            lastLog = now;<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>            LOG.info("#" + id + ", waiting for " + currentInProgress + "  actions to finish");<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>          }<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>        }<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>        synchronized (actionsInProgress) {<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>          if (actionsInProgress.get() == 0) break;<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>          if (!hasWait) {<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>            actionsInProgress.wait(100);<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>          } else {<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>            long waitMicroSecond = Math.min(100000L, (cutoff - now * 1000L));<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>            TimeUnit.MICROSECONDS.timedWait(actionsInProgress, waitMicroSecond);<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>          }<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>        }<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>      }<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>      return true;<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>    }<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span><a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>    @Override<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>    public boolean hasError() {<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>      return errors.hasErrors();<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span>    }<a name="line.1659"></a>
+<span class="sourceLineNo">1660</span><a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>    @Override<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>    public List&lt;? extends Row&gt; getFailedOperations() {<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>      return errors.actions;<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>    }<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span><a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>    @Override<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span>    public RetriesExhaustedWithDetailsException getErrors() {<a name="line.1667"></a>
+<span class="sourceLineNo">1668</span>      return errors.makeException();<a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>    }<a name="line.1669"></a>
 <span class="sourceLineNo">1670</span><a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>  @VisibleForTesting<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>  /** Create AsyncRequestFuture. Isolated to be easily overridden in the tests. */<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>  protected &lt;CResult&gt; AsyncRequestFutureImpl&lt;CResult&gt; createAsyncRequestFuture(<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>      TableName tableName, List&lt;Action&lt;Row&gt;&gt; actions, long nonceGroup, ExecutorService pool,<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>      Batch.Callback&lt;CResult&gt; callback, Object[] results, boolean needResults) {<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>    return new AsyncRequestFutureImpl&lt;CResult&gt;(<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>        tableName, actions, nonceGroup, getPool(pool), needResults, results, callback);<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>  }<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span><a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>  /**<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>   * Create a callable. Isolated to be easily overridden in the tests.<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>   */<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>  @VisibleForTesting<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>  protected MultiServerCallable&lt;Row&gt; createCallable(final ServerName server,<a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>      TableName tableName, final MultiAction&lt;Row&gt; multi) {<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    return new MultiServerCallable&lt;Row&gt;(connection, tableName, server, this.rpcFactory, multi);<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>  }<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span><a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>  /**<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>   * Create a caller. Isolated to be easily overridden in the tests.<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>   */<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>  @VisibleForTesting<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>  protected RpcRetryingCaller&lt;MultiResponse&gt; createCaller(MultiServerCallable&lt;Row&gt; callable) {<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>    return rpcCallerFactory.&lt;MultiResponse&gt; newCaller();<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>  }<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span><a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>  @VisibleForTesting<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>  /** Waits until all outstanding tasks are done. Used in tests. */<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>  void waitUntilDone() throws InterruptedIOException {<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>    waitForMaximumCurrentTasks(0);<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>  }<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span><a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>  /** Wait until the async does not have more than max tasks in progress. */<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>  private void waitForMaximumCurrentTasks(int max) throws InterruptedIOException {<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>    long lastLog = EnvironmentEdgeManager.currentTime();<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>    long currentInProgress, oldInProgress = Long.MAX_VALUE;<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>    while ((currentInProgress = this.tasksInProgress.get()) &gt; max) {<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>      if (oldInProgress != currentInProgress) { // Wait for in progress to change.<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>        long now = EnvironmentEdgeManager.currentTime();<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>        if (now &gt; lastLog + 10000) {<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>          lastLog = now;<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>          LOG.info("#" + id + ", waiting for some tasks to finish. Expected max="<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>              + max + ", tasksInProgress=" + currentInProgress);<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>        }<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>      }<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>      oldInProgress = currentInProgress;<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>      try {<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>        synchronized (this.tasksInProgress) {<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>          if (tasksInProgress.get() != oldInProgress) break;<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>          this.tasksInProgress.wait(100);<a name="line.1720"></a>
+<span class="sourceLineNo">1671</span>    @Override<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>    public Object[] getResults() throws InterruptedIOException {<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>      waitUntilDone();<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>      return results;<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>    }<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>  }<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span><a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>  @VisibleForTesting<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>  /** Create AsyncRequestFuture. Isolated to be easily overridden in the tests. */<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>  protected &lt;CResult&gt; AsyncRequestFutureImpl&lt;CResult&gt; createAsyncRequestFuture(<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>      TableName tableName, List&lt;Action&lt;Row&gt;&gt; actions, long nonceGroup, ExecutorService pool,<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>      Batch.Callback&lt;CResult&gt; callback, Object[] results, boolean needResults) {<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>    return new AsyncRequestFutureImpl&lt;CResult&gt;(<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>        tableName, actions, nonceGroup, getPool(pool), needResults, results, callback);<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>  }<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span><a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>  /**<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>   * Create a callable. Isolated to be easily overridden in the tests.<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span>   */<a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>  @VisibleForTesting<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>  protected MultiServerCallable&lt;Row&gt; createCallable(final ServerName server,<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>      TableName tableName, final MultiAction&lt;Row&gt; multi) {<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>    return new MultiServerCallable&lt;Row&gt;(connection, tableName, server, this.rpcFactory, multi);<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>  }<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span><a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>  /**<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>   * Create a caller. Isolated to be easily overridden in the tests.<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>   */<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>  @VisibleForTesting<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>  protected RpcRetryingCaller&lt;MultiResponse&gt; createCaller(MultiServerCallable&lt;Row&gt; callable) {<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>    return rpcCallerFactory.&lt;MultiResponse&gt; newCaller();<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>  }<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span><a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>  @VisibleForTesting<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>  /** Waits until all outstanding tasks are done. Used in tests. */<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>  void waitUntilDone() throws InterruptedIOException {<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>    waitForMaximumCurrentTasks(0);<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>  }<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span><a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>  /** Wait until the async does not have more than max tasks in progress. */<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>  private void waitForMaximumCurrentTasks(int max) throws InterruptedIOException {<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>    long lastLog = EnvironmentEdgeManager.currentTime();<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>    long currentInProgress, oldInProgress = Long.MAX_VALUE;<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>    while ((currentInProgress = this.tasksInProgress.get()) &gt; max) {<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>      if (oldInProgress != currentInProgress) { // Wait for in progress to change.<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>        long now = EnvironmentEdgeManager.currentTime();<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>        if (now &gt; lastLog + 10000) {<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span>          lastLog = now;<a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>          LOG.info("#" + id + ", waiting for some tasks to finish. Expected max="<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span>              + max + ", tasksInProgress=" + currentInProgress);<a name="line.1720"></a>
 <span class="sourceLineNo">1721</span>        }<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>      } catch (InterruptedException e) {<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>        throw new InterruptedIOException("#" + id + ", interrupted." +<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>            " currentNumberOfTask=" + currentInProgress);<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>      }<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>    }<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>  }<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span><a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>  /**<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>   * Only used w/useGlobalErrors ctor argument, for HTable backward compat.<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>   * @return Whether there were any errors in any request since the last time<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>   *          {@link #waitForAllPreviousOpsAndReset(List)} was called, or AP was created.<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>   */<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>  public boolean hasError() {<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>    return globalErrors.hasErrors();<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>  }<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span><a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>  /**<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>   * Only used w/useGlobalErrors ctor argument, for HTable backward compat.<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>   * Waits for all previous operations to finish, and returns errors and (optionally)<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>   * failed operations themselves.<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>   * @param failedRows an optional list into which the rows that failed since the last time<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>   *        {@link #waitForAllPreviousOpsAndReset(List)} was called, or AP was created, are saved.<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>   * @return all the errors since the last time {@link #waitForAllPreviousOpsAndReset(List)}<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>   *          was called, or AP was created.<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>   */<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>  public RetriesExhaustedWithDetailsException waitForAllPreviousOpsAndReset(<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>      List&lt;Row&gt; failedRows) throws InterruptedIOException {<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>    waitForMaximumCurrentTasks(0);<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>    if (!globalErrors.hasErrors()) {<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>      return null;<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>    }<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>    if (failedRows != null) {<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>      failedRows.addAll(globalErrors.actions);<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>    }<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>    RetriesExhaustedWithDetailsException result = globalErrors.makeException();<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>    globalErrors.clear();<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>    return result;<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>  }<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span><a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>  /**<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>   * increment the tasks counters for a given set of regions. MT safe.<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>   */<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>  protected void incTaskCounters(Collection&lt;byte[]&gt; regions, ServerName sn) {<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>    tasksInProgress.incrementAndGet();<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span><a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>    AtomicInteger serverCnt = taskCounterPerServer.get(sn);<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>    if (serverCnt == null) {<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>      taskCounterPerServer.putIfAbsent(sn, new AtomicInteger());<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>      serverCnt = taskCounterPerServer.get(sn);<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>    }<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>    serverCnt.incrementAndGet();<a name="line.1772"></a>
+<span class="sourceLineNo">1722</span>      }<a name="line.1722"></a>
+<span class="sourceLineNo">1723</span>      oldInProgress = currentInProgress;<a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>      try {<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>        synchronized (this.tasksInProgress) {<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>          if (tasksInProgress.get() != oldInProgress) break;<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>          this.tasksInProgress.wait(100);<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span>        }<a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>      } catch (InterruptedException e) {<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>        throw new InterruptedIOException("#" + id + ", interrupted." +<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>            " currentNumberOfTask=" + currentInProgress);<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>      }<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>    }<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>  }<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span><a name="line.1735"></a>
+<span class="sourceLineNo">1736</span>  /**<a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>   * Only used w/useGlobalErrors ctor argument, for HTable backward compat.<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>   * @return Whether there were any errors in any request since the last time<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>   *          {@link #waitForAllPreviousOpsAndReset(List)} was called, or AP was created.<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>   */<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>  public boolean hasError() {<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>    return globalErrors.hasErrors();<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>  }<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span><a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>  /**<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>   * Only used w/useGlobalErrors ctor argument, for HTable backward compat.<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>   * Waits for all previous operations to finish, and returns errors and (optionally)<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>   * failed operations themselves.<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>   * @param failedRows an optional list into which the rows that failed since the last time<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>   *        {@link #waitForAllPreviousOpsAndReset(List)} was called, or AP was created, are saved.<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>   * @return all the errors since the last time {@link #waitForAllPreviousOpsAndReset(List)}<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>   *          was called, or AP was created.<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>   */<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>  public RetriesExhaustedWithDetailsException waitForAllPreviousOpsAndReset(<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>      List&lt;Row&gt; failedRows) throws InterruptedIOException {<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>    waitForMaximumCurrentTasks(0);<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span>    if (!globalErrors.hasErrors()) {<a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>      return null;<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>    }<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>    if (failedRows != null) {<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>      failedRows.addAll(globalErrors.actions);<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>    }<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>    RetriesExhaustedWithDetailsException result = globalErrors.makeException();<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>    globalErrors.clear();<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>    return result;<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>  }<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span><a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>  /**<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>   * increment the tasks counters for a given set of regions. MT safe.<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>   */<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>  protected void incTaskCounters(Collection&lt;byte[]&gt; regions, ServerName sn) {<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>    tasksInProgress.incrementAndGet();<a name="line.1772"></a>
 <span class="sourceLineNo">1773</span><a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>    for (byte[] regBytes : regions) {<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>      AtomicInteger regionCnt = taskCounterPerRegion.get(regBytes);<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>      if (regionCnt == null) {<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>        regionCnt = new AtomicInteger();<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>        AtomicInteger oldCnt = taskCounterPerRegion.putIfAbsent(regBytes, regionCnt);<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>        if (oldCnt != null) {<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>          regionCnt = oldCnt;<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>        }<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>      }<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>      regionCnt.incrementAndGet();<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>    }<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>  }<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span><a name="line.1786"></a>
-<span class="sourceLineNo">1787</span>  /**<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>   * Decrements the counters for a given region and the region server. MT Safe.<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>   */<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>  protected void decTaskCounters(Collection&lt;byte[]&gt; regions, ServerName sn) {<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>    for (byte[] regBytes : regions) {<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>      AtomicInteger regionCnt = taskCounterPerRegion.get(regBytes);<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>      regionCnt.decrementAndGet();<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>    }<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span><a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>    taskCounterPerServer.get(sn).decrementAndGet();<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>    tasksInProgress.decrementAndGet();<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>    synchronized (tasksInProgress) {<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>      tasksInProgress.notifyAll();<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>    }<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>  }<a name="line.1801"></a>
+<span class="sourceLineNo">1774</span>    AtomicInteger serverCnt = taskCounterPerServer.get(sn);<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>    if (serverCnt == null) {<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>      taskCounterPerServer.putIfAbsent(sn, new AtomicInteger());<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>      serverCnt = taskCounterPerServer.get(sn);<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>    }<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>    serverCnt.incrementAndGet();<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span><a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>    for (byte[] regBytes : regions) {<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>      AtomicInteger regionCnt = taskCounterPerRegion.get(regBytes);<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>      if (regionCnt == null) {<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>        regionCnt = new AtomicInteger();<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>        AtomicInteger oldCnt = taskCounterPerRegion.putIfAbsent(regBytes, regionCnt);<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>        if (oldCnt != null) {<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>          regionCnt = oldCnt;<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>        }<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>      }<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>      regionCnt.incrementAndGet();<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    }<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span>  }<a name="line.1792"></a>
+<span class="sourceLineNo">1793</span><a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>  /**<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>   * Decrements the counters for a given region and the region server. MT Safe.<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>   */<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>  protected void decTaskCounters(Collection&lt;byte[]&gt; regions, ServerName sn) {<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>    for (byte[] regBytes : regions) {<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>      AtomicInteger regionCnt = taskCounterPerRegion.get(regBytes);<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>      regionCnt.decrementAndGet();<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>    }<a name="line.1801"></a>
 <span class="sourceLineNo">1802</span><a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>  /**<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>   * Creates the server error tracker to use inside process.<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>   * Currently, to preserve the main assumption about current retries, and to work well with<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>   * the retry-limit-based calculation, the calculation is local per Process object.<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>   * We may benefit from connection-wide tracking of server errors.<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>   * @return ServerErrorTracker to use, null if there is no ServerErrorTracker on this connection<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>   */<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>  protected ConnectionImplementation.ServerErrorTracker createServerErrorTracker() {<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>    return new ConnectionImplementation.ServerErrorTracker(<a name="line.1811"></a

<TRUNCATED>

Mime
View raw message