Skip to content

Commit

Permalink
HBASE-28771 Refactor AsyncRequestFutureImpl.isActionComplete to suppo…
Browse files Browse the repository at this point in the history
…rt non replica actions
  • Loading branch information
Daniel Roudnitsky committed Aug 7, 2024
1 parent 68045db commit 150fa2b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ Retry manageError(int originalIndex, Row row, Retry canRetry, Throwable throwabl
if (canRetry != Retry.YES) {
// Batch.Callback<Res> was not called on failure in 0.94. We keep this.
setError(originalIndex, row, throwable, server);
} else if (isActionComplete(originalIndex, row)) {
} else if (AsyncProcess.isReplicaGet(row) && isActionComplete(originalIndex)) {
canRetry = Retry.NO_OTHER_SUCCEEDED;
}
return canRetry;
Expand Down Expand Up @@ -1164,10 +1164,15 @@ private void setError(int index, Row row, Throwable throwable, ServerName server
* synchronize, assuming element index/field accesses are atomic. This is an opportunistic
* optimization check, doesn't have to be strict.
* @param index Original action index.
* @param row Original request.
* @return If results are non-null, returns whether a result is currently set for action index.
* @throws IllegalStateException If results are null. We cannot readily tell here whether an
* action that is part of an AsyncRequestFuture that doesn't track results is complete
*/
private boolean isActionComplete(int index, Row row) {
if (!AsyncProcess.isReplicaGet(row)) return false;
private boolean isActionComplete(int index) {
if (results == null) {
throw new IllegalStateException(
String.format("Cannot check action %d completion when results are null", index));
}
Object resObj = results[index];
return (resObj != null)
&& (!(resObj instanceof ReplicaResultState) || ((ReplicaResultState) resObj).callCount == 0);
Expand Down

0 comments on commit 150fa2b

Please sign in to comment.