ivandika3 commented on code in PR #10196:
URL: https://github.com/apache/ozone/pull/10196#discussion_r3195696865
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -245,8 +258,10 @@ Response handlePutRequest(ObjectRequestContext context,
String keyPath, InputStr
getHeaders().getHeaderString(S3Consts.DECODED_CONTENT_LENGTH_HEADER);
boolean hasAmzDecodedLengthZero = amzDecodedLength != null &&
Long.parseLong(amzDecodedLength) == 0;
+ boolean hasKnownZeroLength = hasAmzDecodedLengthZero ||
+ (length == 0 && (lengthHeader != null || hasCalculatedLength || body
== null));
if (canCreateDirectory &&
- (length == 0 || hasAmzDecodedLengthZero) &&
+ hasKnownZeroLength &&
StringUtils.endsWith(keyPath, "/")
Review Comment:
From what I see, the length is only need to check whether the length is 0 or
not. In that case is it possible to simply check the first byte existence?
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -198,12 +200,23 @@ Response handlePutRequest(ObjectRequestContext context,
String keyPath, InputStr
final long startNanos = context.getStartNanos();
String copyHeader = null;
+ FileBackedOutputStream spooledBody = null;
MultiDigestInputStream multiDigestInputStream = null;
try {
OzoneVolume volume = context.getVolume();
OzoneBucket bucket = context.getBucket();
final String lengthHeader =
getHeaders().getHeaderString(HttpHeaders.CONTENT_LENGTH);
+ final String rawAmzContentSha256Header =
getHeaders().getHeaderString(S3Consts.X_AMZ_CONTENT_SHA256);
+ final boolean hasMultiChunksUpload =
+ rawAmzContentSha256Header != null &&
hasMultiChunksPayload(rawAmzContentSha256Header);
+ boolean hasCalculatedLength = false;
long length = lengthHeader != null ? Long.parseLong(lengthHeader) : 0;
+ if (lengthHeader == null && body != null && !hasMultiChunksUpload) {
+ spooledBody = new FileBackedOutputStream(32);
+ length = IOUtils.copyLarge(body, spooledBody, new
byte[getIOBufferSize(0)]);
+ body = spooledBody.asByteSource().openStream();
+ hasCalculatedLength = true;
+ }
Review Comment:
If so, this might be problematic since firstly currently a lot of cluster
(including mine) assume that S3G does not have variable disk requirement (this
then require some kind of persistent volume implementation for S3G deployed in
K8s). Additionally, putting the whole object into a file and then re-reading
again might incur additional disk IO.
--
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]