Repository navigation
docs(storage): add Rapid Cache samples - #14886
Conversation
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]
There was a problem hiding this comment.
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]
nidhiii-27
left a comment
There was a problem hiding this comment.
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.
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]
|
Thanks Nidhi! I regenerated java-storage/README.md with Co-authored by AI Agent |
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
left a comment
There was a problem hiding this comment.
LGTM! Please update the PR description based on the recent changes.
|
@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. |
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 useStorageControlClientwith the global project_.RapidCacheCreatestorage_control_create_rapid_cacheprojects/_/buckets/{bucket}/rapidCaches/{cacheId},zone = cacheIdandcache_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.RapidCacheGetstorage_control_get_rapid_cacheRapidCacheListstorage_control_list_rapid_cachesiterateAll()handles paging) and prints each name.RapidCacheUpdatestorage_control_update_rapid_cache["ttl"]. Waits for the LRO and prints the name and new TTL.RapidCacheDisablestorage_control_disable_rapid_cacheoperation.get(), then prints the name and state.Disable and LRO wait
The cache moves to the
disabledstate 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 aCancellationExceptioneven though the cache is already disabled. A comment in the sample explains this and points toRapidCacheGetto check the state.Test (
ITRapidCacheTest)us-central1-aand can be set withRAPID_CACHE_ZONE. The cache ID is the zone.State: runningTTL: 172800 secondsDisabled Rapid Cache: <name>if the LRO finishes. If the client stops polling (CancellationException), the test runs get and checksState: disabledinstead of failing.ITAnywhereCacheTest, the test is skipped in CI (whenJOB_TYPEis set) because the operations take a long time.Other changes
java-storage/README.md: adds the five samples to the samples table (regenerated withlibrarian generate).Validation
b/482946642
[Generated-by: AI]