Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Reuse Ozone configuration's String conversion logic to support primitive types for query parameters.

Update BucketEndpoint#get to use getInt, tests to use setInt.

https://issues.apache.org/jira/browse/HDDS-14221

How was this patch tested?

Ran all S3 unit and integration tests locally.

CI (in progress):
https://github.com/adoroszlai/ozone/actions/runs/20394478143

@adoroszlai adoroszlai self-assigned this Dec 20, 2025
@adoroszlai adoroszlai added the s3 S3 Gateway label Dec 20, 2025
@adoroszlai adoroszlai marked this pull request as ready for review December 20, 2025 13:47
@rich7420
Copy link
Contributor

@adoroszlai Thanks for the patch!

Comment on lines +118 to +119
int maxKeys = queryParams().getInt(QueryParams.MAX_KEYS, 1000);
final int maxUploads = queryParams().getInt(QueryParams.MAX_UPLOADS, 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems here change to use getInt() not JAX-RS. should we add error hadling in getInt().

now:

default int getInt(String key, int defaultValue) {
String value = get(key);
return value != null ? Integer.parseInt(value) : defaultValue;
}

just a suggestion:

@Override
public int getInt(String key, int defaultValue) {
  String value = get(key);
  if (value == null) {
    return defaultValue;
  }
  try {
    return Integer.parseInt(value.trim());
  } catch (NumberFormatException e) {
    throw new OS3Exception(S3ErrorTable.INVALID_ARGUMENT, 
        key + " must be a valid integer");
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS3Exception is a checked exception, needs to be declared, but the interface does not allow that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can translate to WebApplicationException(400), but doing so for every type seems cumbersome. Then it may be better to create a new converter just for params, initially supporting only getInt/setInt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! I think it makes sense to me.

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1.

@ivandika3
Copy link
Contributor

ivandika3 commented Dec 21, 2025

I'm wondering whether instead of a single long method for handling PUT, GET (e.g. ObjectEndpoint#put) we can divide a single endpoint to multiple methods and let the JAX-RS implementation (Jersey) route the requests the most appropriate handlers (similar to other web frameworks like JavaScript's Express router, Minio https://github.com/minio/minio/blob/master/cmd/api-router.go that uses Gorilla router, etc). For example, for ObjectEndpoint#put, we can divide to putObject, putObjectTagging, createMultipartKey based on whether certain headers appear (e.g. ACL header, multipart header).

Not sure if there are any performance implications.

@adoroszlai adoroszlai marked this pull request as draft December 21, 2025 05:46
@adoroszlai
Copy link
Contributor Author

adoroszlai commented Dec 21, 2025

Thanks @ivandika3, @rich7420 for the review. I have updated the patch to translate to WebApplicationException(400), but stopped using ConfigurationSource, has too much unnecessary baggage for this.

I'm wondering whether instead of a single long method for handling PUT, GET (e.g. ObjectEndpoint#put) we can divide a single endpoint to multiple methods and let the JAX-RS implementation (Jersey) matcher router the most appropriate ones ... For example, for ObjectEndpoint#put, we can divide to putObject, putObjectTagging, createMultipartKey based on whether certain headers appear (e.g. ACL header, multipart header).

We do have two handlers for POST based on content type (@Consumes). I'm not very familiar with Jersey, but looking into the docs I haven't found how to do the same based on headers or query params. Would be great if it's possible.

Assuming we have to roll our own, I'd like to:

  • define handler for each request as you describe, but in separate objects
  • reduce the current long methods into a loop to delegate to the handlers

(See #9516 (review) for details.)

@adoroszlai adoroszlai marked this pull request as ready for review December 21, 2025 08:10
@rich7420
Copy link
Contributor

@adoroszlai thanks for the update! LGTM

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. LGTM +1.

@ivandika3 ivandika3 merged commit b455257 into apache:master Dec 21, 2025
55 checks passed
@ivandika3
Copy link
Contributor

Thanks @adoroszlai for the patch and @rich7420 for the review.

@rich7420
Copy link
Contributor

@adoroszlai , @ivandika3 thanks!

@adoroszlai adoroszlai deleted the HDDS-14221 branch December 22, 2025 15:45
@adoroszlai
Copy link
Contributor Author

Thanks @ivandika3, @rich7420 for the review.

echonesis pushed a commit to echonesis/ozone that referenced this pull request Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants