public abstract class AbstractTransactionalContext extends Object implements Comparable<AbstractTransactionalContext>
Recall from CorfuCompileProxy
that an SMR object layer implements objects whose
history of updates
are backed by a stream. If a Corfu object's method is an Accessor, it invokes the proxy's
access() method. Likewise, if a Corfu object's method is a Mutator or Accessor-Mutator,
it invokes the proxy's logUpdate() method.
Within transactional context, these methods invoke the transactionalContext accessor/mutator helper.
For example, OptimisticTransactionalContext.access() is responsible for sync'ing the proxy state to the snapshot version, and then doing the access.
logUpdate() within transactional context is responsible for updating the write-set.
Finally, if a Corfu object's method is an Accessor-Mutator, then although the mutation is delayed, it needs to obtain the result by invoking getUpcallResult() on the optimistic stream. This is similar to the second stage of access(), except working on the optimistic stream instead of the underlying stream.
Created by mwei on 4/4/16.
Modifier and Type | Field and Description |
---|---|
static long |
ABORTED_ADDRESS
Constant for a transaction which has been aborted.
|
long |
commitAddress
The address that the transaction was committed at.
|
CompletableFuture<Boolean> |
completionFuture
A future which gets completed when this transaction commits.
|
static long |
FOLDED_ADDRESS
Constant for a transaction which has been folded into
another transaction.
|
static long |
NOWRITE_ADDRESS
Constant for committing a transaction which did not
modify the log at all.
|
long |
startTime
The start time of the context.
|
Transaction |
transaction
The builder used to create this transaction.
|
UUID |
transactionID
The ID of the transaction.
|
static long |
UNCOMMITTED_ADDRESS
Constant for the address of an uncommitted log entry.
|
Modifier and Type | Method and Description |
---|---|
void |
abortTransaction(TransactionAbortedException ae)
Forcefully abort the transaction.
|
abstract <R,T> R |
access(ICorfuSMRProxyInternal<T> proxy,
ICorfuSMRAccess<R,T> accessFunction,
Object[] conflictObject)
Access the state of the object.
|
void |
addToReadSet(ICorfuSMRProxyInternal proxy,
Object[] conflictObjects)
Add the proxy and conflict-params information to our read set.
|
abstract void |
addTransaction(AbstractTransactionalContext tc)
Add a given transaction to this transactional context, merging
the read and write sets.
|
long |
commitTransaction()
Commit the transaction to the log.
|
int |
compareTo(AbstractTransactionalContext o)
Transactions are ordered by their snapshot timestamp.
|
abstract <T> Object |
getUpcallResult(ICorfuSMRProxyInternal<T> proxy,
long timestamp,
Object[] conflictObject)
Get the result of an upcall.
|
abstract <T> long |
logUpdate(ICorfuSMRProxyInternal<T> proxy,
SMREntry updateEntry,
Object[] conflictObject)
Log an SMR update to the Corfu log.
|
void |
syncWithRetryUnsafe(VersionLockedObject vlo,
Token snapshotTimestamp,
ICorfuSMRProxyInternal proxy,
Consumer<VersionLockedObject> optimisticStreamSetter) |
String |
toString() |
public static final long UNCOMMITTED_ADDRESS
public static final long FOLDED_ADDRESS
public static final long ABORTED_ADDRESS
public static final long NOWRITE_ADDRESS
public UUID transactionID
public final Transaction transaction
public final long startTime
public long commitAddress
public CompletableFuture<Boolean> completionFuture
public abstract <R,T> R access(ICorfuSMRProxyInternal<T> proxy, ICorfuSMRAccess<R,T> accessFunction, Object[] conflictObject)
R
- The return type of the access function.T
- The type of the proxy's underlying object.proxy
- The proxy to access the state for.accessFunction
- The function to execute, which will be provided with the state
of the object.conflictObject
- Fine-grained conflict information, if available.public abstract <T> Object getUpcallResult(ICorfuSMRProxyInternal<T> proxy, long timestamp, Object[] conflictObject)
T
- The type of the proxy's underlying object.proxy
- The proxy to retrieve the upcall for.timestamp
- The timestamp to return the upcall for.conflictObject
- Fine-grained conflict information, if available.public void syncWithRetryUnsafe(VersionLockedObject vlo, Token snapshotTimestamp, ICorfuSMRProxyInternal proxy, @Nullable Consumer<VersionLockedObject> optimisticStreamSetter)
public abstract <T> long logUpdate(ICorfuSMRProxyInternal<T> proxy, SMREntry updateEntry, Object[] conflictObject)
T
- The type of the proxy's underlying object.proxy
- The proxy which generated the update.updateEntry
- The entry which we are writing to the log.conflictObject
- Fine-grained conflict information, if available.public abstract void addTransaction(AbstractTransactionalContext tc)
tc
- The transactional context to merge.public long commitTransaction() throws TransactionAbortedException
TransactionAbortedException
- If the transaction is aborted.public void abortTransaction(TransactionAbortedException ae)
public void addToReadSet(ICorfuSMRProxyInternal proxy, Object[] conflictObjects)
proxy
- The proxy to addconflictObjects
- The fine-grained conflict information, if
available.public int compareTo(AbstractTransactionalContext o)
compareTo
in interface Comparable<AbstractTransactionalContext>
Copyright © 2019 CorfuDB. All rights reserved.