peterxcli commented on code in PR #11904:
URL: https://github.com/apache/ozone/pull/11904#discussion_r4489755661
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3ObjectWriteGuard.java:
##########
@@ -77,6 +78,9 @@ private void validateBeforeCommit() throws IOException {
}
Review Comment:
```diff
---
a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3ObjectWriteGuard.java
+++
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3ObjectWriteGuard.java
@@ -46,7 +46,6 @@ class S3ObjectWriteGuard implements AutoCloseable {
private long writtenLength;
- private Throwable transferFailure;
private boolean transferComplete;
@@ -71,22 +70,10 @@ private void addCommitGuard() {
private void validateBeforeCommit() throws IOException {
- if (transferFailure != null) {
- throw new IOException(
- "S3 object transfer failed before commit: " + keyPath,
- transferFailure);
- }
- EndpointBase.validateContentLength(
- expectedLength, writtenLength, keyPath).run();
if (!transferComplete) {
throw new IOException("S3 object transfer did not complete before
commit: " + keyPath);
}
- }
-
- private void recordTransferFailure(Throwable failure) {
- if (transferFailure == null) {
- transferFailure = failure;
- }
+ EndpointBase.validateContentLength(expectedLength, writtenLength,
keyPath).run();
}
@@ -118,12 +105,7 @@
void onKeyOpened(Consumer<ByteBuffer> action) {
- try {
- action.accept(getDerivedKey());
- } catch (RuntimeException ex) {
- recordTransferFailure(ex);
- throw ex;
- }
+ action.accept(getDerivedKey());
}
@@ -131,30 +113,14 @@ long copyFrom(InputStream body, int bufferSize) throws
IOException {
- final int readLength;
- try {
- readLength = body.read(buffer, 0, toRead);
- } catch (IOException | RuntimeException ex) {
- recordTransferFailure(ex);
- throw ex;
- }
+ int readLength = body.read(buffer, 0, toRead);
if (readLength == -1) {
break;
}
- try {
- write(buffer, 0, readLength);
- } catch (IOException | RuntimeException ex) {
- recordTransferFailure(ex);
- throw ex;
- }
+ write(buffer, 0, readLength);
writtenLength += readLength;
}
- try {
- verifyChunksComplete(body);
- } catch (IOException | RuntimeException ex) {
- recordTransferFailure(ex);
- throw ex;
- }
+ verifyChunksComplete(body);
return writtenLength;
```
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3ObjectWriteGuard.java:
##########
@@ -77,6 +78,9 @@ private void validateBeforeCommit() throws IOException {
}
Review Comment:
because we now make caller to control wether to commit when cleaning up, so
I think we can remove recording the failure?
--
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]