Skip to content

feat(replication): map HBase table names to Cloud Bigtable table IDs - #4639

Merged
mutianf merged 1 commit into
googleapis:mainfrom
vermas2012:feat/replication-table-name-mapping
Oct 27, 2026
Merged

mutianf merged 1 commit into
googleapis:mainfrom
vermas2012:feat/replication-table-name-mapping

Conversation

@vermas2012

@vermas2012 vermas2012 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Support mapping HBase table names (such as namespaced tables like my_namespace:my_table, where : is not a valid Cloud Bigtable table ID character) to Cloud Bigtable table IDs during WAL replication via google.bigtable.replication.table_name_mapping in hbase-site.xml.

Key Details

  • Single configuration surface: Configured via google.bigtable.replication.table_name_mapping in hbase-site.xml (Configuration) using the same {"source_hbase_table": "destination_bigtable_table"} JSON structure as HBaseSchemaTranslator.
  • Fail-fast startup validation: Validated in CloudBigtableReplicator.start() before opening the Cloud Bigtable connection or incrementing SharedResources reference counts. Canonicalizes default: table names, rejects duplicate keys and N:1 mappings, and validates target table IDs against Cloud Bigtable's naming rules ([_a-zA-Z0-9][-_.a-zA-Z0-9]*, max 50 chars).
  • Reserved target collision protection: Configured mapping targets are reserved at runtime. If an unmapped HBase table's canonical name collides with a mapped target (e.g., unmapped table_B when ns:table_B -> table_B), TableNameMapper.map() throws IllegalStateException before any tasks in the batch are submitted to the executor, causing replicate() to return false and halt replication for that peer rather than writing two HBase tables into one Bigtable table.
  • Additional review fixes in CloudBigtableReplicator:
    • Decrements SharedResources reference count in start(Configuration, MetricsExporter) if initialization throws inside SharedResources.getInstance(configuration) or adapter creation.
    • Changes batchSizeInBytes and getRowSize() from int to long to avoid integer overflow.
    • Moves the per-table replicateTable() loop inside the try block in replicate() so any unexpected exception returns false per replicate()'s contract.
  • Shaded JAR verification: Verified com/google/bigtable/repackaged/com/google/gson/stream/JsonReader.class is present in both bigtable-hbase-1.x-replication and bigtable-hbase-2.x-replication shaded JARs.

@vermas2012
vermas2012 requested a review from a team as a code owner October 13, 2026 14:12
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. api: bigtable Issues related to the googleapis/java-bigtable-hbase API. labels Oct 13, 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 a mechanism to map HBase table names to Cloud Bigtable table IDs, which is particularly useful for handling HBase tables in non-default namespaces. The changes include a new TableNameMapper class to handle these mappings via inline JSON, external files, or prefixed configuration properties, and updates to CloudBigtableReplicator to apply these mappings during replication. Additionally, the PR includes robust error handling for mapping collisions, improved batching logic for replication tasks, and comprehensive unit tests to verify the new functionality.

@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch 3 times, most recently from 37af92b to e66517c Compare October 13, 2026 15:46
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch 2 times, most recently from b566432 to 59545ee Compare October 26, 2026 23:39
@vermas2012
vermas2012 requested a review from mutianf October 27, 2026 02:39
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch from 59545ee to 86cf033 Compare October 27, 2026 03:22
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Oct 27, 2026
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch 2 times, most recently from f93c64e to a8e656e Compare October 27, 2026 13:13
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Oct 27, 2026
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch 2 times, most recently from abf2246 to 831516b Compare October 27, 2026 13:25
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch from 831516b to 6074600 Compare October 27, 2026 14:54
Support mapping HBase table names (such as namespaced tables like
`my_namespace:my_table`, where `:` is not a valid Cloud Bigtable table ID
character) to Cloud Bigtable table IDs during WAL replication via
`google.bigtable.replication.table_name_mapping` in `hbase-site.xml`.

Key details:
- Single configuration surface (`google.bigtable.replication.table_name_mapping`
  in `hbase-site.xml` / Hadoop `Configuration`) using the same
  `{"source_hbase_table": "destination_bigtable_table"}` JSON structure as
  `HBaseSchemaTranslator`.
- Strict startup validation before opening the Cloud Bigtable connection or
  incrementing `SharedResources` reference counts: canonicalizes `default:`
  table names, rejects duplicate keys and N:1 mappings, and validates target
  table IDs against Cloud Bigtable's naming rules (`[_a-zA-Z0-9][-_.a-zA-Z0-9]*`,
  max 50 chars).
- Reserves configured mapping targets at runtime so an unmapped table whose
  canonical name collides with a mapped target (e.g., unmapped `table_B` when
  `ns:table_B -> table_B`) throws `IllegalStateException` before any batch
  tasks are submitted, causing `replicate()` to return `false` and halt that
  replication peer rather than silently merging two HBase tables into one
  Bigtable table.
- Includes review fixes in `CloudBigtableReplicator`:
  - Decrements `SharedResources` reference count if `start(Configuration,
    MetricsExporter)` fails after `SharedResources.getInstance(configuration)`.
  - Uses `long` for `batchSizeInBytes` and `getRowSize()` to avoid integer
    overflow.
  - Runs the per-table `replicateTable()` loop inside the `try` block in
    `replicate()` so any unexpected exception returns `false` per the method
    contract.
- Verified that `com/google/bigtable/repackaged/com/google/gson/stream/JsonReader.class`
  is shaded into both `bigtable-hbase-1.x-replication` and
  `bigtable-hbase-2.x-replication` JARs.
@vermas2012
vermas2012 force-pushed the feat/replication-table-name-mapping branch from 6074600 to f537455 Compare October 27, 2026 15:08
@vermas2012
vermas2012 requested a review from mutianf October 27, 2026 15:30
// Suppress the exception here and return false to the replication machinery.
succeeded = false;
} finally {
LOG.trace(

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.

nit: should we drain the rest of added futures if anything throws?

@mutianf
mutianf merged commit 8c6c36e into googleapis:main Oct 27, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/java-bigtable-hbase API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants