Interface TimestampLeaseAwareTransaction
@Beta
public interface TimestampLeaseAwareTransaction
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
The lambda to execute on commit(). -
Method Summary
Modifier and TypeMethodDescriptionvoid
preCommit
(com.palantir.atlasdb.common.api.timelock.TimestampLeaseName leaseName, int numLeasedTimestamps, TimestampLeaseAwareTransaction.PreCommitAction action) RegisterTimestampLeaseAwareTransaction.PreCommitAction
lambdas that are run onTransaction.commit()
just before the transaction is closed.
-
Method Details
-
preCommit
void preCommit(com.palantir.atlasdb.common.api.timelock.TimestampLeaseName leaseName, int numLeasedTimestamps, TimestampLeaseAwareTransaction.PreCommitAction action) RegisterTimestampLeaseAwareTransaction.PreCommitAction
lambdas that are run onTransaction.commit()
just before the transaction is closed.In the pre-commit lambdas, consumers can perform any actions they would inside a transaction. It is valid, for example, to read to or write from a table.
If
numLeasedTimestamps
is greater than 0, fresh timestamps will be fetched fromTransactionManager.getTimelockService()
and will be provided to the pre-commit lambda via the supplier onConsumer<LongSupplier>
.Clients can use
TimestampLeaseAwareTransactionManager.getLeasedTimestamp(TimestampLeaseName)
to fetch a timestamp before the earliest leased timestamp for a giventimestampLeaseName
on open transactions.- Parameters:
leaseName
- the name of the lease the timestamps are bound tonumLeasedTimestamps
- the number of timestamps that should be fetched and used in the pre-commit lambdaaction
- the lambda executed just before commit. Note the consumer throwsRuntimeException
if a client requests more than specified innumLeasedTimestamps
.
-