Skip to content

Conversation

@Gargi-jais11
Copy link
Contributor

@Gargi-jais11 Gargi-jais11 commented Aug 19, 2025

What changes were proposed in this pull request?

1. Improve data structures and type safety :

  • In DiskBalancerService, use ContainerID instead of Long for container id.
  • Use Objects.requireNonNull(..) instead of Preconditions.checkNotNull(..).
  • In DiskBalancerService do not throw RuntimeException instead throw IOException.
  • Use StorageVolume.TMP_DIR_NAME to replace DiskBalancerService.DISK_BALANCER_TMP_DIR.
  • In DefaultVolumeChoosingPolicy.chooseVolume(..), getCurrentUsage() is called multiple times so it can return different values.

2. Replace the use of Optional for method parameters in DiskBalancer:
As a general rule, parameters should be explicitly required or nullable, not wrapped in an Optional. For context, see: https://www.reddit.com/r/java/comments/sat1j4/opinions_on_using_optional_as_parameter/

3. Cleanup of Dead Code:

  • Remove the new Container.importContainerData(Path containerPath) method since it is never used.
  • Rename Container.copyContainerData to copyContainerDirectory. As, it sounds like copy/import the ContainerData class.
  • SlidingWindow and TestSlidingWindow remove since unused.

4. parameterize disk balancer related unit tests with different container schema versions.

What is the link to the Apache JIRA

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

How was this patch tested?

Passed Existing Tests.

@Gargi-jais11 Gargi-jais11 marked this pull request as ready for review August 19, 2025 07:33
@ChenSammi
Copy link
Contributor

ChenSammi commented Aug 19, 2025

Hi @Gargi-jais11 , it looks like there are a few comments missed to be addressed.

  1. Use StorageVolume.TMP_DIR_NAME to replace DiskBalancerService.DISK_BALANCER_TMP_DIR
    • In DiskBalancerService, use ContainerID instead of Long for container id.
    • In DefaultVolumeChoosingPolicy.chooseVolume(..), getCurrentUsage() is called multiple times so it can return different values.
  2. SlidingWindow and TestSlidingWindow, what's the usage of SlidingWindow here?

@ChenSammi
Copy link
Contributor

Forgot one, parameterize disk balancer related unit tests with different container schema versions.
You can refer to TestBlockDeletingService.java, mainly using "@ContainerTestVersionInfo.ContainerTest" to achieve that.

@Gargi-jais11
Copy link
Contributor Author

Gargi-jais11 commented Aug 19, 2025

Hi @Gargi-jais11 , it looks like there are a few comments missed to be addressed.

  1. Use StorageVolume.TMP_DIR_NAME to replace DiskBalancerService.DISK_BALANCER_TMP_DIR
    • In DiskBalancerService, use ContainerID instead of Long for container id.
    • In DefaultVolumeChoosingPolicy.chooseVolume(..), getCurrentUsage() is called multiple times so it can return different values.

Correct. Thank you for pointing out.

  1. SlidingWindow and TestSlidingWindow, what's the usage of SlidingWindow here?

Related to this I need to check where it is used.
It seems to be added by me during recent rebase but don't have idea how it got added. I will remove these two classes.

@Gargi-jais11 Gargi-jais11 requested a review from ChenSammi August 20, 2025 07:14
Copy link
Contributor

@ChenSammi ChenSammi left a comment

Choose a reason for hiding this comment

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

Thanks @Gargi-jais11 .

@ChenSammi ChenSammi merged commit fd3823a into apache:HDDS-5713 Aug 20, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants