michaeljmarshall opened a new pull request #13639:
URL: https://github.com/apache/pulsar/pull/13639
### Motivation
The `ResourceUsage` class can easily be made immutable. Since it is possibly
shared across threads, it is safer to make it immutable. As a benefit, we can
calculate the `percentUsage` exactly one time, and because we compute the
`percentUsage` for metrics, this should be a slight cpu optimization.
### Modifications
* Make `usage` and `limit` fields `final`
* Remove unnecessary `ResourceUsage#reset` method
* Remove the `ResourceUsage` constructor that was only used to copy objects
* Update the few places that were modifying the internal values of the
`ResourceUsage` class. Note that most of these were for tests. There is one
place where we needed to add an extra object creation step in the
`SimpleLoadManagerImpl`
### Verifying this change
This change is a trivial rework of the code, and it is well covered by
tests. Once the tests pass, I will have high confidence in the correctness of
this change.
### Does this pull request potentially affect one of the following parts:
This is an internal change.
### Documentation
- [x] `no-need-doc`
This change is internal, so there is no need to have external docs for it.
--
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]