Skip to content

docs(storage): add Rapid Cache samples - #14886

Merged
sahusneha2004 merged 5 commits into
mainfrom
storage-control-rapid-cache-samples-java
Nov 10, 2026
Merged

sahusneha2004 merged 5 commits into
mainfrom
storage-control-rapid-cache-samples-java

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds Storage Control Rapid Cache samples for Java, plus an integration test and README entries.

Samples

All samples are in java-storage/samples/snippets/src/main/java/com/example/storage/control/v2/ and use StorageControlClient with the global project _.

Sample Region tag What it does
RapidCacheCreate storage_control_create_rapid_cache Creates a cache with name projects/_/buckets/{bucket}/rapidCaches/{cacheId}, zone = cacheId and cache_type = "rapid-cache-ultra". The cache ID must be the zone, and the zone must be in the bucket's region. Waits for the LRO and prints the name, cache type and state.
RapidCacheGet storage_control_get_rapid_cache Gets the cache and prints the name, zone, cache type and state.
RapidCacheList storage_control_list_rapid_caches Lists all caches in the bucket (iterateAll() handles paging) and prints each name.
RapidCacheUpdate storage_control_update_rapid_cache Sets the TTL (passed in seconds; 1 hour to 7 days) with update mask ["ttl"]. Waits for the LRO and prints the name and new TTL.
RapidCacheDisable storage_control_disable_rapid_cache Starts the disable LRO and waits for it with operation.get(), then prints the name and state.

Disable and LRO wait

The cache moves to the disabled state within seconds, but the disable LRO only finishes once the cache is fully removed, which can take over an hour. That is longer than the client's default LRO polling timeout (5 minutes). When that happens, get() throws a CancellationException even though the cache is already disabled. A comment in the sample explains this and points to RapidCacheGet to check the state.

Test (ITRapidCacheTest)

  • Setup: creates a regional bucket with hierarchical namespace and uniform bucket-level access in the zone's region, then waits 20s for bucket metadata to propagate. The zone defaults to us-central1-a and can be set with RAPID_CACHE_ZONE. The cache ID is the zone.
  • One test runs create → get → list → update → disable and checks the output:
    • create: exact cache name and cache type
    • get: name, zone, cache type and State: running
    • list: the cache name is listed
    • update: TTL: 172800 seconds
    • disable: Disabled Rapid Cache: <name> if the LRO finishes. If the client stops polling (CancellationException), the test runs get and checks State: disabled instead of failing.
  • Teardown: if the cache may still be active (for example, the test failed before disable), it starts a disable without waiting and ignores errors. It then tries to delete the bucket for up to 2 minutes, retrying on 409 (the bucket can't be deleted while the cache is being removed). If that fails, it logs the bucket name and leaves it for the stale-bucket cleanup.
  • Like ITAnywhereCacheTest, the test is skipped in CI (when JOB_TYPE is set) because the operations take a long time.

Other changes

  • java-storage/README.md: adds the five samples to the samples table (regenerated with librarian generate).
  • No dependency changes.

Validation

  • Formatting, lint, unit and sample CI checks pass.
  • The integration test passed in a live run against an allowlisted project.

b/482946642

[Generated-by: AI]

Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with an integration test. Bumps libraries-bom to 26.90.0 (storage-control 2.75.0 with RapidCache). b/482946642

[Generated-by: AI]
@sahusneha2004 sahusneha2004 added ai-generated Pull Request generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Nov 2, 2026

@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 code snippets and integration tests for managing Rapid Cache in Google Cloud Storage Control v2, including creation, retrieval, listing, updating, and disabling operations, alongside updating the necessary Maven dependencies. The review feedback focuses on improving the robustness and readability of the integration tests by moving the Rapid Cache disabling logic into the tearDown method, declaring cacheId as an instance field, and simplifying the test flow by removing the complex manual try-catch-finally block.

Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with #14529. b/482946642

[Generated-by: AI]
@sahusneha2004 sahusneha2004 changed the title feat(storage): add Rapid Cache samples docs(storage): add Rapid Cache samples Nov 2, 2026

@nidhiii-27 nidhiii-27 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.

Please regenerate java-storage/README.md via librarian generate — this is critical so merging the PR does not break the post-submit Librarian - Generate libraries check on main.

Comment thread java-storage/samples/snippets/pom.xml Resolved
Revert the samples pom.xml changes (managed automatically), rename the
create sample's zoneName parameter to cacheId, call the disable sample
directly in the test and handle the polling timeout
(CancellationException), use a positive cacheActive flag, and regenerate
java-storage/README.md with librarian. b/482946642

[Generated-by: AI]
@sahusneha2004

Copy link
Copy Markdown
Contributor Author

Thanks Nidhi! I regenerated java-storage/README.md with librarian generate (librarian v0.50.0, the version pinned in librarian.yaml), so it now lists the new Rapid Cache samples.

Co-authored by AI Agent

@sahusneha2004
sahusneha2004 marked this pull request as ready for review November 6, 2026 10:14
@sahusneha2004
sahusneha2004 requested review from a team as code owners November 6, 2026 10:14
@snippet-bot

snippet-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Match AnywhereCacheCreate by setting only the required fields (name, zone, cache type) on create. RapidCacheUpdate shows how to configure the TTL. Clarify that the disable sample's get() throws CancellationException on client polling timeout. b/482946642

[Generated-by: AI]

@nidhiii-27 nidhiii-27 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.

LGTM! Please update the PR description based on the recent changes.

@sahusneha2004

Copy link
Copy Markdown
Contributor Author

@nidhiii-27 Thanks for the review! I've updated the PR description to match the current code: the samples and what each does, the disable LRO wait behavior, the test and cleanup flow, and validation.

@sahusneha2004
sahusneha2004 merged commit e714f62 into main Nov 10, 2026
204 checks passed
@sahusneha2004
sahusneha2004 deleted the storage-control-rapid-cache-samples-java branch November 10, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull Request generated by AI storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants