Skip to content

Introduce Hns and Flat strategy and integrate with GcsFileSystem#311

Open
suni72 wants to merge 15 commits into
GoogleCloudPlatform:mainfrom
suni72:dir-metadata-ops-2
Open

Introduce Hns and Flat strategy and integrate with GcsFileSystem#311
suni72 wants to merge 15 commits into
GoogleCloudPlatform:mainfrom
suni72:dir-metadata-ops-2

Conversation

@suni72

@suni72 suni72 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation

Description

What?

  • Introduces the NamespaceStrategy interface alongside FlatNamespaceStrategyImpl and HierarchicalNamespaceStrategyImpl implementations.
  • Update GcsFileSystemImpl to integrate NamespaceStrategy based on bucket HNS configuration and HNS API enable flag in core.
  • Added options in GcsFileSystemOptions to configure HNS behavior and parallel status execution.
  • Introduced LazyExecutorService, a lightweight version of Hadoop's LazyExecutorService. This will be used to execute list calls synchronously when parallel execution is disabled.

Why?

Dynamically routes folder commands based on the bucket's namespace configuration (flat vs. hierarchical).

Checklist

  • PR title follows Conventional Commits (e.g., feat(core): ...)
  • All files include the Apache License 2.0 header
  • Documentation has been updated to reflect changes

Generated/Assisted by Agent? [Yes/No]

@codecov

This comment was marked as outdated.

@gemini-code-assist

This comment was marked as outdated.

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

Copy link
Copy Markdown
Contributor

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 a bucket capabilities caching layer and namespace strategy resolution to support Hierarchical Namespace (HNS) routing and optimization. Key changes include adding BucketCapabilities, defining NamespaceStrategy with flat and hierarchical implementations, and integrating a Caffeine-backed cache with TTL in AnalyticsCacheManager. Feedback focuses on improving encapsulation and API design, specifically by removing testing-only methods from the public GcsFileSystem interface, making internal methods package-private, converting BucketCapabilities to an @AutoValue class, and simplifying a lambda expression to a method reference.

Comment thread client/src/main/java/com/google/cloud/gcs/analyticscore/client/GcsFileSystem.java Outdated
@suni72 suni72 force-pushed the dir-metadata-ops-2 branch 3 times, most recently from c507032 to c58a027 Compare June 24, 2026 10:55
@suni72 suni72 force-pushed the dir-metadata-ops-2 branch 5 times, most recently from 968794a to 0ffc941 Compare July 9, 2026 13:09
@suni72 suni72 force-pushed the dir-metadata-ops-2 branch 4 times, most recently from 5db7b68 to 70c1223 Compare July 10, 2026 12:42
@suni72 suni72 force-pushed the dir-metadata-ops-2 branch from 70c1223 to 98f664d Compare July 10, 2026 12:52
@suni72 suni72 marked this pull request as ready for review July 10, 2026 13:04
@suni72 suni72 requested a review from a team as a code owner July 10, 2026 13:04
@suni72 suni72 requested a review from dheerajsngh July 10, 2026 13:05
FlatNamespaceStrategyImpl(
GcsClient gcsClient, Supplier<ExecutorService> statusExecutorServiceSupplier) {
this.gcsClient = gcsClient;
this.statusExecutorServiceSupplier = statusExecutorServiceSupplier;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might have to think of a better name for the executor service like metadataExecutorServiceSupplier or something else.


private final Telemetry telemetry;
private final AnalyticsCacheManager cacheManager;
private final AnalyticsCacheManager.BucketPropertiesLoader bucketPropertiesProvider;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need to take this extra parameter as the input. Can you check if their is way to avoid this? why do other cache do not require this?

* Status calls (e.g., getting file info) are lightweight. A core pool size of 2 allows basic
* concurrency without significant resource overhead.
*/
private static final int DEFAULT_STATUS_CORE_POOL_SIZE = 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is not configurable by user, this is the final value. we do not need to add DEFAULT prefix.

BucketProperties properties =
cacheManager.getBucketProperties(bucketName, bucketPropertiesProvider);

if (properties.isHnsEnabled() && fileSystemOptions.isHnsApiEnabled()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The check should be the other way around.
We should first check for the flag and then properties.isHnsEnabled().
properties.isHnsEnabled() involves an api call. If the flag is not on, we should not do the extra api call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets move this implementation of LazyExecutor and test into another PR, where we implement getFileInfo where it is used. Also remove the parallel execution flag, we can introduce it during the implementation of getFileInfo


package com.google.cloud.gcs.analyticscore.client;

interface NamespaceStrategy {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The interface should not be empty. It should define the methods which will need different handling between the HNS and flat bucket otherwise the purpose of the interface is defeated.

The interface should be designed in a way such that we do not expose implementation logic, while also not duplicating logic between the two

interface NamespaceStrategy {
  FileInfo getDirectoryInfo(GcsItemId itemId) throws IOException;
  void createDirectory(StorageResourceId resourceId) throws IOException;
  void renameDirectory(GcsItemInfo srcInfo, GcsItemId dstId) throws IOException;
  void deleteDirectory(GcsItemInfo dirInfo, boolean recursive) throws IOException;
  List<FileInfo> listDirectory(GcsItemId id, GcsListOptions options) throws IOException;
  void repairImplicitDirectory(URI parentPath) throws IOException;
----
others 
}

I guess you did not add the methods here so that we do not need to unnecessarily add the empty implementations in the concrete classes.
Lets discuss which would be better approach tomorrow.
But at the very least we should have a comment that the methods will be added in the follow up PRs, else the interface looks more like a placeholder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes are unrelated to the changes in this PR. Please move them into a seperate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes do not seems to be related to the change. Send them in a seperate PR.
They are increasing review overhead by increasing the number of files to review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes do not seems to be related to the change. Send them in a seperate PR.
They are increasing review overhead by increasing the number of files to review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes do not seems to be related to the change. Send them in a seperate PR.
They are increasing review overhead by increasing the number of files to review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes do not seems to be related to the change. Send them in a seperate PR.
They are increasing review overhead by increasing the number of files to review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes do not seems to be related to the change. Send them in a seperate PR.
They are increasing review overhead by increasing the number of files to review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment as above. Move them in a seperate PR.

Comment thread CONFIGURATION.md
| Property | Description | Default Value |
| :--- | :--- | :--- |
| `analytics-core.hns.api.enable` | Controls whether the Hierarchical Namespace (HNS) API is enabled for operations. | `false` |
| `analytics-core.status.parallel.enabled` | Controls whether Cloud Storage object requests for metadata and status operations execute in parallel. | `true` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets introduce this during the implementation phase.

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