Russole commented on code in PR #9935:
URL: https://github.com/apache/ozone/pull/9935#discussion_r3035389827
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -210,53 +203,64 @@ public Response get(
String lastKey = null;
int count = 0;
if (maxKeys > 0) {
- while (ozoneKeyIterator != null && ozoneKeyIterator.hasNext()) {
- OzoneKey next = ozoneKeyIterator.next();
- if (bucket != null && bucket.getBucketLayout().isFileSystemOptimized()
&&
- StringUtils.isNotEmpty(prefix) &&
- !next.getName().startsWith(prefix)) {
- // prefix has delimiter but key don't have
- // example prefix: dir1/ key: dir123
- continue;
- }
- if (startAfter != null && count == 0 && Objects.equals(startAfter,
next.getName())) {
- continue;
- }
- String relativeKeyName = next.getName().substring(prefix.length());
-
- int depth = StringUtils.countMatches(relativeKeyName, delimiter);
- if (!StringUtils.isEmpty(delimiter)) {
- if (depth > 0) {
- // means key has multiple delimiters in its value.
- // ex: dir/dir1/dir2, where delimiter is "/" and prefix is dir/
- String dirName = relativeKeyName.substring(0, relativeKeyName
- .indexOf(delimiter));
- if (!dirName.equals(prevDir)) {
- response.addPrefix(EncodingTypeObject.createNullable(
- prefix + dirName + delimiter, encodingType));
- prevDir = dirName;
+ try {
+ while (ozoneKeyIterator != null && ozoneKeyIterator.hasNext()) {
+ OzoneKey next = ozoneKeyIterator.next();
+ if (bucket != null &&
bucket.getBucketLayout().isFileSystemOptimized() &&
+ StringUtils.isNotEmpty(prefix) &&
+ !next.getName().startsWith(prefix)) {
+ // prefix has delimiter but key don't have
+ // example prefix: dir1/ key: dir123
+ continue;
+ }
+ if (startAfter != null && count == 0 && Objects.equals(startAfter,
next.getName())) {
+ continue;
+ }
+ String relativeKeyName = next.getName().substring(prefix.length());
+
+ int depth = StringUtils.countMatches(relativeKeyName, delimiter);
+ if (!StringUtils.isEmpty(delimiter)) {
+ if (depth > 0) {
+ // means key has multiple delimiters in its value.
+ // ex: dir/dir1/dir2, where delimiter is "/" and prefix is dir/
+ String dirName = relativeKeyName.substring(0, relativeKeyName
+ .indexOf(delimiter));
+ if (!dirName.equals(prevDir)) {
+ response.addPrefix(EncodingTypeObject.createNullable(
+ prefix + dirName + delimiter, encodingType));
+ prevDir = dirName;
+ count++;
+ }
+ } else if (relativeKeyName.endsWith(delimiter)) {
+ // means or key is same as prefix with delimiter at end and ends
with
+ // delimiter. ex: dir/, where prefix is dir and delimiter is /
+ response.addPrefix(
+ EncodingTypeObject.createNullable(relativeKeyName,
encodingType));
+ count++;
+ } else {
+ // means our key is matched with prefix if prefix is given and it
+ // does not have any common prefix.
+ addKey(response, next);
count++;
}
- } else if (relativeKeyName.endsWith(delimiter)) {
- // means or key is same as prefix with delimiter at end and ends
with
- // delimiter. ex: dir/, where prefix is dir and delimiter is /
- response.addPrefix(
- EncodingTypeObject.createNullable(relativeKeyName,
encodingType));
- count++;
} else {
- // means our key is matched with prefix if prefix is given and it
- // does not have any common prefix.
addKey(response, next);
count++;
}
- } else {
- addKey(response, next);
- count++;
- }
- if (count == maxKeys) {
- lastKey = next.getName();
- break;
+ if (count == maxKeys) {
+ lastKey = next.getName();
+ break;
+ }
+ }
+ } catch (RuntimeException ex) {
+ getMetrics().updateGetBucketFailureStats(startNanos);
+ auditReadFailure(s3GAction, ex);
+ if (ex.getCause() instanceof OMException) {
+ final OMException omException = (OMException) ex.getCause();
+ handleOMException(omException, bucketName, prefix);
+ } else {
Review Comment:
The comment for `ResultCodes.FILE_NOT_FOUND` says "continue and send normal
response with 0 keyCount", which makes sense for the outer case (before
iteration starts).
However, in the new iterator-side runtime path, `FILE_NOT_FOUND` will stop
the loop and return the current response.
So the semantics seem different. Should iterator-side `FILE_NOT_FOUND`
really be treated the same way?
--
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]