Class MetadataTableAdminDao

java.lang.Object
org.apache.beam.sdk.io.gcp.bigtable.changestreams.dao.MetadataTableAdminDao

@Internal public class MetadataTableAdminDao extends Object
Data access object for creating and dropping the metadata table.

The metadata table will be used to keep the state of the entire Beam pipeline as well as splitting and merging partitions.

Each Beam pipeline will create its own metadata table.

  • Field Details

  • Constructor Details

    • MetadataTableAdminDao

      public MetadataTableAdminDao(com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient tableAdminClient, com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient instanceAdminClient, String changeStreamName, String tableId)
  • Method Details

    • getChangeStreamNamePrefix

      public ByteString getChangeStreamNamePrefix()
      Return the prefix used to identify the rows belonging to this job.
      Returns:
      the prefix used to identify the rows belonging to this job
    • getTableId

      public String getTableId()
      Return the metadata table name.
      Returns:
      the metadata table name
    • isAppProfileSingleClusterAndTransactional

      public boolean isAppProfileSingleClusterAndTransactional(String appProfileId)
      Verify the app profile is for single cluster routing with allow single-row transactions enabled. For metadata data operations, the app profile needs to be single cluster routing because it requires read-after-write consistency. Also, the operations depend on single row transactions operations like CheckAndMutateRow.
      Returns:
      true if the app profile is single-cluster and allows single-row transactions, otherwise false
    • doesMetadataTableExist

      public boolean doesMetadataTableExist()
      Returns:
      true if metadata table exists, otherwise false.
    • createMetadataTable

      public boolean createMetadataTable()
      Create the metadata table if it does not exist yet. If the table does exist, verify all the column families exists, if not add those column families. This table only need to be created once per instance. All change streams jobs will use this table. This table is created in the same instance as the table being streamed. While we don't restrict access to the table, manually editing the table can lead to inconsistent beam jobs.
      Returns:
      true if the table was successfully created, otherwise false.
    • cleanUpPrefix

      public void cleanUpPrefix()
      Delete all the metadata rows starting with the change stream name prefix, except for detect new partition row because it signals the existence of a pipeline with the change stream name.