Skip to content

samples(bigtable): migrate all admin snippets and tests to modern V2 clients#13392

Draft
jinseopkim0 wants to merge 7 commits into
mainfrom
bigtable-v2-samples
Draft

samples(bigtable): migrate all admin snippets and tests to modern V2 clients#13392
jinseopkim0 wants to merge 7 commits into
mainfrom
bigtable-v2-samples

Conversation

@jinseopkim0
Copy link
Copy Markdown
Contributor

This PR migrates all remaining admin-related snippets and tests under java-bigtable/samples/snippets to utilize the modern BigtableTableAdminClientV2 and BigtableInstanceAdminClientV2, fully phasing out legacy V1 admin clients and .getBaseClient() references.

Migrated Samples & Tests:

  • Primary Admin Samples:
    • HelloWorld.java & HelloWorldTest.java
    • InstanceAdminExample.java & InstanceAdminExampleTest.java
    • TableAdminExample.java & TableAdminExampleTest.java
  • Secondary Admin Samples:
    • AuthorizedViewExample.java & AuthorizedViewExampleTest.java
    • SchemaBundleExample.java & SchemaBundleExampleTest.java
    • QuickstartTest.java
    • MobileTimeSeriesBaseTest.java
    • deletes/DeleteTableExample.java
    • deletes/DeleteColumnFamilyExample.java
    • deletes/DropRowRangeExample.java
    • deletes/DeletesTest.java

Key Improvements:

  1. Replaced all raw .getBaseClient() escape-hatch calls.
  2. Replaced deprecated V1 .exists(...) and exists(tableId) calls with V2 getTable / getInstance try-catch blocks.
  3. Updated nested models SubsetView and FamilySubsets to use the V2 protobuf-generated inner classes AuthorizedView.SubsetView and AuthorizedView.FamilySubsets.
  4. Correctly constructed the ProtoSchema wrapper when building and parsing schema bundles in SchemaBundleExample.java.
  5. Simplified column family presence checks by directly inspecting the keys of table.getColumnFamiliesMap(), completely eliminating legacy custom Truth correspondence helpers.

All files are formatted using spotify:fmt and compile cleanly (BUILD SUCCESS).

Copy link
Copy Markdown
Contributor

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

@jinseopkim0
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

@jinseopkim0
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

@jinseopkim0
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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