Class PartitionMetadataDao.InTransactionContext

java.lang.Object
org.apache.beam.sdk.io.gcp.spanner.changestreams.dao.PartitionMetadataDao.InTransactionContext
Enclosing class:
PartitionMetadataDao

public static class PartitionMetadataDao.InTransactionContext extends Object
Represents the execution of a read / write transaction in Cloud Spanner.
  • Constructor Details

    • InTransactionContext

      public InTransactionContext(String metadataTableName, TransactionContext transaction, Dialect dialect)
      Constructs a context to execute a user defined function transactionally.
      Parameters:
      metadataTableName - the name of the partition metadata table
      transaction - the underlying client library transaction to be executed
      dialect - the dialect of the database.
  • Method Details

    • insert

      public Void insert(PartitionMetadata row)
      Inserts the partition metadata.
      Parameters:
      row - the partition metadata to be inserted
    • updateToScheduled

      public Void updateToScheduled(List<String> partitionTokens)
      Updates multiple partition rows to PartitionMetadata.State.SCHEDULED state.
      Parameters:
      partitionTokens - the partitions' unique identifiers
    • updateToRunning

      public Void updateToRunning(String partitionToken)
      Updates a partition row to PartitionMetadata.State.RUNNING state.
      Parameters:
      partitionToken - the partition unique identifier
    • updateToFinished

      public Void updateToFinished(String partitionToken)
      Updates a partition row to PartitionMetadata.State.FINISHED state.
      Parameters:
      partitionToken - the partition unique identifier
    • updateWatermark

      public Void updateWatermark(String partitionToken, com.google.cloud.Timestamp watermark)
      Update the partition watermark to the given timestamp.
      Parameters:
      partitionToken - the partition unique identifier
      watermark - the new partition watermark
      Returns:
      the commit timestamp of the read / write transaction
    • getPartition

      @Nullable public Struct getPartition(String partitionToken)
      Fetches the partition metadata row data for the given partition token.
      Parameters:
      partitionToken - the partition unique identifier
      Returns:
      the partition metadata for the given token if it exists as a struct. Otherwise, it returns null.