Skip to content

Conversation

@priyeshkaratha
Copy link
Owner

What changes were proposed in this pull request?

Provide a one-liner summary of the changes in the PR Title field above.
It should be in the form of HDDS-1234. Short summary of the change.

Please describe your PR in detail:

  • What changes are proposed in the PR? and Why? It would be better if it is written from third person's
    perspective not just for the reviewer.
  • Provide as much context and rationale for the pull request as possible. It could be copy-paste from
    the Jira's description if the jira is well defined.
  • If it is complex code, describe the approach used to solve the issue. If possible attach design doc,
    issue investigation, github discussion, etc.

Examples of well-written pull requests:

What is the link to the Apache JIRA

Please create an issue in ASF JIRA before opening a pull request, and you need to set the title of the pull
request which starts with the corresponding JIRA issue number. (e.g. HDDS-XXXX. Fix a typo in YYY.)

(Please replace this section with the link to the Apache JIRA)

How was this patch tested?

(Please explain how this patch was tested. Ex: unit tests, manual tests, workflow run on the fork git repo.)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this.)

@gemini-code-assist
Copy link

Summary of Changes

Hello @priyeshkaratha, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This PR introduces and integrates 'replicated size' into Apache Ozone's Recon service. It adds a replicatedSizeOfFiles field to the NSSummary data structure, updates the logic for calculating and propagating this metric through the directory hierarchy, and modifies API endpoints to expose it. A new upgrade action ensures that existing deployments correctly populate this field upon upgrade. Comprehensive tests have been added or updated to validate the new functionality across different replication configurations.

Highlights

  • Intent: This pull request introduces the concept of 'replicated size' to Recon's namespace summary (NSSummary) and related insights. The goal is to provide accurate storage usage metrics that account for data replication, alongside the existing unreplicated data size.
  • Key Changes: The core change involves adding a replicatedSizeOfFiles field to the NSSummary data structure and updating all relevant logic in Recon to correctly calculate, persist, and expose this new metric. This includes modifications to how NSSummaries are built, updated, serialized, and queried. An upgrade action is also introduced to ensure existing deployments correctly populate this new field upon upgrade.
  • Detailed Changes: 1. NSSummary and Codec: A new replicatedSizeOfFiles field was added to NSSummary.java, along with corresponding constructors, getters, and setters. The NSSummaryCodec.java was updated to serialize and deserialize this new field, ensuring its persistence.
  1. NSSummary Task Event Handler: NSSummaryTaskDbEventHandler.java was modified to track and propagate replicatedSizeOfFiles changes up the directory hierarchy during key and directory put/delete events. The propagateSizeUpwards method now accepts and updates replicated size.
  2. API Endpoints: OMDBInsightEndpoint.java was updated to retrieve and expose both unreplicated and replicated sizes for deleted directories. FSOBucketHandler.java was simplified to directly use the aggregated replicatedSizeOfFiles from NSSummary for calculating disk usage under an object.
  3. Upgrade Action: A new ReconLayoutFeature.REPLICATED_SIZE_OF_FILES (version 4) was added, along with a ReplicatedSizeOfFilesUpgradeAction.java. This upgrade action triggers a full rebuild of the NSSummary tree during finalization, ensuring that the new replicatedSizeOfFiles field is correctly populated for all existing data.
  4. Testing Enhancements: Integration tests (TestReconInsightsForDeletedDirectories.java, TestOmDBInsightEndPoint.java, TestNSSummaryTaskWithFSO.java) were updated to be parameterized with various replication configurations (RATIS, EC) and include assertions for the new replicatedSizeOfFiles and replicatedDataSize metrics. Helper methods in TestDataUtil.java were extended to support specifying replication configurations during bucket creation for tests. A new unit test (TestReplicatedSizeOfFilesUpgradeAction.java) was added to verify the upgrade action's functionality.
  • Testing: The changes are covered by extensive unit and integration tests. Existing tests for Recon insights and NSSummary functionality were enhanced to include assertions for the new replicated size metric across various replication types (RATIS, EC). A dedicated test was added for the upgrade action to ensure proper NSSummary rebuild.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the replicatedSizeOfFiles field to NSSummary to track replicated data size, which is a significant enhancement for accurate disk usage reporting. The changes are well-integrated across the data model, serialization, business logic, and API endpoints. The tests have been effectively updated and parameterized to cover different replication configurations, which is great. I've identified a potential NullPointerException and a minor logging issue that should be addressed. Overall, this is a solid contribution.

}
return totalDU;
.getNSSummary(parentId);
return nsSummary.getReplicatedSizeOfFiles();

Choose a reason for hiding this comment

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

high

nsSummary can be null if getNSSummary(parentId) returns null (e.g., for an empty or unprocessed directory). This would cause a NullPointerException when nsSummary.getReplicatedSizeOfFiles() is called. A null check is needed to prevent this.

Suggested change
return nsSummary.getReplicatedSizeOfFiles();
return nsSummary != null ? nsSummary.getReplicatedSizeOfFiles() : 0L;

if (result != ReconTaskController.ReInitializationResult.SUCCESS) {
LOG.error(
"Failed to queue reinitialization event for manual trigger (result: {}), failing the reinitialization " +
"during NSSummaryAggregatedTotalsUpgrade action, will be retried as part of syncDataFromOM " +

Choose a reason for hiding this comment

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

medium

The log message seems to contain a copy-paste error. It mentions NSSummaryAggregatedTotalsUpgrade action, but this code is in ReplicatedSizeOfFilesUpgradeAction. This could be confusing during debugging. Please correct the action name in the log message.

Suggested change
"during NSSummaryAggregatedTotalsUpgrade action, will be retried as part of syncDataFromOM " +
"during ReplicatedSizeOfFilesUpgradeAction, will be retried as part of syncDataFromOM " +

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.

3 participants