public final class TransactionManager
extends java.lang.Object
We say that a transaction has acquired a write lock on an object if any entry
in the object's $history
list has $writeLockHolder
set to that transaction. @see fabric.lang.Object._Impl
We say that a transaction has acquired a read lock if it is in the "read list" for that object. @see fabric.lang.Object._Impl.$readMapEntry
When a transaction acquires a read lock, we ensure that the read condition holds: that the holder of the write lock is an ancestor of that transaction. Before reading an object, we ensure that the transaction holds a read lock and that the read condition still holds.
When a transaction acquires a write lock, we ensure that the write condition holds: the holders of the read and write locks are all ancestors of that transaction. Before writing an object, we ensure that the transaction holds a write lock and that the write condition still holds.
Assumptions:
The following objects are used as condition variables:
Modifier and Type | Field and Description |
---|---|
static java.lang.ThreadLocal<java.lang.Long> |
COMMIT_TIME
XXX Really gross HACK to make actual transaction commit times visible to
the application.
|
static java.lang.ThreadLocal<java.lang.String[]> |
CONTACTED_NODES
XXX Similarly gross HACK for making the nodes contacted by this client
during commit visible to the application.
|
static java.lang.ThreadLocal<java.lang.Integer> |
ROUND_TRIPS
XXX Similarly gross HACK for making transaction commit round trips visible
to the application.
|
static boolean |
TRACE_WRITE_LOCKS
A debugging switch for storing a stack trace each time a write lock is
obtained.
|
Modifier and Type | Method and Description |
---|---|
static void |
abortReaders(Store store,
long onum) |
void |
abortTransaction()
Aborts the transaction, recursing to any workers that were called, and any
stores that were contacted.
|
void |
associateAndSyncLog(Log log,
TransactionID tid)
Associates the given log with this worker's transaction manager and
synchronizes the log with the given tid.
|
void |
associateLog(Log log)
Associates the given transaction log with this transaction manager.
|
boolean |
checkForStaleObjects()
Checks whether any of the objects used by a transaction are stale.
|
void |
commitTransaction()
Commits the transaction if possible; otherwise, aborts the transaction.
|
void |
commitTransaction(boolean ignoreRetrySignal) |
void |
deregisterThread(java.lang.Thread thread)
Registers that the given thread has finished.
|
Log |
getCurrentLog() |
TransactionID |
getCurrentTid() |
RemoteWorker |
getFetchWorker(Object._Proxy proxy) |
static TransactionManager |
getInstance() |
static ReadMap.Entry |
getReadMapEntry(Object._Impl impl,
long expiry) |
SecurityCache |
getSecurityCache() |
WriterMap |
getWriterMap() |
static boolean |
haveReaders(Store store,
long onum) |
void |
registerCreate(Object._Impl obj) |
void |
registerLabelsInitialized(Object._Impl obj) |
void |
registerRead(Object._Impl obj) |
void |
registerRemoteCall(RemoteWorker worker)
Registers a remote call to the given worker.
|
void |
registerThread(java.lang.Thread thread)
Registers the given thread with the current transaction.
|
boolean |
registerWrite(Object._Impl obj)
This should be called before the object is modified.
|
void |
sendCommitMessagesAndCleanUp()
Sends commit messages to the cohorts in a distributed transaction.
|
void |
sendPrepareMessages()
Sends prepare messages to the cohorts in a distributed transaction.
|
static void |
startThread(java.lang.Thread thread)
Starts the given thread, registering it as necessary.
|
void |
startTransaction()
Starts a new transaction.
|
void |
startTransaction(TransactionID tid)
Starts a new transaction with the given tid.
|
public static boolean TRACE_WRITE_LOCKS
public static final java.lang.ThreadLocal<java.lang.Long> COMMIT_TIME
public static final java.lang.ThreadLocal<java.lang.Integer> ROUND_TRIPS
public static final java.lang.ThreadLocal<java.lang.String[]> CONTACTED_NODES
public static boolean haveReaders(Store store, long onum)
public static void abortReaders(Store store, long onum)
public static ReadMap.Entry getReadMapEntry(Object._Impl impl, long expiry)
public static TransactionManager getInstance()
public void abortTransaction()
public void commitTransaction() throws AbortException, TransactionRestartingException, TransactionAtomicityViolationException
AbortException
- if the transaction was aborted.TransactionRestartingException
- if the transaction was aborted and needs to be retried.TransactionAtomicityViolationException
public void commitTransaction(boolean ignoreRetrySignal)
TransactionRestartingException
- if the prepare fails.public void sendPrepareMessages()
TransactionRestartingException
- if the prepare fails.public void sendCommitMessagesAndCleanUp() throws TransactionAtomicityViolationException
public void registerCreate(Object._Impl obj)
public void registerLabelsInitialized(Object._Impl obj)
public void registerRead(Object._Impl obj)
public boolean registerWrite(Object._Impl obj)
public boolean checkForStaleObjects()
public void startTransaction()
public void startTransaction(TransactionID tid)
public static void startThread(java.lang.Thread thread)
public void registerThread(java.lang.Thread thread)
public void deregisterThread(java.lang.Thread thread)
public void registerRemoteCall(RemoteWorker worker)
public void associateLog(Log log)
public Log getCurrentLog()
public TransactionID getCurrentTid()
public WriterMap getWriterMap()
public RemoteWorker getFetchWorker(Object._Proxy proxy)
public SecurityCache getSecurityCache()
public void associateAndSyncLog(Log log, TransactionID tid)