Skip to content

Commit 0ec2a58

Browse files
author
Daniel Roudnitsky
committed
HBASE-28771 Refactor AsyncRequestFutureImpl.isActionComplete to support non replica actions
1 parent 68045db commit 0ec2a58

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ Retry manageError(int originalIndex, Row row, Retry canRetry, Throwable throwabl
731731
if (canRetry != Retry.YES) {
732732
// Batch.Callback<Res> was not called on failure in 0.94. We keep this.
733733
setError(originalIndex, row, throwable, server);
734-
} else if (isActionComplete(originalIndex, row)) {
734+
} else if (AsyncProcess.isReplicaGet(row) && isActionComplete(originalIndex)) {
735735
canRetry = Retry.NO_OTHER_SUCCEEDED;
736736
}
737737
return canRetry;
@@ -1164,10 +1164,16 @@ private void setError(int index, Row row, Throwable throwable, ServerName server
11641164
* synchronize, assuming element index/field accesses are atomic. This is an opportunistic
11651165
* optimization check, doesn't have to be strict.
11661166
* @param index Original action index.
1167-
* @param row Original request.
1167+
* @return If results are non-null, returns whether a result is currently set for action index.
1168+
* @throws IllegalStateException If results are null. We cannot readily tell here whether an
1169+
* action that is part of an AsyncRequestFuture that doesn't track
1170+
* results is complete
11681171
*/
1169-
private boolean isActionComplete(int index, Row row) {
1170-
if (!AsyncProcess.isReplicaGet(row)) return false;
1172+
private boolean isActionComplete(int index) {
1173+
if (results == null) {
1174+
throw new IllegalStateException(
1175+
String.format("Cannot check action %d completion when results are null", index));
1176+
}
11711177
Object resObj = results[index];
11721178
return (resObj != null)
11731179
&& (!(resObj instanceof ReplicaResultState) || ((ReplicaResultState) resObj).callCount == 0);

0 commit comments

Comments
 (0)