szetszwo commented on code in PR #12065:
URL: https://github.com/apache/ozone/pull/12065#discussion_r4654802410
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java:
##########
Review Comment:
Existing problem: This is incorrect since the `respFuture` is already
completed here. Calling respFuture.completeExceptionally(..) has no effect.
- It should throw CompletionException.
- Then, all the calls are just catch IOException and then throw
CompletionException. We should change validateResponse(..) to throw
CompletionException.
```diff
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
index ff6fddf071..73711414d5 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java
@@ -597,11 +597,7 @@ CompletableFuture<PutBlockResult>
executePutBlock(boolean close,
asyncReply = putBlockAsync(xceiverClient, blockData, close ||
isBlockFull, tokenString, containerAutoCreate());
CompletableFuture<ContainerCommandResponseProto> future =
asyncReply.getResponse();
flushFuture = future.thenCombineAsync(putBlockReplyHandled, (e,
ignored) -> {
- try {
- validateResponse(e);
- } catch (IOException sce) {
- throw new CompletionException(sce);
- }
+ validateResponse(e, true);
// if the ioException is not set, putBlock is successful
if (getIoException() == null && !force) {
handleSuccessfulPutBlock(e.getPutBlock().getCommittedBlockLength(),
@@ -800,21 +796,25 @@ public void close() throws IOException {
void waitOnFlushFuture() throws InterruptedException, ExecutionException {
}
- void validateResponse(
- ContainerCommandResponseProto responseProto)
- throws IOException {
+ void validateResponse(ContainerCommandResponseProto responseProto,
boolean throwCompletionException) {
try {
// if the ioException is already set, it means a prev request has
failed
// just throw the exception. The current operation will fail with the
// original error
IOException exception = getIoException();
if (exception != null) {
- throw exception;
+ if (throwCompletionException) {
+ throw new CompletionException(exception);
+ } else {
+ return;
+ }
}
ContainerProtocolCalls.validateContainerResponse(responseProto);
} catch (StorageContainerException sce) {
setIoException(sce);
- throw sce;
+ if (throwCompletionException) {
+ throw new CompletionException(sce);
+ }
}
}
@@ -966,11 +966,7 @@ private CompletableFuture<PutBlockResult>
writeChunkToContainer(
CompletableFuture<ContainerCommandResponseProto>
respFuture = asyncReply.getResponse();
validateFuture = respFuture.thenCombineAsync(putBlockReplyHandled,
(e, ignored) -> {
- try {
- validateResponse(e);
- } catch (IOException sce) {
- respFuture.completeExceptionally(sce);
- }
+ validateResponse(e, true);
// if the ioException is not set, putBlock is successful
if (getIoException() == null && putBlockPiggybacking) {
handleSuccessfulPutBlock(e.getWriteChunk().getCommittedBlockLength(),
diff --git
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
index 5f33e02f4d..0773b3d455 100644
---
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
+++
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ECBlockOutputStream.java
@@ -299,11 +299,7 @@ public CompletableFuture<PutBlockResult>
executePutBlock(boolean close,
CompletableFuture<ContainerProtos.ContainerCommandResponseProto>
future =
asyncReply.getResponse();
flushFuture = future.thenApplyAsync(e -> {
- try {
- validateResponse(e);
- } catch (IOException sce) {
- throw new CompletionException(sce);
- }
+ validateResponse(e, false);
// if the ioException is not set, putBlock is successful
if (getIoException() == null) {
BlockID responseBlockID = BlockID.getFromProtobuf(
@@ -356,22 +352,4 @@ public CompletableFuture<PutBlockResult>
executePutBlock(boolean close,
public DatanodeDetails getDatanodeDetails() {
return datanodeDetails;
}
-
- @Override
- void validateResponse(
- ContainerProtos.ContainerCommandResponseProto responseProto)
- throws IOException {
- try {
- // if the ioException is already set, it means a prev request has
failed
- // just throw the exception. The current operation will fail with the
- // original error
- IOException exception = getIoException();
- if (exception != null) {
- return;
- }
- ContainerProtocolCalls.validateContainerResponse(responseProto);
- } catch (IOException sce) {
- setIoException(sce);
- }
- }
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]