samples(bigtable): migrate all admin snippets and tests to modern V2 clients#13392
samples(bigtable): migrate all admin snippets and tests to modern V2 clients#13392jinseopkim0 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates Bigtable samples and tests to use the newer BigtableTableAdminClientV2 and BigtableInstanceAdminClientV2 clients along with direct protobuf-generated request and model classes. The review feedback identifies several important issues: potential resource leaks due to unclosed InputStream instances in SchemaBundleExample.java, an inverted assertion logic in InstanceAdminExampleTest.java that should use assertThrows to verify cluster deletion, and opportunities to optimize table existence checks across multiple files by requesting a NAME_ONLY view. Additionally, it is recommended to simplify column family checks in TableAdminExampleTest.java using containsKey.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates several Google Cloud Bigtable sample snippets and tests to use the newer BigtableTableAdminClientV2 and BigtableInstanceAdminClientV2 APIs, replacing deprecated client classes and updating resource path structures. Feedback on the changes suggests optimizing the table existence check in HelloWorldTest.java by using the NAME_ONLY view to avoid fetching full metadata, and improving resource efficiency in DeletesTest.java by sharing a single client instance across tests instead of recreating it inside individual test methods.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates various Cloud Bigtable Java samples and snippets from the deprecated BigtableTableAdminClient and BigtableInstanceAdminClient to the newer BigtableTableAdminClientV2 and BigtableInstanceAdminClientV2. This migration includes updating the creation, retrieval, listing, and deletion of tables, instances, clusters, authorized views, and schema bundles, as well as replacing the client-side .exists() helper methods with explicit getTable/getInstance calls. The review feedback highlights opportunities to prevent resource leaks in tests by ensuring exception-safe cleanup of bigtableDataClient, and recommends using strongly-typed SDK helper classes (such as TableName, AuthorizedViewName, and SchemaBundleName) instead of manual string concatenation and parsing for resource names.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request migrates the Bigtable admin samples and tests from the legacy BigtableTableAdminClient and BigtableInstanceAdminClient to the newer BigtableTableAdminClientV2 and BigtableInstanceAdminClientV2 APIs. It replaces model-based wrappers with direct protobuf request builders for table, instance, authorized view, and schema bundle operations, and implements custom exists checks using getTable or getInstance calls. There are no review comments to address, and I have no additional feedback to provide.
This PR migrates all remaining admin-related snippets and tests under
java-bigtable/samples/snippetsto utilize the modernBigtableTableAdminClientV2andBigtableInstanceAdminClientV2, fully phasing out legacy V1 admin clients and.getBaseClient()references.Migrated Samples & Tests:
HelloWorld.java&HelloWorldTest.javaInstanceAdminExample.java&InstanceAdminExampleTest.javaTableAdminExample.java&TableAdminExampleTest.javaAuthorizedViewExample.java&AuthorizedViewExampleTest.javaSchemaBundleExample.java&SchemaBundleExampleTest.javaQuickstartTest.javaMobileTimeSeriesBaseTest.javadeletes/DeleteTableExample.javadeletes/DeleteColumnFamilyExample.javadeletes/DropRowRangeExample.javadeletes/DeletesTest.javaKey Improvements:
.getBaseClient()escape-hatch calls..exists(...)andexists(tableId)calls with V2getTable/getInstancetry-catch blocks.SubsetViewandFamilySubsetsto use the V2 protobuf-generated inner classesAuthorizedView.SubsetViewandAuthorizedView.FamilySubsets.ProtoSchemawrapper when building and parsing schema bundles inSchemaBundleExample.java.table.getColumnFamiliesMap(), completely eliminating legacy custom Truth correspondence helpers.All files are formatted using
spotify:fmtand compile cleanly (BUILD SUCCESS).