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 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.cloud.spanner.Struct
getPartition(java.lang.String partitionToken)
Fetches the partition metadata row data for the given partition token.java.lang.Void
insert(PartitionMetadata row)
Inserts the partition metadata.java.lang.Void
updateToFinished(java.lang.String partitionToken)
Updates a partition row toPartitionMetadata.State.FINISHED
state.java.lang.Void
updateToRunning(java.lang.String partitionToken)
Updates a partition row toPartitionMetadata.State.RUNNING
state.java.lang.Void
updateToScheduled(java.util.List<java.lang.String> partitionTokens)
Updates multiple partition rows toPartitionMetadata.State.SCHEDULED
state.java.lang.Void
updateWatermark(java.lang.String partitionToken, com.google.cloud.Timestamp watermark)
Update the partition watermark to the given timestamp.
-
-
-
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 tabletransaction
- the underlying client library transaction to be executeddialect
- 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 toPartitionMetadata.State.SCHEDULED
state.- Parameters:
partitionTokens
- the partitions' unique identifiers
-
updateToRunning
public java.lang.Void updateToRunning(java.lang.String partitionToken)
Updates a partition row toPartitionMetadata.State.RUNNING
state.- Parameters:
partitionToken
- the partition unique identifier
-
updateToFinished
public java.lang.Void updateToFinished(java.lang.String partitionToken)
Updates a partition row toPartitionMetadata.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 identifierwatermark
- 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.
-
-