Class PartitionMetadataDao.InTransactionContext

  • Enclosing class:
    PartitionMetadataDao

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

      Constructors 
      Constructor Description
      InTransactionContext​(java.lang.String metadataTableName, com.google.cloud.spanner.TransactionContext transaction, com.google.cloud.spanner.Dialect dialect)
      Constructs a context to execute a user defined function transactionally.
    • Constructor Detail

      • InTransactionContext

        public InTransactionContext​(java.lang.String metadataTableName,
                                    com.google.cloud.spanner.TransactionContext transaction,
                                    com.google.cloud.spanner.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 Detail

      • insert

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

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

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

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

        public java.lang.Void updateWatermark​(java.lang.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 com.google.cloud.spanner.Struct getPartition​(java.lang.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.