public class PartitionMetadataDao
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PartitionMetadataDao.InTransactionContext
Represents the execution of a read / write transaction in Cloud Spanner.
|
static class |
PartitionMetadataDao.TransactionResult<T>
Represents a result from executing a Cloud Spanner read / write transaction.
|
Modifier and Type | Method and Description |
---|---|
ResultSet |
getAllPartitionsCreatedAfter(com.google.cloud.Timestamp timestamp)
Fetches all partitions with a
PartitionMetadataAdminDao.COLUMN_CREATED_AT less than the
given timestamp. |
Struct |
getPartition(java.lang.String partitionToken)
Fetches the partition metadata row data for the given partition token.
|
com.google.cloud.Timestamp |
getUnfinishedMinWatermark()
Fetches the earliest partition watermark from the partition metadata table that is not in a
PartitionMetadata.State.FINISHED state. |
com.google.cloud.Timestamp |
insert(PartitionMetadata row)
Inserts the partition metadata.
|
<T> PartitionMetadataDao.TransactionResult<T> |
runInTransaction(java.util.function.Function<PartitionMetadataDao.InTransactionContext,T> callable)
Runs a given function in a transaction context.
|
boolean |
tableExists()
Checks whether the metadata table already exists in the database.
|
com.google.cloud.Timestamp |
updateToFinished(java.lang.String partitionToken)
Updates a partition row to
PartitionMetadata.State.FINISHED state. |
com.google.cloud.Timestamp |
updateToRunning(java.lang.String partitionToken)
Updates a partition row to
PartitionMetadata.State.RUNNING state. |
com.google.cloud.Timestamp |
updateToScheduled(java.util.List<java.lang.String> partitionTokens)
Updates multiple partition row to
PartitionMetadata.State.SCHEDULED state. |
void |
updateWatermark(java.lang.String partitionToken,
com.google.cloud.Timestamp watermark)
Update the partition watermark to the given timestamp.
|
public boolean tableExists()
@Nullable public Struct getPartition(java.lang.String partitionToken)
partitionToken
- the partition unique identifier@Nullable public com.google.cloud.Timestamp getUnfinishedMinWatermark()
PartitionMetadata.State.FINISHED
state.PartitionMetadata.State.FINISHED
state.public ResultSet getAllPartitionsCreatedAfter(com.google.cloud.Timestamp timestamp)
PartitionMetadataAdminDao.COLUMN_CREATED_AT
less than the
given timestamp. The results are ordered by the PartitionMetadataAdminDao.COLUMN_CREATED_AT
and PartitionMetadataAdminDao.COLUMN_START_TIMESTAMP
columns in ascending order.public com.google.cloud.Timestamp insert(PartitionMetadata row)
row
- the partition metadata to be insertedpublic com.google.cloud.Timestamp updateToScheduled(java.util.List<java.lang.String> partitionTokens)
PartitionMetadata.State.SCHEDULED
state.partitionTokens
- the partitions' unique identifierspublic com.google.cloud.Timestamp updateToRunning(java.lang.String partitionToken)
PartitionMetadata.State.RUNNING
state.partitionToken
- the partition unique identifierpublic com.google.cloud.Timestamp updateToFinished(java.lang.String partitionToken)
PartitionMetadata.State.FINISHED
state.partitionToken
- the partition unique identifierpublic void updateWatermark(java.lang.String partitionToken, com.google.cloud.Timestamp watermark)
partitionToken
- the partition unique identifierwatermark
- the new partition watermarkpublic <T> PartitionMetadataDao.TransactionResult<T> runInTransaction(java.util.function.Function<PartitionMetadataDao.InTransactionContext,T> callable)
T
- the return type to be returned from the input transactional functioncallable
- the function to be executed within the transaction context