Skip to content

Conversation

@adoroszlai
Copy link
Contributor

@adoroszlai adoroszlai commented Feb 5, 2024

What changes were proposed in this pull request?

Create a dedicated configurator object for setting the following properties for tests, instead of polluting MiniOzoneCluster.Builder interface:

  • blockSize
  • chunkSize
  • dataStreamBufferFlushSize
  • dataStreamMinPacketSize
  • datastreamWindowSize
  • streamBufferFlushSize
  • streamBufferMaxSize
  • streamBufferSize

The first commit in the PR (284f3ec) tries to minimize change for easier review. Follow-up commits are minor additional improvements.

Moving the default values for these properties to ozone-site.xml uncovered a problem with OzoneClientConfig construction, which is also fixed here (445db63). (See #6163 for similar fix in prod. code.)

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

How was this patch tested?

CI:
https://github.com/adoroszlai/ozone/actions/runs/7782795270

@adoroszlai adoroszlai added test code-cleanup Changes that aim to make code better, without changing functionality. labels Feb 5, 2024
@adoroszlai adoroszlai self-assigned this Feb 5, 2024
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@adoroszlai , thanks for working on this! I have to quick comments inlined.

Comment on lines 36 to 42
private OptionalLong blockSize = OptionalLong.empty();
private OptionalInt streamBufferSize = OptionalInt.empty();
private OptionalLong streamBufferFlushSize = OptionalLong.empty();
private OptionalLong dataStreamBufferFlushSize = OptionalLong.empty();
private OptionalLong dataStreamWindowSize = OptionalLong.empty();
private OptionalLong streamBufferMaxSize = OptionalLong.empty();
private OptionalInt dataStreamMinPacketSize = OptionalInt.empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also change the fields to not to use Optional. In general, it is not a good practice to use Optional as a field. See this comment by Brian Goetz (the main author of Java Concurrency in Practice).

You should almost never use it as a field of something or a method parameter.

/**
* Helper for tests that want to set client stream properties.
*/
public final class ClientConfigBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is for testing only, how about calling git ClientConfigForTesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I wasn't quite happy with the original name, but couldn't find a better one.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@adoroszlai adoroszlai merged commit 60bcdaf into apache:master Feb 6, 2024
@adoroszlai
Copy link
Contributor Author

Thanks @szetszwo for the review.

@adoroszlai adoroszlai deleted the HDDS-10292 branch February 6, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-cleanup Changes that aim to make code better, without changing functionality. test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants